:root {
  --ink: #191817;
  --ink-soft: #514e49;
  --paper: #f4efe7;
  --paper-deep: #e8e0d4;
  --surface: #fffdf9;
  --signal: #d65035;
  --signal-dark: #a63824;
  --signal-pale: #f6d6ca;
  --lime: #d7e76c;
  --line: #1f1e1b;
  --line-soft: #d5ccbf;
  --focus: #2563eb;
  --danger: #922f1e;
  --shadow: 8px 8px 0 rgba(25, 24, 23, .12);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  min-width: 320px;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background: radial-gradient(circle at 96% 6%, rgba(214, 80, 53, .17), transparent 22rem), linear-gradient(135deg, rgba(255,255,255,.48), transparent 38%), var(--paper);
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
a { color: inherit; text-underline-offset: .18em; }

.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; color: var(--surface); background: var(--ink); border: 1px solid var(--ink); transform: translateY(-170%); }
.skip-link:focus { transform: translateY(0); }
.app-shell { width: min(100%, 1120px); min-height: 100dvh; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom)); }

h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.055em; }
h1, h2 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; }
h1 { font-size: clamp(3.1rem, 10vw, 5.55rem); line-height: .86; }
h2 { font-size: clamp(2rem, 7vw, 3.15rem); line-height: .94; }
h3 { font-size: 1.13rem; line-height: 1.1; }
h4, .eyebrow, .section-kicker { margin-bottom: 8px; font-family: "Space Mono", ui-monospace, monospace; font-size: .67rem; font-weight: 700; letter-spacing: .075em; line-height: 1.35; text-transform: uppercase; }
.eyebrow, .section-kicker { color: var(--signal-dark); }
.muted { color: var(--ink-soft); }

