/* Lydia Website Studio — brand tokens and layout.
   Palette is the existing Lydia brand only. Fonts are the static WOFF2 files
   already licensed for the public site (weight 400); hierarchy comes from size
   and italics, not synthesised weights. */

@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/dm-sans.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/dm-sans-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --ivory: #F6F2E9;
  --ink: #28241F;
  --vermilion: #AD341F;
  --peach: #EAC3AD;
  --ink-soft: #5C554C;

  /* Derived tints of brand colours only (no new hues). */
  --line: rgba(40, 36, 31, 0.18);
  --line-strong: rgba(40, 36, 31, 0.42);
  --surface: color-mix(in srgb, var(--ivory) 65%, white);
  --peach-soft: color-mix(in srgb, var(--peach) 38%, var(--ivory));

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --control: 44px;
  --radius: 4px;
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--vermilion); text-underline-offset: 0.15em; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 0.875em; overflow-wrap: anywhere; }
p { margin: 0 0 var(--s3); }

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

.visually-hidden {
  position: absolute !important; 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;
}
.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 10;
  padding: var(--s3) var(--s4); background: var(--ink); color: var(--ivory); border-radius: var(--radius);
}
.skip-link:focus { top: var(--s4); }

/* ---- type ------------------------------------------------------------ */
.wordmark { font-family: var(--font-display); font-size: 1.375rem; letter-spacing: 0.01em; margin: 0; }
.wordmark--small { font-size: 1.125rem; }
.wordmark__sub { font-style: italic; color: var(--ink-soft); }
.eyebrow { font-size: 0.8125rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--vermilion); margin: 0 0 var(--s3); }
.display { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.75rem, 9vw, 6rem); line-height: 0.98; letter-spacing: -0.015em; margin: 0 0 var(--s4); }
.lede { font-size: 1.125rem; max-width: 34em; color: var(--ink-soft); margin: 0; }
.panel-title { font-family: var(--font-display); font-weight: 400; font-size: 1.375rem; line-height: 1.2; margin: 0 0 var(--s3); }
.fineprint { font-size: 0.875rem; color: var(--ink-soft); margin: var(--s3) 0 0; }
.muted { color: var(--ink-soft); }
.status { min-height: 1.5em; margin: var(--s2) 0 0; font-size: 0.9375rem; color: var(--ink-soft); }
.status[data-tone="error"] { color: var(--vermilion); }
.status:empty { margin: 0; min-height: 0; }
.notice { padding: 0 var(--s4); }

/* ---- controls -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control); padding: 0 var(--s4);
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: transparent; color: var(--ink);
  font: inherit; line-height: 1.2; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--vermilion); border-color: var(--vermilion); color: var(--ivory); }
.btn--quiet { border-color: var(--line-strong); }
.btn--block { width: 100%; }
.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s3); }

label { display: block; font-size: 0.9375rem; color: var(--ink-soft); margin-bottom: var(--s1); }
input[type="email"], textarea {
  display: block; width: 100%; min-height: var(--control); padding: var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; line-height: 1.4;
}
textarea { resize: vertical; }
input[type="email"] { margin-bottom: var(--s3); }

.badge { display: inline-block; padding: 0.1em 0.55em; border-radius: 999px; font-size: 0.8125rem; border: 1px solid var(--line-strong); }
.badge--ok { background: var(--peach-soft); border-color: var(--peach); color: var(--ink); }
.badge--bad { background: var(--vermilion); border-color: var(--vermilion); color: var(--ivory); }

/* ---- sign-in page ---------------------------------------------------- */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr;
  gap: 0; padding: var(--s5) var(--s4) var(--s4);
}
.login__foot { align-self: end; }
.login__brand { padding-bottom: var(--s5); }
.login__editorial { border-top: 2px solid var(--vermilion); padding: var(--s6) 0 var(--s6); }
.login__panel { border-top: 1px solid var(--line); padding-top: var(--s5); max-width: 28rem; }
.login__foot { border-top: 1px solid var(--line); margin-top: var(--s6); padding-top: var(--s4); font-size: 0.9375rem; color: var(--ink-soft); }
.login__foot p { margin: 0; }

