:root {
  --bg: #0c0d11;
  --panel: #14161d;
  --panel-2: #191c25;
  --line: #262a36;
  --ink: #e8eaf0;
  --ink-2: #9aa1b4;
  --ink-3: #626a80;
  --accent: #d9a05b;      /* brass — the compass needle */
  --accent-dim: #8a6636;
  --good: #4fb477;
  --warn: #d98b5b;
  --bad: #d9615b;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: contain;
}

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

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  font-size: 26px; color: var(--accent);
  filter: drop-shadow(0 0 10px rgba(217,160,91,.35));
}
h1 { font-size: 19px; margin: 0; letter-spacing: .3px; font-weight: 600; }
#subtitle { margin: 1px 0 0; font-size: 12.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- tabs */

#tabs {
  display: flex; gap: 4px; padding: 0 12px 10px; position: sticky;
  top: calc(env(safe-area-inset-top) + 52px); z-index: 19;
  background: var(--bg); overflow-x: auto; scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  flex: 0 0 auto; background: none; border: 0; color: var(--ink-3);
  font: inherit; font-size: 14px; padding: 7px 13px; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
}
#tabs button.active { background: var(--panel-2); color: var(--ink); }

main { padding: 4px 12px 90px; max-width: 720px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.muted.small { color: var(--ink-3); }
p { margin: 6px 0; }

/* ---------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 8px; text-align: center;
}
.stat b { display: block; font-size: 21px; font-weight: 600; line-height: 1.1; }
.stat span { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.stat.alert b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: var(--good); }

/* ---------------------------------------------------------------- items */

.item {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; margin: 8px 0; background: var(--panel-2);
}
.item.focus { border-left: 3px solid var(--accent); }
.item.observation { border-left: 3px solid #7b8ed9; }
.item.warning { border-left: 3px solid var(--warn); }
.item.win { border-left: 3px solid var(--good); }
.item h3 { font-size: 14.5px; margin: 0 0 4px; font-weight: 600; line-height: 1.35; }
.item .body { font-size: 13.5px; color: var(--ink-2); white-space: pre-wrap; }
.item .why { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; font-style: italic; }
.item .evidence { font-size: 12px; color: var(--ink-3); margin-top: 6px; padding-left: 14px; }
.item .evidence li { margin: 2px 0; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.tag {
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  background: #22262f; color: var(--ink-2); letter-spacing: .3px;
}
.tag.accent { background: rgba(217,160,91,.15); color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

button { font: inherit; cursor: pointer; border-radius: 10px; }
button.primary {
  background: var(--accent); color: #17130c; border: 0;
  padding: 9px 15px; font-weight: 600; font-size: 14px;
}
button.ghost {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); padding: 8px 13px; font-size: 13.5px;
}
button.ghost.small { padding: 4px 10px; font-size: 12.5px; }
button.ghost:active, button.primary:active { transform: scale(.97); }
button.ghost.on { border-color: var(--accent); color: var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.actions.wrap { flex-wrap: wrap; }
.seg { display: flex; gap: 4px; }
.seg-btn {
  background: none; border: 0; color: var(--ink-3); font-size: 12px;
  padding: 4px 9px; border-radius: 999px;
}
.seg-btn.active { background: var(--panel-2); color: var(--ink); }

/* ---------------------------------------------------------------- inputs */

textarea, input[type=text], input[type=date], select {
  width: 100%; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font: inherit; font-size: 14.5px; margin-top: 8px; resize: vertical;
}
textarea:focus, input:focus, select:focus { outline: 1px solid var(--accent-dim); }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.slider-row { flex: 1 1 140px; font-size: 13px; color: var(--ink-2); }
.slider-row b { color: var(--accent); }
input[type=range] {
  width: 100%; accent-color: var(--accent); margin-top: 4px;
}

/* ---------------------------------------------------------------- holds */

.hold { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.hold:last-child { border-bottom: 0; }
.hold .name { flex: 1; font-size: 14px; }
.hold .name small { display: block; color: var(--ink-3); font-size: 11.5px; }
.hold .rate { font-size: 12px; color: var(--ink-3); min-width: 52px; text-align: right; }
.hold .rate.bad { color: var(--bad); }
.hold-btns { display: flex; gap: 4px; }
.hold-btns button {
  width: 32px; height: 32px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-3); font-size: 14px; padding: 0;
}
.hold-btns button.on[data-state=held] { background: var(--good); color: #06130c; border-color: var(--good); }
.hold-btns button.on[data-state=floor] { background: var(--warn); color: #1a0e05; border-color: var(--warn); }
.hold-btns button.on[data-state=missed] { background: var(--bad); color: #1a0606; border-color: var(--bad); }
.strip { display: flex; gap: 2px; margin-top: 4px; }
.strip i { width: 6px; height: 6px; border-radius: 2px; background: #2a2f3b; display: block; }
.strip i.held { background: var(--good); }
.strip i.floor { background: var(--warn); }
.strip i.missed { background: var(--bad); }

/* ---------------------------------------------------------------- wheel */

#wheel-chart { display: flex; justify-content: center; padding: 6px 0 12px; }
.wheel-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.wheel-row label { flex: 0 0 108px; font-size: 13px; color: var(--ink-2); }
.wheel-row input { flex: 1; margin: 0; }
.wheel-row b { flex: 0 0 22px; text-align: right; color: var(--accent); font-size: 13px; }
.hist-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 12px; }
.hist-row span { flex: 0 0 108px; color: var(--ink-3); }
.bar { flex: 1; height: 7px; background: #22262f; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

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

#chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--accent); color: #17130c; border-bottom-right-radius: 4px; }
.msg.coach { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
#chat-form { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(env(safe-area-inset-bottom) + 10px); display: flex; gap: 8px; align-items: flex-end; }
#chat-form textarea { margin: 0; }
#chat-form button { flex: 0 0 auto; }

/* ---------------------------------------------------------------- misc */

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--ink-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.ok { background: var(--good); }
.dot.bad { background: var(--bad); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); padding: 10px 16px; border-radius: 999px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { color: var(--ink-3); font-size: 13.5px; padding: 10px 0; text-align: center; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
