/* Pathma UI prototype — control vocabulary per DESIGN.md (ADL/TDL lineage,
   Pathma palette). Four species: beveled buttons press, flat tags label,
   bare text informs, underlined links navigate. No disabled states. */

:root {
  --paper: #f4f8f9;
  --surface: #fdfefe;
  --surface-alt: #e9f1f2;
  --ink: #1e2e34;
  --ink-soft: #52676e;
  --line: #d7e2e5;
  --accent: #367588;
  --accent-hover: #2b5f6f;
  --on-accent: #ffffff;
  --danger: #9c5138;
  --raise: 0 1px 0 rgba(30, 46, 52, 0.05), 0 1px 3px rgba(30, 46, 52, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --raise-primary: 0 1px 0 rgba(0, 0, 0, 0.10), 0 1px 3px rgba(54, 117, 136, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.20);
  --raise-edge: #c3d4d9;
  --btn-bg: #ffffff;
  --btn-hover: #eaf1f3;
  --tag-bg: #e2ebee;
  --ins-bg: #d9eaee;
  --ins-ink: #1d4c59;
  --del-ink: #9c5138;
  --card-bg: #eef4f5;
  --ok: #2e7d5b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101b20;
    --surface: #16242b;
    --surface-alt: #1c2f37;
    --ink: #dce8eb;
    --ink-soft: #8fa6ad;
    --line: #2a3d45;
    --accent: #5da2b5;
    --accent-hover: #7ab8c9;
    --on-accent: #0c181d;
    --danger: #c98a6e;
    --raise: 0 1px 0 rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.40), inset 0 1px 0 rgba(255, 245, 235, 0.06);
    --raise-primary: 0 1px 0 rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    --raise-edge: #3a5560;
    --btn-bg: #1d3038;
    --btn-hover: #26404a;
    --tag-bg: #223a43;
    --ins-bg: #1d4c59;
    --ins-ink: #cfe6ec;
    --del-ink: #c98a6e;
    --card-bg: #1a2c33;
    --ok: #5bb08c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- top bar: wordmark + three-tab nav ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 650;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.65rem 0;
}
.wordmark .mark {
  width: 1.3rem;
  height: 1.3rem;
  display: block;
}
.nav { display: flex; align-items: stretch; }
.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 0.9rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); font-weight: 600; }
.nav a.active::after {
  content: '';
  position: absolute;
  left: 0.5rem; right: 0.5rem; bottom: 0;
  height: 3px;
  background: var(--accent);
}
.nav a:focus-visible, .wordmark:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.topbar .spacer { flex: 1; }

main {
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  display: flex;
  flex-direction: column;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.92rem;
  background: var(--btn-bg);
  color: var(--ink);
  border: 1px solid var(--raise-edge);
  box-shadow: var(--raise);
  border-radius: 10px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.08s, transform 0.05s;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent-hover);
  box-shadow: var(--raise-primary);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btnrow { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---- tags, status, links ---- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--tag-bg);
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.on { color: var(--ok); }
.status.off { color: var(--ink-soft); }
.link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}
.link:hover { text-decoration-thickness: 2px; }
.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- chat ---- */
.chatlog {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0.5rem 0 1rem;
}
.utter {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 14px 14px 4px 14px;
  padding: 0.55rem 0.85rem;
  max-width: 85%;
}
.reply { max-width: 95%; display: flex; flex-direction: column; gap: 0.55rem; align-items: flex-start; }
.reply p { margin: 0; }
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  max-width: 100%;
}
.card p { margin: 0.25rem 0 0; }
.card .k {
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.hint { color: var(--ink-soft); font-size: 0.85rem; margin: 0; }
.stamp { color: var(--ink-soft); font-size: 0.78rem; margin: 0; }
ins { background: var(--ins-bg); color: var(--ins-ink); text-decoration: none; border-radius: 3px; padding: 0 2px; }
del { color: var(--del-ink); }

.chips { display: flex; flex-direction: column; gap: 0.55rem; align-items: flex-start; }

.inputbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
  padding: 0.75rem 0 1rem;
  background: var(--paper);
}
.inputbar .field-wrap {
  flex: 1;
  position: relative;
  display: flex;
  min-width: 0;
}
.inputbar .field-wrap textarea {
  padding-right: 3rem;
  resize: none;
  max-height: 30vh;
  overflow-y: auto;
  line-height: 1.45;
  /* The field grows to fit its content, so the scrollbar control only
     matters past the 30vh cap; hide it rather than let it collide with
     the send button. Scrolling still works by caret and wheel. */
  scrollbar-width: none;
}
.inputbar .field-wrap textarea::-webkit-scrollbar { display: none; }
.inputbar .send {
  position: absolute;
  right: 6px;
  bottom: 5px; /* centers within a one-line field; hugs the last line when grown */
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent-hover);
  box-shadow: var(--raise-primary);
  border-radius: 9px;
  cursor: pointer;
}
.inputbar .send:hover { background: var(--accent-hover); }
.inputbar .send:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); }
.inputbar .send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.inputbar textarea {
  flex: 1;
  font: inherit;
  background: var(--btn-bg);
  color: var(--ink);
  border: 1px solid var(--raise-edge);
  box-shadow: var(--raise);
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
  min-width: 0;
}
.inputbar textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.inputbar textarea::placeholder { color: color-mix(in srgb, var(--ink-soft) 55%, transparent); }
.inputbar .mic {
  background: var(--btn-bg);
  border: 1px solid var(--raise-edge);
  box-shadow: var(--raise);
  border-radius: 12px;
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  color: var(--accent);
  flex: none;
  cursor: pointer;
}
.inputbar .mic:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); }
.inputbar .mic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- generic page furniture (rulebook, settings) ---- */
h1 { font-size: 1.35rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }
.lede { color: var(--ink-soft); margin: 0 0 1.25rem; font-size: 0.92rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.panel h2 { font-size: 1rem; font-weight: 600; margin: 0 0 0.2rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.panel .desc { color: var(--ink-soft); font-size: 0.88rem; margin: 0 0 0.75rem; }
.panel-foot { margin-top: 0.85rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

textarea.doc {
  width: 100%;
  min-height: 14rem;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--btn-bg);
  border: 1px solid var(--raise-edge);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  resize: vertical;
}
textarea.doc:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.rulelist { margin: 0; padding-left: 1.2rem; }
.rulelist li { margin: 0.35rem 0; }

.rev { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.rev:first-child { border-top: none; }
.rev .stamp { margin-bottom: 0.3rem; }
.revdiff { font-size: 0.92rem; line-height: 1.6; }

.empty {
  color: var(--ink-soft);
  font-size: 0.9rem;
  background: var(--surface-alt);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.empty p { margin: 0 0 0.5rem; }
.empty p:last-child { margin-bottom: 0; }

.audit { margin: 0.5rem 0 0; padding: 0; list-style: none; font-size: 0.88rem; }
.audit li { padding: 0.4rem 0; border-top: 1px solid var(--line); display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.audit .stamp { flex: none; }

form.mcp { display: flex; flex-direction: column; gap: 0.7rem; max-width: 26rem; }
form.mcp label { font-size: 0.85rem; font-weight: 600; display: flex; flex-direction: column; gap: 0.3rem; }
form.mcp input, form.mcp select {
  font: inherit;
  background: var(--btn-bg);
  color: var(--ink);
  border: 1px solid var(--raise-edge);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}
form.mcp input:focus, form.mcp select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

@media (max-width: 480px) {
  .topbar { gap: 0.5rem; }
  .nav a { padding: 0.65rem 0.6rem; }
}