@media (min-width: 900px) {
  .login {
    grid-template-columns: minmax(0, 1.25fr) minmax(22rem, 1fr);
    grid-template-rows: auto 1fr auto;
    column-gap: clamp(var(--s6), 6vw, 6rem);
    padding: var(--s6) clamp(var(--s5), 6vw, 6rem) var(--s5);
  }
  .login__brand { grid-column: 1 / -1; }
  .login__editorial { grid-column: 1; grid-row: 2; }
  .login__panel { grid-column: 2; grid-row: 2; align-self: start; margin-top: var(--s6); border-top: 1px solid var(--line); }
  .login__foot { grid-column: 1 / -1; grid-row: 3; }
}

/* ---- studio ---------------------------------------------------------- */
.studio { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s1) var(--s3);
  padding: var(--s2) var(--s4); border-bottom: 1px solid var(--line);
}
.topbar .wordmark { grid-column: 1; grid-row: 1; margin: 0; }
.topbar #logout-btn { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.topbar .worker { grid-column: 1; grid-row: 2; }
.topbar__user { display: none; margin: 0; font-size: 0.875rem; color: var(--ink-soft); }
.worker { margin: 0; font-size: 0.8125rem; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 0.45em; min-width: 0; }
@media (min-width: 700px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: var(--s3) var(--s4); padding: var(--s3) var(--s4); }
  .topbar .wordmark { grid-row: 1; }
  .topbar .worker { grid-column: 2; grid-row: 1; justify-self: end; font-size: 0.875rem; }
  .topbar__user { display: block; grid-column: 3; grid-row: 1; }
  .topbar #logout-btn { grid-column: 4; grid-row: 1; }
}
.worker::before { content: ""; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--line-strong); flex: none; }
.worker[data-state="online"]::before { background: var(--ink); }
.worker[data-state="offline"]::before { background: var(--vermilion); }
.worker[data-state="offline"] { color: var(--ink); }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs__tab {
  flex: 1 1 0; min-height: var(--control); border: 0; border-bottom: 3px solid transparent;
  background: transparent; color: var(--ink-soft); font: inherit; cursor: pointer;
}
.tabs__tab[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--vermilion); }