/* Shared form language */
label, legend { display: block; font-size: .83rem; font-weight: 800; letter-spacing: -.015em; }
input, select, textarea { width: 100%; min-height: 52px; padding: 12px 13px; color: var(--ink); border: 1.5px solid var(--line); border-radius: 0; background: var(--surface); box-shadow: 3px 3px 0 transparent; transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
input:hover, select:hover, textarea:hover { border-color: var(--signal); }
textarea { min-height: 118px; resize: vertical; }
input[type="file"] { padding: 9px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.field { display: grid; gap: 8px; margin: 0; }
fieldset.field { min-width: 0; padding: 0; border: 0; }
.field .helptext { color: var(--ink-soft); font-size: .76rem; }
.errorlist { margin: 0; padding: 10px 12px 10px 28px; color: var(--danger); border-left: 3px solid var(--signal); background: #fff0eb; font-size: .82rem; }

.primary-action, .copy-button, .quiet-button { min-height: 48px; padding: 11px 16px; border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 800; letter-spacing: -.02em; transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, color 160ms ease; }
.primary-action { color: var(--surface); background: var(--signal); box-shadow: 4px 4px 0 var(--ink); }
.primary-action:hover { color: var(--surface); background: var(--signal-dark); transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.primary-action:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.primary-action:disabled { cursor: wait; opacity: .72; }
.copy-button, .quiet-button { color: var(--ink); background: transparent; }
.copy-button:hover, .quiet-button:hover { background: var(--lime); }
.copy-button[data-copied="true"] { color: #173e29; background: var(--lime); }

/* Login and registration */
.auth-page .app-shell { display: grid; align-items: center; max-width: 1240px; }
.auth-layout { display: grid; overflow: hidden; border: 1.5px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.auth-manifest { position: relative; display: grid; align-content: space-between; min-height: 590px; padding: 24px; overflow: hidden; color: var(--surface); background: var(--ink); }
.auth-manifest::after { position: absolute; right: -76px; bottom: -98px; width: 250px; height: 250px; border: 1px solid rgba(255,255,255,.62); border-radius: 50%; content: ""; }
.brand { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px; font-size: .8rem; font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { display: grid; width: 30px; aspect-ratio: 1; place-items: center; color: var(--ink); background: var(--lime); border-radius: 50%; }
.brand-mark svg { width: 17px; height: 17px; }
.manifest-copy { position: relative; z-index: 1; max-width: 12ch; margin: 42px 0 18px; color: var(--surface); font-size: clamp(3.1rem, 15vw, 5.4rem); }
.manifest-detail { position: relative; z-index: 1; max-width: 33ch; margin-bottom: 0; color: rgba(255,255,255,.72); font-size: .83rem; }
.manifest-badge { position: absolute; z-index: 1; right: 22px; top: 92px; display: grid; width: 74px; height: 74px; place-items: center; color: var(--ink); background: var(--signal); border: 1.5px solid var(--surface); border-radius: 50%; font-family: "Space Mono", monospace; font-size: .64rem; font-weight: 700; line-height: 1.25; text-align: center; transform: rotate(11deg); }
.auth-panel { display: grid; align-content: center; gap: 22px; padding: 28px 22px 30px; }
.auth-panel h1 { max-width: 11ch; margin-bottom: 0; }
.auth-intro { max-width: 42ch; margin-bottom: 0; color: var(--ink-soft); font-size: .92rem; }
.auth-form { display: grid; gap: 14px; }
.auth-form p { display: grid; gap: 8px; margin: 0; }
.auth-form .primary-action { width: max-content; min-width: 190px; margin-top: 4px; }
.auth-note { margin: 0; padding-top: 16px; border-top: 1px solid var(--line-soft); color: var(--ink-soft); font-size: .75rem; }

/* Working space */
.workspace { display: grid; gap: 26px; }
.workspace-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0 13px; border-bottom: 1px solid var(--line); }
.workspace-topbar .brand { font-size: .74rem; }
.workspace-state { display: flex; align-items: center; gap: 7px; font-family: "Space Mono", monospace; font-size: .63rem; font-weight: 700; text-transform: uppercase; }
.workspace-state::before { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(215,231,108,.35); content: ""; }
.hero { display: grid; gap: 14px; padding: 8px 0 0; }
.hero h1 { max-width: 12ch; margin-bottom: 0; }
.hero .muted { max-width: 49ch; margin-bottom: 0; font-size: .95rem; }

.composer { display: grid; gap: 20px; padding: 20px; border: 1.5px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.composer-heading { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.composer-index { display: grid; width: 30px; height: 30px; place-items: center; color: var(--surface); background: var(--ink); border-radius: 50%; font-family: "Space Mono", monospace; font-size: .68rem; font-weight: 700; }
.composer-heading h2 { margin: 0; font-size: 2.4rem; }
.composer-heading p { grid-column: 2; margin: -3px 0 0; color: var(--ink-soft); font-size: .79rem; }
.composer-grid { display: grid; gap: 16px; }
.placeholder-options { display: grid; gap: 8px; }
.placeholder-options > div { display: grid; gap: 8px; }
.placeholder-options label { position: relative; display: flex; align-items: center; min-height: 50px; padding: 11px 14px 11px 42px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; }
.placeholder-options label:hover { background: var(--signal-pale); }
.placeholder-options input { position: absolute; left: 14px; width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--signal); }
.composer-actions { display: grid; gap: 12px; }
.composer-actions .primary-action { width: 100%; }
.loading-indicator { margin: 0; color: var(--ink-soft); font-size: .8rem; font-weight: 700; }
.htmx-indicator { display: none; }
.htmx-request.htmx-indicator { display: block; }
.voice-composer { gap: 12px; padding: 16px 20px; border-color: var(--line-soft); box-shadow: none; }
.voice-composer label { font-family: "Space Mono", monospace; font-size: .67rem; text-transform: uppercase; }
.voice-composer .copy-button { justify-self: start; }

/* Conversation */
.conversation-thread { display: grid; gap: 18px; margin-top: 10px; }
.conversation-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.conversation-toolbar h2 { margin: 0; font-size: 2.6rem; }
.conversation-toolbar form { flex: 0 0 auto; }
.conversation-toolbar .copy-button { min-height: 40px; padding: 8px 13px; font-size: .75rem; }
.message-bubble, .advice-card, .empty-conversation, .archive-item { border: 1.5px solid var(--line); background: var(--surface); }
.message-bubble { padding: 18px; background: var(--signal-pale); box-shadow: 5px 5px 0 rgba(25,24,23,.12); }
.message-bubble p:last-child { margin-bottom: 0; font-size: 1.03rem; }
.advice-card { padding: 20px; box-shadow: var(--shadow); }
.advice-card > .muted { margin-bottom: 20px; font-size: .87rem; }
.advice-card h3 { max-width: 25ch; margin-bottom: 10px; font-family: "Cormorant Garamond", Georgia, serif; font-size: 2.1rem; font-weight: 600; }
.communication-card { margin: 18px 0; padding: 15px; color: var(--ink); border: 1.5px solid var(--line); background: var(--lime); }
.communication-card h4 { margin-bottom: 9px; }
.communication-card ul { display: grid; gap: 8px; margin: 0; padding-left: 18px; font-size: .85rem; }
.avoid { margin: 18px 0; padding: 12px 14px; color: var(--danger); border-left: 4px solid var(--signal); background: #fff0eb; font-size: .86rem; }
.response-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 4px; }
.response-actions form { margin: 0; }
.response-actions .copy-button { min-height: 40px; padding: 8px 12px; font-size: .75rem; }
.variants { display: grid; gap: 0; margin-top: 20px; border-top: 1.5px solid var(--line); }
.variant { display: grid; gap: 10px; padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.variant:last-child { padding-bottom: 0; border-bottom: 0; }
.variant h4 { margin: 0; color: var(--signal-dark); }
.variant p { margin: 0; font-size: .97rem; line-height: 1.58; }
.variant .copy-button { justify-self: start; min-height: 40px; padding: 8px 13px; font-size: .77rem; }
.empty-conversation { position: relative; min-height: 220px; padding: 24px; overflow: hidden; background: var(--ink); color: var(--surface); box-shadow: var(--shadow); }
.empty-conversation::after { position: absolute; right: -34px; bottom: -70px; width: 190px; height: 190px; border: 1px solid var(--lime); border-radius: 50%; content: ""; }
.empty-conversation h2 { position: relative; z-index: 1; max-width: 9ch; margin: 0 0 12px; }
.empty-conversation .muted { position: relative; z-index: 1; max-width: 31ch; margin: 0; color: rgba(255,255,255,.7); font-size: .84rem; }
.archive-item { margin: 14px 0; padding: 16px; }

@media (min-width: 680px) {
  .app-shell { padding: 34px 32px 52px; }
  .workspace { gap: 34px; }
  .composer { padding: 28px; }
  .composer-grid { grid-template-columns: 1fr 1fr; }
  .composer-grid .field--wide, .composer-grid fieldset { grid-column: 1 / -1; }
  .placeholder-options, .placeholder-options > div { grid-template-columns: repeat(3, 1fr); }
  .placeholder-options label { min-height: 88px; align-items: start; }
  .composer-actions { grid-template-columns: minmax(240px, 1fr) auto; align-items: center; }
  .composer-actions .primary-action { width: max-content; }
  .voice-composer { grid-template-columns: 1fr auto; align-items: end; }
  .voice-composer label { grid-column: 1 / -1; }
  .conversation-thread { gap: 22px; }
  .advice-card { padding: 28px; }
  .variant { grid-template-columns: 110px minmax(0, 1fr) auto; align-items: start; gap: 18px; }
  .variant .copy-button { justify-self: end; }
}
@media (min-width: 820px) {
  .auth-layout { grid-template-columns: minmax(360px, .9fr) minmax(460px, 1.1fr); }
  .auth-manifest { min-height: 630px; padding: 36px; }
  .auth-panel { padding: 56px; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(330px, .72fr); align-items: start; }
  .workspace-topbar, .hero { grid-column: 1 / -1; }
  .composer { grid-column: 1; }
  .voice-composer { grid-column: 2; grid-row: 3; }
  #conversation-panel { grid-column: 2; grid-row: 2; }
  .empty-conversation { min-height: 360px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
