/* Inbox: the swatch card. Every chat carries one chip; its colour is its state.
   Lacquer red means "needs you" and nothing else. */
:root {
  --ground: #FBFAF8;
  --surface: #FFFFFF;
  --hover: #F5F0EC;
  --selected: #EFE7E1;
  --ink: #1F1A1C;
  --ink-2: #554C50;
  --ink-3: #6E6569;
  --rule: #E6E0DB;
  --rule-soft: #EFEAE6;

  --needs: #C8102E;
  --needs-text: #A80D27;
  --needs-wash: #FBEEF0;
  --you: #6B2D5C;
  --you-wash: #F3EAF0;
  --assistant: #E4CDBE;
  --assistant-wash: #F4EAE3;
  --booked: #B9C9B2;
  --booked-text: #3F5A38;
  --closed: #D9D2CC;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; }
body {
  background: var(--ground); color: var(--ink);
  font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  caret-color: var(--you);
}
::selection { background: var(--assistant); color: var(--ink); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--closed) transparent; }
.num { font-variant-numeric: tabular-nums; }
.code { font: 500 11px/1 var(--mono); letter-spacing: .04em; color: var(--ink-3); text-transform: uppercase; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- swatch chips ---------- */
.chip { display: inline-block; width: 12px; height: 18px; border-radius: 3px; flex: none; background: var(--c); }
.s-needs { --c: var(--needs); }
.s-you { --c: var(--you); }
.s-assistant { --c: var(--assistant); }
.s-booked { --c: var(--booked); }
.s-closed { --c: var(--closed); }
.repaint { animation: repaint 520ms var(--ease) both; }
@keyframes repaint { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 8px;
  font-weight: 600; font-size: 14px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  transition: background 160ms, border-color 160ms; white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: #D8D0CA; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #3A3236; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sign in ---------- */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.signin form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.signin .swatches { display: flex; gap: 6px; margin-bottom: 18px; }
.signin .swatches .chip { width: 18px; height: 30px; }
.signin h1 { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.signin p { color: var(--ink-2); margin: -6px 0 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface);
  font-size: 15px; font-weight: 400; color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--ink); }
.signin .btn { height: 44px; justify-content: center; margin-top: 6px; }
.error { color: var(--needs-text); font-size: 14px; }

/* ---------- shell ---------- */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 216px minmax(320px, 380px) minmax(0, 1fr) 300px; }
.rail { border-right: 1px solid var(--rule); padding: 24px 14px 18px; display: flex; flex-direction: column; min-height: 0; }
.rail .who { padding: 0 8px; }
.rail .product { display: flex; align-items: center; gap: 8px; }
.rail .salon { font-size: 18px; font-weight: 650; letter-spacing: -.01em; margin: 6px 0 2px; }
.rail .mode { font-size: 12px; color: var(--ink-3); }
.legend { list-style: none; display: flex; flex-direction: column; gap: 2px; margin-top: 28px; }
.legend button {
  width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: center;
  padding: 8px; border-radius: 8px; font-size: 14px; text-align: left; color: var(--ink);
}
.legend button:hover { background: var(--hover); }
.legend button[aria-pressed="true"] { background: var(--selected); font-weight: 600; }
.legend .all { width: 12px; height: 18px; border-radius: 3px; border: 1.5px solid var(--ink-3); }
.legend .count { font: 500 12px/1 var(--mono); color: var(--ink-3); }
.legend .needs .count { color: var(--needs-text); font-weight: 700; }
.rail .foot { margin-top: auto; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; color: var(--ink-3); font-size: 13px; }

