/* Org chat — phone-first, one page, two views.
   Palette and radii are pinned by the work order; everything else stays
   quiet so the thread is the interface. */

:root {
  --navy: #0b1f3a;
  --gold: #c9a227;
  --bg: #f5f6f8;
  --ink: #1a2230;
  --line: #d8dde5;
  --muted: #66707e;
  --danger: #b3261e;
  --ok: #1b7f3b;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- login ---- */

#view-login {
  margin: auto;
  width: 100%;
  max-width: 340px;
  padding: 24px;
}

.login-card h1 { margin: 0 0 4px; font-size: 24px; }

.lead { margin: 0 0 20px; color: var(--muted); }

#login-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

#token {
  width: 100%;
  padding: 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

#login-form button {
  margin-top: 14px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 600;
}

#login-form button:disabled { opacity: 0.55; }

.error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
}

/* ---- chat ---- */

#view-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid var(--gold);
}

.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }

#logout-btn {
  min-height: 44px;
  padding: 6px 14px;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  font: inherit;
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 6px;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-top: 32px;
}

.turn { margin: 0 0 14px; }

.row { display: flex; flex-direction: column; }
.row.mine   { align-items: flex-end; }
.row.theirs { align-items: flex-start; }

.bubble {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.ceo {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.org {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

time, .chip { font-size: 12px; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 5px; }
.chip-done { color: var(--ok); }
.chip-timeout, .chip-error { color: var(--danger); }

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

.turn-error {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--danger);
  overflow-wrap: anywhere;
}

/* ---- composer ---- */

.composer-bar {
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
}

#send-error { margin: 0 0 6px; }

.counter {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#draft {
  flex: 1;
  min-width: 0; /* lets the textarea shrink at 360px */
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.4;
  max-height: 6.2em; /* four rows, then it scrolls */
  overflow-y: auto;
}

#send-btn {
  flex: none;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 600;
}

#send-btn:disabled { opacity: 0.55; }