.studio__grid { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.rail, .chat, .review { min-width: 0; padding: var(--s4); }

/* Mobile / tablet: chat-first, one section at a time. */
@media (max-width: 999px) {
  .studio__grid[data-panel="chat"] .rail, .studio__grid[data-panel="chat"] .review { display: none; }
  .studio__grid[data-panel="preview"] .rail, .studio__grid[data-panel="preview"] .chat { display: none; }
  .studio__grid[data-panel="history"] .chat, .studio__grid[data-panel="history"] .review { display: none; }
  .composer { position: sticky; bottom: 0; background: var(--ivory); padding-bottom: var(--s3); }
  /* Keep the latest message clear of the sticky composer when scrolled into view. */
  .msg { scroll-margin-bottom: 16rem; }
}
/* Desktop: history rail · conversation · review. */
@media (min-width: 1000px) {
  .tabs { display: none; }
  .studio { height: 100vh; height: 100dvh; }
  .studio__grid { grid-template-columns: 17rem minmax(0, 1fr) minmax(22rem, 32%); overflow: hidden; }
  .rail { border-right: 1px solid var(--line); overflow: auto; }
  .review { border-left: 1px solid var(--line); overflow: auto; }
  .chat { display: flex; flex-direction: column; overflow: hidden; }
  .messages { flex: 1; overflow: auto; }
}

/* rail */
.rail__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.threads, .release-list, .plain-list { list-style: none; margin: 0; padding: 0; }
.thread {
  display: block; width: 100%; min-height: var(--control); padding: var(--s3) var(--s2);
  text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.thread[aria-current="true"] { background: var(--peach-soft); }
.thread__title { display: block; }
.thread__time { display: block; font-size: 0.8125rem; color: var(--ink-soft); }
.releases { margin-top: var(--s6); }
.release { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.release:last-child { border-bottom: 0; } /* no empty trailing separator */
.release__summary { margin: 0 0 var(--s1); }
.release__meta { margin: 0 0 var(--s1); font-size: 0.8125rem; color: var(--ink-soft); }
.release__hash { margin: 0 0 var(--s2); font-size: 0.8125rem; }

/* hashes: short on one line, exact full value behind a native disclosure */
.hash { min-width: 0; }
.hash summary { cursor: pointer; min-height: 1.75rem; line-height: 1.75rem; }
.hash__short { white-space: nowrap; }
.hash__toggle { margin-left: var(--s2); font-size: 0.75rem; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 0.15em; }
.hash__full { display: block; margin: var(--s1) 0 0; font-size: 0.75rem; overflow-wrap: anywhere; word-break: break-all; }

/* chat */
.chat__title { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; line-height: 1.2; margin: 0 0 var(--s3); }
.messages { list-style: none; margin: 0; padding: 0; }
.messages__empty { padding: var(--s5) 0; color: var(--ink-soft); font-style: italic; }
.msg { padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.msg--assistant { border-left: 3px solid var(--peach); padding-left: var(--s4); }
.msg__meta { display: flex; gap: var(--s3); align-items: baseline; flex-wrap: wrap; margin: 0 0 var(--s2); font-size: 0.8125rem; color: var(--ink-soft); }
.msg__who { font-family: var(--font-display); font-style: italic; font-size: 1rem; color: var(--ink); }
.msg--user .msg__who { color: var(--vermilion); }
.msg__body p { margin: 0 0 var(--s2); }
.msg__body p:last-child { margin-bottom: 0; }
.msg__state { margin: var(--s2) 0 0; font-size: 0.875rem; font-style: italic; color: var(--ink-soft); }
.msg[data-status="failed"] .msg__state { color: var(--vermilion); font-style: normal; }
.msg__images { list-style: none; display: flex; gap: var(--s2); flex-wrap: wrap; padding: 0; margin: var(--s2) 0 0; }
.msg__images img { display: block; max-width: min(100%, 16rem); height: auto; border: 1px solid var(--line); background: var(--surface); }

.composer { border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s3); }
.composer__row { display: flex; gap: var(--s3); flex-wrap: wrap; justify-content: space-between; margin-top: var(--s3); }
.composer__row .btn { flex: 1 1 8rem; }
.file-btn { position: relative; margin: 0; color: var(--ink); }
.file-btn:has(:focus-visible) { outline: 3px solid var(--vermilion); outline-offset: 2px; }
.attachments { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: var(--s2); }
.attachments:empty { margin: 0; }
.attachment {
  display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  padding: var(--s2); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.attachment img { width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--radius); }
.attachment__name { overflow-wrap: anywhere; }
.attachment__state { display: block; font-size: 0.8125rem; color: var(--ink-soft); }
.attachment[data-status="failed"] .attachment__state { color: var(--vermilion); }

/* review */
.review .actions { flex-direction: column; align-items: stretch; } /* full-width, left-aligned decision controls */
.review .actions .btn { width: 100%; }
.review__summary { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.3; margin: 0 0 var(--s4); }
.review__meta { display: grid; grid-template-columns: minmax(6rem, auto) minmax(0, 1fr); gap: var(--s2) var(--s4); margin: 0 0 var(--s4); font-size: 0.9375rem; }
.review__meta dt { color: var(--ink-soft); }
.review__meta dd { margin: 0; min-width: 0; }
.checks { margin: var(--s2) 0 0; padding-left: 1.1em; font-size: 0.875rem; }
.checks--bad { color: var(--vermilion); }

/* dialogs */
dialog.confirm {
  border: 1px solid var(--ink); border-radius: var(--radius); background: var(--ivory); color: var(--ink);
  padding: var(--s5); width: min(34rem, calc(100vw - 2rem)); max-width: none;
}
dialog.confirm::backdrop { background: rgba(40, 36, 31, 0.55); }

/* about page */
.page { max-width: 44rem; margin: 0 auto; padding: var(--s6) var(--s4) var(--s7); }
.page h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2rem, 6vw, 3rem); line-height: 1.05; margin: var(--s4) 0 var(--s5); }
.page h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.375rem; margin: var(--s6) 0 var(--s3); }
.page ul { padding-left: 1.2em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