/* ---------- list ---------- */
.list { border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; background: var(--ground); }
.list-head { padding: 24px 20px 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.list-head h2 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; }
.list-head .side-tools { display: flex; align-items: center; gap: 4px; }
.list-head .compact { display: none; }
.chips-row { display: none; }
.salon-small { display: none; }
.rows { overflow-y: auto; flex: 1; list-style: none; }
a.row { color: inherit; text-decoration: none; }
.row {
  width: 100%; display: grid; grid-template-columns: 6px minmax(0, 1fr); gap: 14px; text-align: left;
  padding: 14px 20px 14px 0; border-bottom: 1px solid var(--rule-soft); transition: background 120ms;
}
.row:hover { background: var(--hover); }
.row[aria-current="true"] { background: var(--selected); }
.row .chip { width: 6px; height: auto; border-radius: 0 3px 3px 0; align-self: stretch; }
.row .top { display: flex; align-items: baseline; gap: 8px; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .via { font-size: 12px; color: var(--ink-3); flex: none; }
.row .time { margin-left: auto; font-size: 12px; color: var(--ink-3); flex: none; }
.row .snippet { color: var(--ink-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.state-line { font-size: 12.5px; margin-top: 5px; color: var(--ink-3); font-weight: 500; }
.state-line.needs { color: var(--needs-text); font-weight: 650; }
.state-line.you { color: var(--you); font-weight: 600; }
.state-line.booked { color: var(--booked-text); }
.empty { padding: 48px 24px; color: var(--ink-2); text-align: left; }
.empty h3 { font-size: 17px; color: var(--ink); margin-bottom: 4px; font-weight: 600; }

/* ---------- thread ---------- */
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.thread-head { padding: 16px 24px; border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 12px; }
.thread-head .back { display: none; }
.thread-head .title { min-width: 0; flex: 1; }
.thread-head h1 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .meta { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .actions { display: flex; gap: 8px; }
.notice { margin: 16px 24px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--needs-wash); color: var(--needs-text); font-size: 14px; }
.notice b { font-weight: 650; }
.notice.you { background: var(--you-wash); color: var(--you); }
.notice span { color: var(--ink-2); }
.scroll { flex: 1; overflow-y: auto; padding: 8px 0 24px; }
.timeline { display: grid; grid-template-columns: 6px minmax(0, 1fr); column-gap: 22px; max-width: 760px; }
.timeline .strip { background: var(--c); border-radius: 0; }
.timeline .strip.first { border-top-right-radius: 3px; }
.timeline .strip.last { border-bottom-right-radius: 3px; }
.item { padding: 6px 24px 6px 0; display: flex; flex-direction: column; }
.day { padding: 18px 24px 6px 0; }
.day span { font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.label { font-size: 12px; color: var(--ink-3); margin: 8px 0 4px; }
.item.out { align-items: flex-end; }
.bubble { max-width: min(520px, 88%); padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.bubble.client { background: var(--ground); border: 1px solid var(--rule); border-top-left-radius: 4px; }
.bubble.bot { background: var(--assistant-wash); border-top-right-radius: 4px; }
.bubble.owner { background: var(--you); color: #fff; border-top-right-radius: 4px; }
.bubble.owner::selection { background: #fff; color: var(--you); }
.event { align-self: center; display: inline-flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.event .chip { width: 8px; height: 14px; }
.event.needs { color: var(--needs-text); font-weight: 600; }
.event.booked { color: var(--booked-text); font-weight: 600; }
.event .detail { color: var(--ink-3); font-weight: 400; }

.composer { border-top: 1px solid var(--rule); padding: 12px 24px 16px; }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 180px; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--ground); font-size: 15px; line-height: 1.4;
}
.composer textarea:focus { outline: none; border-color: var(--ink); background: var(--surface); }
.composer textarea::placeholder { color: var(--ink-3); }
.composer .send { height: 44px; width: 44px; justify-content: center; padding: 0; }
.composer .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.composer .error { margin-top: 8px; }
.placeholder { flex: 1; display: grid; place-items: center; padding: 32px; }
.placeholder .key { display: flex; flex-direction: column; gap: 10px; max-width: 300px; }
.placeholder h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.placeholder .k { display: flex; gap: 12px; align-items: center; color: var(--ink-2); font-size: 14px; }

/* ---------- client panel ---------- */
.side { border-left: 1px solid var(--rule); padding: 24px 22px; overflow-y: auto; background: var(--ground); }
.side h3 { font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 26px 0 10px; }
.side h3:first-child { margin-top: 4px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.kv span:first-child { color: var(--ink-3); }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }
.booking { padding: 10px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; display: grid; grid-template-columns: 8px 1fr; gap: 12px; }
.booking .chip { width: 8px; height: 100%; }
.booking b { font-weight: 600; display: block; }
.booking span { color: var(--ink-2); }
.muted { color: var(--ink-3); font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1360px) {
  .app { grid-template-columns: 216px minmax(300px, 360px) minmax(0, 1fr); }
  .side { display: none; }
}
@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); }
  .rail { display: none; }
  .list-head .compact { display: grid; }
  .list-head .count-all { display: none; }
  .list-head .salon-small { display: block; font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
  .list-head { padding: 18px 16px 6px; }
  .chips-row { display: flex; gap: 6px; padding: 4px 16px 12px; overflow-x: auto; scrollbar-width: none; }
  .chips-row button {
    flex: none; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 10px;
    border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); font-size: 13.5px; font-weight: 500;
  }
  .chips-row button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
  .chips-row button[aria-pressed="true"] .code { color: #E9E3DF; }
  .chips-row .chip { width: 8px; height: 14px; }
  .row { padding-right: 16px; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app.open .list { display: none; }
  .app:not(.open) .thread { display: none; }
  .list { border-right: 0; }
  .thread-head { padding: 10px 12px 10px 6px; }
  .thread-head .back { display: grid; }
  .thread-head .actions .btn { padding: 0 12px; }
  .notice { margin: 12px 16px 0; }
  .item, .day { padding-right: 16px; }
  .timeline { column-gap: 14px; }
  .composer { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .bubble { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  .repaint { animation: none; }
  * { transition: none !important; }
}
