@import url("https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;450;500;600&display=swap");

:root {
  --ground:      #F4F6F8;
  --surface:     #FFFFFF;
  --surface-alt: #EDF0F4;
  --ink:         #16233A;
  --ink-soft:    #3D4A5F;
  --muted:       #6A7484;
  --line:        #DCE1E8;
  --line-strong: #C3CBD6;
  --accent:      #9A6B34;
  --accent-bg:   #F3E8D9;
  --ok:          #2F6B4F;
  --ok-bg:       #DFEDE5;
  --warn:        #8A6414;
  --warn-bg:     #F5E9CE;
  --bot:         #EAF0F6;
  --client:      #DCF0D8;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0;
}

.mono, .eyebrow, .chip, .num {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.eyebrow {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

button, input, textarea, select { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-weight: 500;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.85; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

input[type="text"], input[type="email"], textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 0;
}

a { color: var(--accent); }

/* ------------------------------------------------------------------ login */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.login-card {
  width: 100%;
  max-width: 27rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.5rem;
}
.login-card h1 { font-size: 1.9rem; margin: 0.8rem 0 0.4rem; }
.login-card .lede { color: var(--muted); margin: 0 0 1.75rem; font-size: 0.95rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.field label { font-size: 0.85rem; font-weight: 500; }

.notice {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}
.notice.dev { background: var(--warn-bg); border-color: #E2CE9B; }
.notice a { font-family: "IBM Plex Mono", monospace; font-size: 0.82rem; word-break: break-all; }

/* -------------------------------------------------------------- app shell */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--ink);
  color: #fff;
  flex-wrap: wrap;
}
.topbar .brand { font-family: "Newsreader", serif; font-size: 1.15rem; }
.topbar .spacer { flex: 1; }
.topbar select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
}
.topbar select option { color: var(--ink); }
.topbar .who { font-size: 0.85rem; opacity: 0.75; }
.topbar button { border-color: rgba(255,255,255,0.3); background: transparent; }

.layout {
  display: grid;
  grid-template-columns: 20rem 1fr;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem 3rem;
  align-items: start;
}
@media (max-width: 60rem) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card > header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.card > header h2 { font-size: 1.05rem; }
.card .body { padding: 1.1rem; }

.stack { display: flex; flex-direction: column; gap: 1.25rem; }

.kv { display: flex; flex-direction: column; gap: 0.65rem; }
.kv div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; }
.kv dt, .kv .k { color: var(--muted); }
.kv .v { font-weight: 500; text-align: right; }
.kv .v.num { font-family: "IBM Plex Mono", monospace; }

.chip {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  background: var(--surface-alt);
  color: var(--muted);
}
.chip.ok   { background: var(--ok-bg);   color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------------ conversations */

.convo-list { list-style: none; margin: 0; padding: 0; }
.convo-list li {
  border-bottom: 1px solid var(--line);
}
.convo-list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  padding: 0.85rem 1.1rem;
  display: block;
  border-left: 3px solid transparent;
  border-radius: 0;
}
.convo-list button:hover { background: var(--surface-alt); opacity: 1; }
.convo-list button[aria-current="true"] {
  background: var(--surface-alt);
  border-left-color: var(--accent);
}
.convo-list .who { font-weight: 500; }
.convo-list .meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.thread { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.7rem; min-height: 18rem; }
.bubble {
  max-width: 34rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.92rem;
  white-space: pre-wrap;
}
.bubble.inbound  { background: var(--client); align-self: flex-start; border-bottom-left-radius: 2px; }
.bubble.outbound { background: var(--bot);    align-self: flex-end;   border-bottom-right-radius: 2px; }
.bubble .stamp {
  display: block;
  margin-top: 0.35rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  color: var(--muted);
}
.bubble.human { background: var(--accent-bg); }

.composer {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--surface-alt);
}
.composer input { flex: 1; }

.empty {
  padding: 3rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

/* ------------------------------------------------------------- fake phone */

.phone-wrap { min-height: 100%; display: grid; place-items: center; padding: 2rem 1rem; }
.phone {
  width: 22rem;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  overflow: hidden;
  background: #ECE5DD;
  box-shadow: 0 12px 40px rgba(22, 35, 58, 0.16);
}
.phone .bar {
  background: #075E54;
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.phone .bar strong { font-weight: 500; }
.phone .bar span { font-size: 0.75rem; opacity: 0.8; font-family: "IBM Plex Mono", monospace; }
.phone .chat {
  height: 26rem;
  overflow-y: auto;
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.phone .composer { background: #F0F0F0; border-top: none; padding: 0.7rem; }
.phone .bubble { max-width: 85%; font-size: 0.88rem; }
.phone .bubble.outbound { background: #fff; align-self: flex-start; }
.phone .bubble.inbound  { background: #DCF8C6; align-self: flex-end; }

.phone-note {
  max-width: 22rem;
  margin: 1.25rem auto 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------- phone simulator */

.sim-controls {
  width: 22rem;
  max-width: 100%;
  margin: 0 auto 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.sim-field { display: flex; flex-direction: column; gap: 0.25rem; }
.sim-field span {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sim-field select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.86rem;
}
.sim-route {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: var(--accent);
  min-height: 1.1rem;
}

/* ----------------------------------------------------------------- library */

.library-layout { grid-template-columns: 24rem 1fr; padding-top: 0; }
@media (max-width: 60rem) { .library-layout { grid-template-columns: 1fr; } }

.searchbar { display: flex; gap: 0.6rem; }
.searchbar input { flex: 1; }

.src-row { padding: 0.8rem 1.1rem; }
.src-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: space-between;
}
.src-link {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  display: inline-block;
  margin-top: 0.3rem;
}

.passage {
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-top: 0.9rem;
  background: var(--surface);
}
.passage.firm { border-left-color: var(--accent); background: var(--accent-bg); }
.passage-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.passage-head .ref { font-weight: 600; font-size: 0.9rem; }
.passage-body {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
  color: var(--ink-soft);
}
.passage .meta {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  color: var(--muted);
}

.no-source {
  margin-top: 0.9rem;
  padding: 1.1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.no-source strong { display: block; margin-bottom: 0.35rem; }
.no-source p { margin: 0; font-size: 0.88rem; color: var(--muted); }

textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  resize: vertical;
}

.checks { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.tick {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--line);
}
.tick.done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bg); }
