:root {
  --ink: #22352b;
  --ink-soft: #55625a;
  --paper: #e7e9e1;
  --surface: #ffffff;
  --honey: #c98a10;
  --honey-wash: #f7ecd2;
  --moss: #3e6b4f;
  --stone: #8d9388;
  --rule: #d2d6c9;
  --danger: #a33b2c;

  --sans: "Karla", ui-sans-serif, system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;

  --gap: 1rem;
  --spine: 5px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--moss); }

:focus-visible {
  outline: 2px solid var(--honey);
  outline-offset: 2px;
}

/* ---------- shared pieces ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.logo {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
}
.logo-lg { width: 2.75rem; height: 2.75rem; }

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
}

/* Icons sit with the text, never larger than it. */
.btn i, .list-heading i, .tag-soon i, .no-messages i, .form-error i {
  font-size: 0.9em;
}
.list-heading i { margin-right: 0.45rem; color: var(--stone); }
.tag-soon i { margin-right: 0.28rem; }

.empty i {
  display: block;
  font-size: 1.6rem;
  color: var(--stone);
  margin-bottom: 0.6rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 0.5rem 0.9rem;
  background: none;
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: #2d4638; }

.btn-quiet {
  border-color: var(--rule);
  background: var(--surface);
  color: var(--ink);
}
.btn-quiet:hover { border-color: var(--ink-soft); }

.btn-ghost {
  color: inherit;
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
}
.btn-ghost:hover { text-decoration: underline; }

.btn-block { width: 100%; }

.btn-danger { color: var(--danger); font-size: 0.85rem; padding-inline: 0; }
.btn-danger:hover { text-decoration: underline; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
  padding: 0.6rem 0.7rem;
}
textarea { resize: vertical; }

/* ---------- sign in ---------- */

.signin-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--gap);
}

.signin { width: min(23rem, 100%); }

.signin-mark { margin-bottom: 1.75rem; }
.signin-mark .wordmark { font-size: 2.1rem; }
.signin-mark .brand { gap: 0.7rem; }

