/* Built for a reader who is not looking for a chat app: large type, quiet
   colour, nothing that blinks. Everything scales from one font size. */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #1c1b19;
  --ink-soft: #5c5852;
  --line: #e3dfd8;
  --accent: #6b4f2a;
  --accent-soft: #f3ede3;
  --danger: #9a2f21;
  --radius: 10px;
  --measure: 42rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --surface: #232120;
    --ink: #eeeae4;
    --ink-soft: #a8a29a;
    --line: #38353160;
    --accent: #c9a678;
    --accent-soft: #2b2825;
    --danger: #e08272;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Both screens set their own `display`, which outranks the browser's built-in
   rule for the `hidden` attribute. Without this the script hides a screen and
   nothing happens on the page. Keep it above the layout rules. */
[hidden] { display: none !important; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* --- sign in ------------------------------------------------------------ */

.centered {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.card {
  width: min(23rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
}

.card h1 {
  margin: 0 0 .25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card .sub {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  font-size: .95rem;
}

label {
  display: block;
  margin-bottom: .35rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
}

input[type="text"], input[type="password"] {
  width: 100%;
  margin-bottom: 1.1rem;
  padding: .7rem .8rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
}

input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font-family: system-ui, sans-serif;
  cursor: pointer;
}

.card button[type="submit"] {
  width: 100%;
  padding: .75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 7px;
}

.card button[disabled] { opacity: .55; cursor: default; }

.error {
  margin: 1rem 0 0;
  padding: .6rem .75rem;
  font-size: .9rem;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-radius: 6px;
}

/* --- chat --------------------------------------------------------------- */

#chat-view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

header .title { font-weight: 600; }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: system-ui, sans-serif;
  font-size: .8rem;
}

.linkish {
  padding: 0;
  font-size: .8rem;
  color: var(--ink-soft);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.linkish:hover { color: var(--ink); }

#transcript {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem 1.25rem 1rem;
  scroll-behavior: smooth;
}

.message {
  max-width: var(--measure);
  margin: 0 auto 1.75rem;
}

.message.user .body {
  padding: .7rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  border-bottom-right-radius: 3px;
  margin-left: 3rem;
}

.message .body > :first-child { margin-top: 0; }
.message .body > :last-child { margin-bottom: 0; }
.message p { margin: 0 0 .85rem; }
.message ul, .message ol { margin: 0 0 .85rem; padding-left: 1.3rem; }
.message li { margin-bottom: .3rem; }
.message strong { font-weight: 600; }

.message code {
  padding: .1em .35em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--accent-soft);
  border-radius: 4px;
}

.message.error .body {
  padding: .7rem 1rem;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-radius: var(--radius);
}

/* Reading indicator */
.status {
  max-width: var(--measure);
  margin: 0 auto 1.75rem;
  font-family: system-ui, sans-serif;
  font-size: .85rem;
  color: var(--ink-soft);
}

.status .dot {
  display: inline-block;
  width: .4rem; height: .4rem;
  margin-right: .5rem;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .status .dot { animation: none; opacity: .7; }
  #transcript { scroll-behavior: auto; }
}

footer {
  flex: none;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

#chat-form {
  display: flex;
  gap: .6rem;
  align-items: flex-end;
  max-width: var(--measure);
  margin: 0 auto;
}

#input {
  flex: 1;
  max-height: 11rem;
  padding: .7rem .85rem;
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  resize: none;
  overflow-y: auto;
}

#send-btn {
  flex: none;
  padding: .7rem 1.2rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 9px;
}

#send-btn[disabled] { opacity: .5; cursor: default; }

@media (max-width: 34rem) {
  html { font-size: 16px; }
  #transcript { padding: 1.25rem 1rem .5rem; }
  .message.user .body { margin-left: 1rem; }
  .header-right { gap: .75rem; }
}
