:root {
  --paper: #f2f5f3;
  --surface: #ffffff;
  --ink: #14241f;
  --muted: #56675f;
  --line: #cfd9d3;
  --code: #e6ece8;
  --pine: #123c33;
  --pine-raised: #1b4d42;
  --on-pine: #eaf2ee;
  --on-pine-muted: #a9c2b8;
  --marker: #ffd45c;
  --on-marker: #14241f;
  --danger: #a32a1f;
  --sans: 'Schibsted Grotesk Variable', 'Segoe UI', system-ui, sans-serif;
  --serif: 'Literata Variable', Georgia, serif;
  --mono: 'Cascadia Code', Consolas, 'SF Mono', Menlo, monospace;
  --reading: 44rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10211c;
    --surface: #18302a;
    --ink: #e8efeb;
    --muted: #9db0a7;
    --line: #2d4a42;
    --code: #0b1a16;
    --pine: #0b1a16;
    --pine-raised: #18302a;
    --danger: #ff9d8f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--marker); outline-offset: 2px; box-shadow: 0 0 0 4px var(--ink); border-radius: 4px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.primary {
  background: var(--marker);
  color: var(--on-marker);
  border: 0;
  border-radius: 8px;
  padding: .6rem 1rem;
  font-weight: 600;
}
.primary:hover { background: #ffc933; }
.secondary {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .45rem .85rem;
}
.secondary:hover { border-color: var(--muted); }
.form-error { color: var(--danger); margin: 0; font-size: .9375rem; }

/* Sign in */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
  background: var(--pine);
}
.login-form {
  width: min(100%, 24rem);
  display: grid;
  gap: 1.1rem;
  color: var(--on-pine);
}
.login-form h1 {
  margin: 0 0 .75rem;
  font-size: clamp(2.25rem, 8vw, 3.25rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.login-form label { display: grid; gap: .35rem; font-weight: 500; }
.login-form input {
  background: var(--on-pine);
  color: #14241f;
  border: 0;
  border-radius: 8px;
  padding: .7rem .8rem;
}
.login-form .form-error { color: var(--marker); }
.login-form .primary { padding: .75rem 1rem; margin-top: .25rem; }

/* Layout */
.app { height: 100dvh; display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); }

.sidebar {
  background: var(--pine);
  color: var(--on-pine);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.1rem .75rem .75rem;
}
.brand { margin: 0 .5rem 1rem; font-size: 1.125rem; font-weight: 700; letter-spacing: -.01em; }
.new-chat { width: 100%; }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; margin: 1rem -.25rem 0; padding: 0 .25rem; }
.conversation-list .empty { color: var(--on-pine-muted); font-size: .9375rem; margin: .25rem .5rem; }
.conversation { position: relative; display: flex; border-radius: 8px; }
.conversation:hover, .conversation:focus-within { background: var(--pine-raised); }
.conversation.is-current { background: var(--pine-raised); box-shadow: inset 3px 0 0 var(--marker); }
.conversation-title {
  flex: 1; min-width: 0;
  background: none; border: 0; color: inherit; text-align: left;
  padding: .5rem .25rem .5rem .6rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: .9375rem;
}
.conversation-delete {
  flex: none; width: 2.1rem;
  background: none; border: 0; color: var(--on-pine-muted);
  display: grid; place-items: center;
  opacity: 0;
}
.conversation:hover .conversation-delete, .conversation-delete:focus-visible, .conversation.is-current .conversation-delete { opacity: 1; }
.conversation-delete:hover { color: var(--marker); }
@media (hover: none) { .conversation-delete { opacity: 1; } }
.conversation-delete svg, .icon-button svg, .send svg, .copy-answer svg {
  width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.account { border-top: 1px solid var(--pine-raised); margin-top: .75rem; padding: .7rem .5rem 0; }
.account-name { margin: 0 0 .25rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { display: flex; flex-wrap: wrap; gap: .1rem .9rem; }
.account-actions button {
  background: none; border: 0; padding: .15rem 0;
  color: var(--on-pine-muted); font-size: .875rem;
}
.account-actions button:hover { color: var(--on-pine); text-decoration: underline; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; flex: none; }
.icon-button { background: none; border: 0; padding: .4rem; display: grid; place-items: center; border-radius: 8px; }
.menu-button { display: none; }
.model-picker select {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .35rem .4rem;
  font-weight: 600;
  max-width: 100%;
  cursor: pointer;
}
.model-picker select:hover { border-color: var(--line); }
.model-picker option { background: var(--surface); color: var(--ink); font-weight: 400; }

/* Conversation: the person's words are marked like a highlighted passage; answers read like a document. */
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1rem 2rem; scrollbar-gutter: stable; }
.chat.is-empty .thread { display: none; }
.turn { max-width: var(--reading); margin: 0 auto 2.75rem; }
.question {
  margin: 0 0 1.1rem;
  font-size: 1.125rem;
  line-height: 1.75;
  font-weight: 550;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 18rem;
  overflow-y: auto;
}
.question mark {
  background: var(--marker);
  color: var(--on-marker);
  padding: .14em .4em;
  border-radius: 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.answer { font: 400 1.0625rem/1.72 var(--serif); overflow-wrap: anywhere; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p, .answer ul, .answer ol, .answer blockquote, .answer table { margin: 0 0 1em; }
.answer li { margin-bottom: .3em; }
.answer h1, .answer h2, .answer h3, .answer h4 { font-family: var(--sans); line-height: 1.25; font-weight: 700; margin: 1.6em 0 .5em; letter-spacing: -.01em; }
.answer h1 { font-size: 1.5rem; }
.answer h2 { font-size: 1.3rem; }
.answer h3 { font-size: 1.125rem; }
.answer h4 { font-size: 1rem; }
.answer a { color: inherit; text-decoration-color: var(--muted); text-underline-offset: 2px; }
.answer blockquote { border-left: 3px solid var(--line); padding-left: 1em; color: var(--muted); }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 1.75em 0; }
.answer table { display: block; overflow-x: auto; border-collapse: collapse; font: 400 .9375rem/1.5 var(--sans); }
.answer th, .answer td { border-bottom: 1px solid var(--line); padding: .45em .9em .45em 0; text-align: left; vertical-align: top; }
.answer th { font-weight: 650; border-bottom-color: var(--muted); }
.answer code { font: .875em/1.5 var(--mono); background: var(--code); padding: .1em .3em; border-radius: 4px; }
.code-block { position: relative; margin: 0 0 1em; }
.code-block pre { margin: 0; background: var(--code); border-radius: 8px; padding: 2.5rem 1rem 1rem; overflow-x: auto; }
.code-block code { background: none; padding: 0; font-size: .875rem; overflow-wrap: normal; }
.copy-code {
  position: absolute; top: .4rem; right: .4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: .1rem .5rem; font: 500 .8125rem/1.5 var(--sans);
}
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-literal { color: #7b2e8e; }
.hljs-string, .hljs-attr, .hljs-addition { color: #1f6b3a; }
.hljs-number, .hljs-title, .hljs-type { color: #0b5a8a; }
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
.hljs-deletion { color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-literal { color: #dba6ea; }
  .hljs-string, .hljs-attr, .hljs-addition { color: #9bdcae; }
  .hljs-number, .hljs-title, .hljs-type { color: #8fcdf2; }
}

.answer-meta { display: flex; align-items: center; gap: .75rem; margin-top: .6rem; font-size: .8125rem; color: var(--muted); min-height: 1.75rem; }
.copy-answer { background: none; border: 0; color: inherit; padding: .2rem .25rem; display: inline-flex; gap: .3rem; align-items: center; border-radius: 6px; }
.copy-answer:hover { color: var(--ink); }
.copy-answer svg { width: 1rem; height: 1rem; }
.turn-note { color: var(--danger); font: 400 .9375rem/1.5 var(--sans); margin: .75rem 0 0; }

.thinking { display: inline-block; width: 2.25rem; height: .8rem; border-radius: 3px; background: var(--marker); animation: thinking 1.1s ease-in-out infinite alternate; transform-origin: left; }
@keyframes thinking { from { transform: scaleX(.25); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .thinking { animation: none; }
  .sidebar { transition: none !important; }
}

/* Composer */
.dock { flex: none; width: 100%; max-width: calc(var(--reading) + 2rem); margin: 0 auto; padding: 0 1rem .6rem; }
.greeting { display: none; }
.chat.is-empty { justify-content: flex-start; }
.chat.is-empty .dock { margin-block: auto; padding-bottom: 12vh; }
.chat.is-empty .greeting {
  display: block;
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.chat-error { color: var(--danger); margin: 0 0 .5rem; font-size: .9375rem; }
.composer {
  display: flex; align-items: flex-end; gap: .5rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: .5rem .5rem .5rem .9rem;
}
.composer:focus-within { border-color: var(--ink); }
.composer textarea {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: 0; box-shadow: none; resize: none;
  padding: .35rem 0;
  max-height: 40vh;
  line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }
.send {
  flex: none; width: 2.35rem; height: 2.35rem;
  display: grid; place-items: center;
  background: var(--marker); color: var(--on-marker);
  border: 0; border-radius: 9px;
}
.send:hover { background: #ffc933; }
.stop { background: var(--ink); color: var(--paper); }
.stop:hover { background: var(--muted); }
.stop svg { fill: currentColor; stroke: none; }
.disclaimer { margin: .4rem 0 0; font-size: .8125rem; color: var(--muted); text-align: center; }

/* Dialogs */
.dialog {
  background: var(--paper); color: var(--ink);
  border: 0; border-radius: 14px;
  padding: 1.5rem;
  width: min(calc(100vw - 2rem), 28rem);
  box-shadow: 0 24px 60px rgb(0 20 14 / .35);
}
.dialog-wide { width: min(calc(100vw - 2rem), 44rem); }
.dialog::backdrop { background: rgb(5 20 16 / .55); }
.dialog h2 { margin: 0; font-size: 1.375rem; letter-spacing: -.01em; }
.dialog h3 { margin: 0 0 .75rem; font-size: 1.0625rem; }
.dialog form { display: grid; gap: .9rem; }
.dialog label { display: grid; gap: .3rem; font-weight: 500; font-size: .9375rem; }
.dialog input:not([type='checkbox']) {
  width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .25rem; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.month-total { color: var(--muted); margin: .25rem 0 1rem; }
.new-password { background: var(--marker); color: var(--on-marker); padding: .6rem .8rem; border-radius: 8px; margin: 0 0 1rem; overflow-wrap: anywhere; }
.new-password code { font: 600 .9375rem var(--mono); }
.table-scroll { overflow-x: auto; }
.dialog table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.dialog th { text-align: left; font-weight: 600; color: var(--muted); padding: .35rem .75rem .35rem 0; }
.dialog td { border-top: 1px solid var(--line); padding: .55rem .75rem .55rem 0; vertical-align: middle; }
.dialog .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.user-name { font-weight: 600; }
.user-email { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.user-inactive .user-name, .user-inactive .user-email { text-decoration: line-through; }
.user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.user-actions button { font-size: .8125rem; padding: .25rem .55rem; white-space: nowrap; }
.user-form { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); gap: .75rem !important; justify-items: start; }
.user-form h3 { margin: 0; }
.user-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; width: 100%; }
.dialog label.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; }

@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20;
    width: min(85vw, 19rem);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .2s ease, visibility .2s;
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: 0; z-index: 10; background: rgb(5 20 16 / .55); }
  .menu-button { display: grid; }
  .topbar { padding: .4rem .5rem; }
  .composer textarea { font-size: 1rem; }
  .chat.is-empty .dock { padding-bottom: 6vh; }
  .user-fields { grid-template-columns: 1fr; }
}