.signin-sub {
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.signin-form {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: var(--spine) solid var(--honey);
  padding: 1.25rem;
}

.signin-form label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.signin-form label:first-of-type { margin-top: 0; }

.signin-form .btn { margin-top: 1.2rem; }

.form-error {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  background: #f6e3e0;
  border-left: 3px solid var(--danger);
  color: #6f251a;
  font-size: 0.9rem;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.6rem clamp(0.75rem, 3vw, 1.5rem);
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  background: var(--ink);
  color: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-actions { display: flex; align-items: center; gap: 0.35rem; }

@media (max-width: 34rem) {
  .topbar-actions .label { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar-actions .btn { font-size: 1.05rem; padding: 0.4rem 0.5rem; }
}

#bell[data-state="on"] { color: var(--honey-wash); }
#bell[hidden] { display: none; }

/* ---------- layout ---------- */

.layout {
  max-width: 68rem;
  margin: 0 auto;
  padding: var(--gap) clamp(0.75rem, 3vw, 1.5rem) 3rem;
}

.resting { margin-top: 0; }

/* ---------- composer ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.composer {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: var(--spine) solid var(--honey);
  border-radius: 2px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.composer-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  background: var(--honey-wash);
  border-bottom: 1px solid #e6d5ae;
}
.composer-head i { color: #a2700c; font-size: 0.95rem; }
.composer-head h2 {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

/* The request is typed in the same serif it will be read in. */
input[type="text"].title-input {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  padding: 0.85rem 0.9rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
input[type="text"].title-input::placeholder {
  font-weight: 400;
  color: #9aa197;
}
input[type="text"].title-input:focus {
  outline: none;
  border-bottom-color: var(--honey);
  box-shadow: inset 0 -2px 0 var(--honey);
}

.composer-more {
  padding: 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.composer-more textarea {
  border-color: var(--rule);
  background: #fcfcfa;
}
.composer-more textarea:focus {
  outline: none;
  border-color: var(--ink-soft);
  background: var(--surface);
}

/* --- segmented urgency control --- */

.segmented {
  border: 0;
  margin: 0.9rem 0 0;
  padding: 0;
}
.segmented legend {
  padding: 0;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.segmented-track {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
}
.segmented-track label {
  flex: 1;
  text-align: center;
  padding: 0.42rem 0.3rem;
  font-size: 0.88rem;
  cursor: pointer;
  background: #fcfcfa;
  border-left: 1px solid var(--rule);
  color: var(--ink-soft);
  transition: background 0.12s ease, color 0.12s ease;
}
.segmented-track label:first-of-type { border-left: 0; }
.segmented-track input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-track label:hover { background: #f3f4ee; }
.segmented-track input:checked + label {
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
}
.segmented-track input#pri-soon:checked + label,
.segmented-track input[value="soon"]:checked + label {
  background: var(--honey);
  color: #2b1f00;
}
.segmented-track input:focus-visible + label {
  outline: 2px solid var(--honey);
  outline-offset: -2px;
}

/* --- photo dropzone --- */

.dropzone {
  margin-top: 0.9rem;
  border: 1px dashed var(--rule);
  border-radius: 2px;
  background: #fcfcfa;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.dropzone.dragging {
  border-color: var(--honey);
  background: var(--honey-wash);
}
.dropzone.has-files { border-style: solid; }

.dropzone-cue {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
}
.dropzone-cue i {
  font-size: 1.15rem;
  color: var(--stone);
}
.dropzone-main { font-weight: 500; }
.dropzone-note {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: right;
}
.dropzone-note.ready { color: var(--moss); font-weight: 500; }
.dropzone-note.over { color: var(--danger); font-weight: 500; }
.dropzone-cue:hover i { color: var(--honey); }
.dropzone input:focus-visible + .dropzone-cue {
  outline: 2px solid var(--honey);
  outline-offset: -2px;
}

.previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.8rem 0.8rem;
}
.previews:empty { display: none; }
.previews img {
  width: 3.6rem;
  height: 3.6rem;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.composer-actions {
  padding: 0.75rem 0.9rem;
  display: flex;
  justify-content: flex-end;
}
.composer-actions[hidden] { display: none; }

/* ---------- request list ---------- */

.list { display: flex; flex-direction: column; gap: 0.6rem; }

.list-heading {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 1.1rem 0 0.1rem;
}
.list-heading:first-child { margin-top: 0; }

.slip {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: var(--spine) solid var(--stone);
  border-radius: 2px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
}
.slip:hover { border-color: var(--ink-soft); border-left-color: var(--honey); }
.slip[data-status="open"] { border-left-color: var(--honey); }
.slip[data-status="doing"] { border-left-color: var(--moss); }
.slip[data-status="done"] { border-left-color: var(--rule); background: #f4f5f0; }
.slip[aria-current="true"] { border-color: var(--ink); }

.slip-title {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0;
}
.slip[data-status="done"] .slip-title {
  font-weight: 400;
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--stone);
}

.slip-meta {
  margin-top: 0.3rem;
  font-size: 0.83rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tag-soon { color: #8a5a00; font-weight: 700; }

.unread {
  background: var(--honey);
  color: #2b1f00;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--rule);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}
.empty p { margin: 0; }

/* ---------- thread ---------- */

.thread-head {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: var(--spine) solid var(--honey);
  padding: 0.9rem;
}
.thread-head[data-status="doing"] { border-left-color: var(--moss); }
.thread-head[data-status="done"] { border-left-color: var(--rule); }

.thread-title {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
}

.thread-meta {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.thread-details {
  margin: 0.75rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--rule);
  white-space: pre-wrap;
}

.thread-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
  align-items: center;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.7rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--moss);
  cursor: pointer;
}
.back-link:hover { text-decoration: underline; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 1.1rem 0;
}

.bubble {
  max-width: 34rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
}
.bubble.mine {
  align-self: flex-end;
  background: var(--honey-wash);
  border-color: #e3d2ac;
}
.bubble p { margin: 0; white-space: pre-wrap; }
.bubble .who {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}
.bubble.fresh { animation: rise 0.22s ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(0.4rem); }
  to   { opacity: 1; transform: none; }
}

.no-messages {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 1.1rem 0;
}

.reply {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.reply textarea { flex: 1; }


/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.55rem 0.9rem;
  border-radius: 2px;
  font-size: 0.9rem;
  z-index: 20;
  max-width: calc(100% - 2rem);
}
.toast[hidden] { display: none; }
.toast[data-kind="error"] { background: var(--danger); }

/* ---------- two panes ---------- */

@media (min-width: 60rem) {
  .layout {
    display: grid;
    grid-template-columns: 22rem 1fr;
    gap: 1.5rem;
    align-items: start;
  }
  .back-link { display: none; }
}

@media (max-width: 59.99rem) {
  .pane-thread { display: none; }
  body.viewing-thread .pane-thread { display: block; }
  body.viewing-thread .pane-list { display: none; }
  .pane-thread { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- photos ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.shot {
  position: relative;
  margin: 0;
  border: 1px solid var(--rule);
  background: var(--paper);
}
.shot img {
  display: block;
  width: 100%;
  height: 9rem;
  object-fit: cover;
}
.shot a:focus-visible { outline-offset: -3px; }

.shot-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  border-radius: 50%;
  background: rgba(34, 53, 43, 0.82);
  color: var(--paper);
  cursor: pointer;
  line-height: 1;
  font-size: 0.85rem;
}
.shot-remove:hover { background: var(--danger); }

/* ---------- file picker ---------- */

.pickfile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}
.pickfile input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.pickfile label.btn { margin: 0; }
.pickfile input[type="file"]:focus-visible + .pickfile-note,
.pickfile input[type="file"]:focus-visible ~ .pickfile-note { text-decoration: underline; }

.pickfile-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.pickfile-note.has-files { color: var(--moss); font-weight: 500; }

/* ---------- edit form ---------- */

.thread-head.editing { border-left-color: var(--moss); }

.field-label {
  display: block;
  margin: 0.8rem 0 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
#edit-form .field-label:first-child { margin-top: 0; }
