/* The page around the conversation: sign-in, the lists on the left, the chat,
   the toolbar above a report. The report itself is styled in report.css,
   inside the locked frame. Colours and the typeface are in fonts.css. */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: lining-nums;
}

h1, h2, h3, h4, h5, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

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

button {
  cursor: pointer;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  padding: 0.4rem 0.9rem;
}
button:hover { background: var(--paper-soft); }
button:disabled { cursor: default; opacity: 0.55; }
button:focus-visible, textarea:focus-visible, .open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-strong); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger-text { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
button.big { font-size: 1.15rem; padding: 0.7rem 2.2rem; }

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

.signin {
  max-width: 34rem;
  margin: 0 auto;
  padding: 14vh 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  align-items: flex-start;
}
.signin .logo { width: 11rem; height: auto; margin-bottom: 0.4rem; }
.signin h1 { font-size: 2.2rem; font-weight: 700; color: var(--accent-strong); }
.signin .lead { font-size: 1.15rem; }
.signin p { color: var(--ink-soft); }
.signin .lead { color: var(--ink); }
.signin .notice { background: var(--accent-soft); color: var(--accent-strong); padding: 0.6rem 0.9rem; border-radius: 8px; }

/* --- shell -------------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 19rem minmax(0, 1fr); height: 100vh; height: 100dvh; }

.side {
  background: var(--paper-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 0.75rem 0.75rem;
  gap: 0.9rem;
}
.brand { display: flex; align-items: center; gap: 0.7rem; font-weight: 700; font-size: 1.15rem; color: var(--accent-strong); padding: 0 0.4rem; }
.brand img { width: 4.6rem; height: auto; flex: none; }
.side .new { width: 100%; text-align: left; font-weight: 600; background: var(--paper); }
.side .new:hover { background: #fff; border-color: var(--accent); }

.lists { flex: 1; min-height: 0; overflow-y: auto; padding-right: 0.15rem; }
.lists h2 { font-size: 0.8rem; font-weight: 600; color: var(--ink-faint); text-transform: none; padding: 0 0.4rem; margin: 0.9rem 0 0.3rem; }
.lists h2:first-child { margin-top: 0; }

.list li { display: flex; align-items: flex-start; border-radius: 8px; }
.list li:hover, .list li:focus-within { background: rgba(0, 0, 0, 0.045); }
.list li.selected { background: var(--accent-soft); }
.list .open {
  flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0.4rem 0.4rem;
  display: flex; flex-direction: column; gap: 0.05rem; border-radius: 8px;
}
.list .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { font-size: 0.78rem; color: var(--ink-faint); }
.list .meta.soon { color: var(--warning); font-weight: 600; }
.list .remove { border: 0; background: none; color: var(--ink-faint); padding: 0.3rem 0.5rem; font-size: 1.1rem; line-height: 1.2; visibility: hidden; }
.list li:hover .remove, .list li:focus-within .remove { visibility: visible; }
.list .remove:hover { color: var(--danger); }
.list .empty { color: var(--ink-faint); font-size: 0.88rem; padding: 0.2rem 0.4rem 0.4rem; display: block; }
.list .empty:hover { background: none; }

/* The month's limit: a bar that fills, above the account at the bottom of the side. */
.usage { padding: 0.7rem 0.4rem 0.2rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.35rem; }
.usage[hidden] { display: none; }
.usage-title { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; font-size: 0.88rem; font-weight: 600; }
.usage-title strong { font-variant-numeric: tabular-nums lining-nums; }
.usage-text { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.35; }
.usage progress { appearance: none; -webkit-appearance: none; width: 100%; height: 0.6rem; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
.usage progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.usage progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.usage progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.usage.near progress::-webkit-progress-value, .usage.over progress::-webkit-progress-value { background: var(--warning); }
.usage.near progress::-moz-progress-bar, .usage.over progress::-moz-progress-bar { background: var(--warning); }
.usage.near .usage-title strong, .usage.over .usage-title strong, .usage.near .usage-text, .usage.over .usage-text { color: var(--warning); }
.usage.near .usage-text, .usage.over .usage-text { font-weight: 600; }
.retention { font-size: 0.8rem; color: var(--ink-soft); padding: 0.7rem 0.4rem 0; margin-top: 0.9rem; border-top: 1px solid var(--line); }

/* Who is signed in, and the way out: the e-mail on a line of its own (a long
   one wraps), the button under it. */
.account { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; font-size: 0.88rem; padding: 0.7rem 0.4rem 0; border-top: 1px solid var(--line); }
.account .email { max-width: 100%; overflow-wrap: anywhere; color: var(--ink-soft); line-height: 1.3; }
.account button { background: var(--paper); padding: 0.3rem 1.1rem; font-weight: 600; }
.account button:hover { background: #fff; border-color: var(--accent); }

.menu { display: none; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat, .report { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* --- conversation ----------------------------------------------------------------- */

.messages, .welcome, .composer { width: 100%; max-width: 50rem; margin: 0 auto; padding-left: 1.5rem; padding-right: 1.5rem; }
.messages { padding-top: 1.5rem; padding-bottom: 1rem; display: flex; flex-direction: column; gap: 1.4rem; }

.welcome { padding-top: 16vh; display: flex; flex-direction: column; gap: 0.8rem; }
.welcome h1 { font-size: 1.9rem; font-weight: 700; }
.welcome p { color: var(--ink-soft); }
.examples { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; align-items: flex-start; }
.examples button { text-align: left; border-color: var(--line); color: var(--accent-strong); }
.examples button:hover { border-color: var(--accent); background: var(--accent-soft); }

.message .who { font-size: 0.8rem; font-weight: 600; color: var(--ink-faint); margin-bottom: 0.15rem; }
.message.user { align-self: flex-end; max-width: 85%; }
.message.user .who { text-align: right; }
.message.user .body { background: var(--accent-soft); border-radius: 14px 14px 4px 14px; padding: 0.55rem 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.message.assistant .body { display: flex; flex-direction: column; gap: 0.7rem; }
.message.assistant p { white-space: pre-line; overflow-wrap: anywhere; }
.message.assistant h3, .message.assistant h4, .message.assistant h5 { font-size: 1.05rem; font-weight: 700; margin-top: 0.3rem; }
.message.assistant ul, .message.assistant ol { padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.2rem; }
.message.assistant ul { list-style: disc; }
.message.assistant ol { list-style: decimal; }
.message.assistant code { font-family: Consolas, "Courier New", monospace; font-size: 0.9em; background: var(--paper-soft); padding: 0.05em 0.3em; border-radius: 4px; }
.message.assistant pre { background: var(--paper-soft); padding: 0.7rem 0.9rem; border-radius: 8px; overflow-x: auto; }
.message.assistant pre code { background: none; padding: 0; }

.table-wrap { overflow-x: auto; }
.message table { border-collapse: collapse; font-variant-numeric: tabular-nums lining-nums; }
.message th, .message td { padding: 0.3rem 0.9rem 0.3rem 0; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.message th { font-weight: 600; border-bottom-color: var(--line-strong); }
.message th:last-child, .message td:last-child { padding-right: 0; }
.message .num { text-align: right; white-space: nowrap; }

.status { color: var(--ink-soft); display: flex; align-items: center; gap: 0.5rem; }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 0.5rem 0.8rem; }

.report-card {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  border: 1px solid var(--line-strong); border-left: 4px solid var(--accent); border-radius: 8px; padding: 0.7rem 0.9rem;
}
.report-card .about { display: flex; flex-direction: column; min-width: 0; }
.report-card .title { font-weight: 600; }
.report-card .meta { font-size: 0.85rem; color: var(--ink-soft); }
.report-card button { white-space: nowrap; }
.report-card.gone { border-left-color: var(--line-strong); color: var(--ink-faint); }

.composer { padding-top: 0.6rem; padding-bottom: 0.9rem; }
.composer .field {
  display: flex; align-items: flex-end; gap: 0.6rem;
  border: 1px solid var(--line-strong); border-radius: 14px; padding: 0.5rem 0.5rem 0.5rem 0.9rem; background: var(--paper);
}
.composer .field:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; resize: none; background: none; padding: 0.3rem 0; line-height: 1.45; min-height: 2rem; }
.composer textarea:focus-visible { outline: none; }
.composer .hint { font-size: 0.78rem; color: var(--ink-faint); padding: 0.3rem 0.9rem 0; }

/* --- report view -------------------------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 0.7rem 1.5rem; border-bottom: 1px solid var(--line); }
.toolbar .back { margin-right: auto; text-decoration: none; font-weight: 600; }
.toolbar .meta { font-size: 0.85rem; color: var(--ink-soft); margin-right: 0.4rem; }
.report .scroll { background: var(--paper-soft); padding: 1.2rem; }
.report-frame { display: block; width: 100%; max-width: 56rem; margin: 0 auto; min-height: 60vh; border: 1px solid var(--line); border-radius: 4px; background: #fff; }

/* --- dialogs ---------------------------------------------------------------------------- */

.dialog { border: 0; border-radius: 12px; padding: 1.4rem 1.5rem 1.2rem; max-width: 30rem; width: calc(100% - 2rem); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.dialog::backdrop { background: rgba(20, 30, 28, 0.45); }
.dialog h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.7rem; }
.dialog p { margin-bottom: 0.6rem; overflow-wrap: anywhere; }
.dialog .reason { border-left: 4px solid var(--accent); padding: 0.3rem 0 0.3rem 0.8rem; font-weight: 600; }
.dialog .note { font-size: 0.88rem; color: var(--ink-soft); }
.dialog .buttons { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

/* --- narrow screens ----------------------------------------------------------------------- */

@media (max-width: 52rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(20rem, 88vw); z-index: 5; transform: translateX(-100%); transition: transform 0.15s ease; box-shadow: 0 0 30px rgba(0, 0, 0, 0.2); }
  .side-open .side { transform: none; }
  .menu { display: block; position: fixed; top: 0.5rem; left: 0.5rem; z-index: 6; padding: 0.25rem 0.6rem; }
  .messages, .welcome { padding-top: 3.2rem; }
  .toolbar { padding-left: 3.4rem; }
  .list .remove { visibility: visible; }
}
