/* Metis phone app. Mobile first, dark first, follows the system theme. */

:root {
  color-scheme: dark light;
  --bg: #0b0d12;
  --surface: #141821;
  --surface-2: #1c212c;
  --line: #2a3140;
  --text: #e9ebf1;
  --muted: #a2aaba;
  --accent: #f0b878;
  --accent-soft: rgba(240, 184, 120, 0.16);
  --hole: #000000;
  --rec: #ff7b6e;
  --rec-soft: rgba(255, 123, 110, 0.22);
  --ok: #86d6ad;
  --bad: #ff9a9a;
  --warn: #f3cd74;
  --focus: #9fc0ff;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 100%;
  line-height: 1.45;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f4f0;
    --surface: #ffffff;
    --surface-2: #ecebe6;
    --line: #d9d7cf;
    --text: #16181d;
    --muted: #555b67;
    --accent: #9a5a14;
    --accent-soft: rgba(154, 90, 20, 0.12);
    --hole: #101218;
    --rec: #c3352a;
    --rec-soft: rgba(195, 53, 42, 0.16);
    --ok: #1d7048;
    --bad: #b02222;
    --warn: #7d5800;
    --focus: #2457c5;
  }
}

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

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

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

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

/* ---- header ---- */

.top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hole) 0 42%, var(--accent) 47%, var(--accent-soft) 62%, transparent 72%);
}

.quiet {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
}

#repair {
  display: none;
}

body[data-state="waiting"] #repair,
body[data-state="ready"] #repair {
  display: inline-block;
}

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

main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px;
}

.screen {
  display: none;
}

body:not([data-state]) #screen-start,
body[data-state="unsupported"] #screen-unsupported,
body[data-state="unpaired"] #screen-pair,
body[data-state="waiting"] #screen-waiting,
body[data-state="ready"] #screen-ready {
  display: flex;
}

.center {
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 100%;
  max-width: 28rem;
  margin: 0 auto;
  padding: 24px 0 48px;
}

/* The form sits low, near the thumb and the message line. */
#screen-pair {
  justify-content: flex-end;
}

#screen-waiting {
  align-items: center;
  text-align: center;
}

#screen-ready {
  flex-direction: column;
  gap: 12px;
  max-width: 40rem;
  margin: 0 auto;
  padding: 4px 0 16px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
}

.hint {
  color: var(--muted);
}

.missing {
  margin: 0;
  padding-left: 1.2em;
}

.missing li {
  margin: 4px 0;
}

/* ---- pair ---- */

.pair-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.pair-form label {
  font-size: 0.9rem;
  color: var(--muted);
}

#pair-code {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.2rem;
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#pair-code::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.primary {
  min-height: 52px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #15110b;
  font-weight: 600;
  font-size: 1.05rem;
}

@media (prefers-color-scheme: light) {
  .primary {
    color: #ffffff;
  }
}

.primary:disabled,
#pair-code:disabled {
  opacity: 0.55;
}

/* ---- waiting ---- */

.orbit {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hole) 0 40%, var(--accent) 45%, var(--accent-soft) 60%, transparent 71%);
  animation: breathe 3.2s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.75;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- note list ---- */

.late {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.warn {
  padding: 10px 14px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  color: var(--warn);
}

.notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.note-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.note-num {
  font-weight: 600;
}

.note-time,
.note-len {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stage {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.stage[data-stage="waiting"] {
  color: var(--warn);
}

.stage[data-stage="transcribed"],
.stage[data-stage="routed"],
.stage[data-stage="queued"],
.stage[data-stage="building"],
.stage[data-stage="picked_up"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.stage[data-stage="built"],
.stage[data-stage="merged"] {
  color: var(--ok);
}

.stage[data-stage="failed"],
.stage[data-stage="unsent"] {
  color: var(--bad);
}

.note .delete {
  margin-top: 8px;
}

.note-title {
  margin-top: 8px;
  font-weight: 600;
}

.note-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.note-error {
  margin-top: 6px;
  color: var(--bad);
}

.transcript-box {
  margin-top: 8px;
}

.transcript-box summary {
  display: inline-block;
  min-height: 44px;
  padding: 10px 0;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}

.transcript-box summary::-webkit-details-marker {
  display: none;
}

/* A small chevron: points right when closed, down when open. */
.transcript-box summary::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
  transition: transform 160ms ease;
}

.transcript-box[open] summary::after {
  transform: translateY(-4px) rotate(45deg);
}

.transcript {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  white-space: pre-wrap;
}

.empty {
  padding: 24px 0;
  text-align: center;
}

/* ---- message ---- */

.message {
  flex: none;
  min-height: 1.45em;
  padding: 6px 16px 0;
  color: var(--text);
  text-align: center;
}

.message:empty {
  padding-top: 0;
}

/* ---- record dock ---- */

.dock {
  flex: none;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 8px;
}

body[data-state="ready"] .dock {
  display: flex;
}

.queue {
  color: var(--warn);
  font-size: 0.95rem;
}

.record {
  position: relative;
  width: 9.5rem;
  height: 9.5rem;
  margin: 6px 0 2px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hole) 0 54%, var(--accent) 57%, var(--accent-soft) 66%, transparent 71%);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms ease;
}

.record:active {
  transform: scale(0.97);
}

.record:disabled {
  opacity: 0.6;
}

.record .disc {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  transition: border-radius 160ms ease, background-color 160ms ease;
}

.record[data-recording="true"] {
  background: radial-gradient(circle, var(--hole) 0 54%, var(--rec) 57%, var(--rec-soft) 66%, transparent 71%);
  animation: pulse 1.8s ease-in-out infinite;
}

.record[data-recording="true"] .disc {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--rec);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.record-label {
  color: var(--muted);
}

.elapsed {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

/* ---- footer line ---- */

.foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 14px;
  padding: 4px 16px calc(env(safe-area-inset-bottom, 0px) + 8px);
  color: var(--muted);
  font-size: 0.78rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
