:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1f2630;
  --line: #2d3540;
  --text: #e6edf3;
  --muted: #8b96a3;
  --accent: #f5a524;
  --yes: #22c55e;
  --yes-bg: #14532d;
  --no: #ef4444;
  --no-bg: #3b1d1f;
  --warn: #eab308;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.who { color: var(--muted); font-size: 13px; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; background: none; border: 0; padding: 14px 4px; color: var(--muted); font-weight: 600;
}
.tabs button.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

.weeknav { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.weeknav .label { flex: 1; text-align: center; font-weight: 600; }
.weeknav .label small { display: block; color: var(--muted); font-weight: 400; }
.iconbtn {
  min-width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); font-size: 20px;
}
.iconbtn:disabled { opacity: .35; }

.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 10px;
  padding: 9px 12px; min-height: 40px; font-weight: 600;
}
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.btn.danger { color: #fca5a5; border-color: #5b2427; }
.btn.small { padding: 5px 10px; min-height: 34px; font-size: 13px; }
.btn.on { border-color: var(--accent); color: var(--accent); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.card.past { opacity: .5; }
.card.today { border-color: var(--accent); }
.dayhead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dayhead .d { font-weight: 700; }
.dayhead .s { color: var(--muted); font-size: 13px; }
.dayhead .tools { margin-left: auto; display: flex; gap: 6px; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.slot {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 10px;
  min-height: 48px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.slot .t { font-weight: 700; font-size: 14px; }
.slot .c { font-size: 11px; color: var(--muted); }
.slot.yes { background: var(--yes-bg); border-color: var(--yes); }
.slot.no { background: var(--no-bg); border-color: #5b2427; color: #c7a3a3; }
.slot:disabled { cursor: default; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.badge.ok { background: var(--yes-bg); color: #bbf7d0; }
.badge.todo { background: #3a2f0b; color: #fde68a; }

/* Team grid */
.heat { display: grid; gap: 4px; }
.heat .cell {
  border-radius: 8px; border: 1px solid transparent; background: var(--panel2);
  min-height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px;
}
.heat .cell .n { font-weight: 800; font-size: 16px; }
.heat .cell .t { font-size: 10px; color: var(--muted); }
.heat .cell.l1 { background: #1d2a22; }
.heat .cell.l2 { background: #3a3110; border-color: #6b5a12; }
.heat .cell.l3 { background: var(--yes-bg); border-color: var(--yes); }
.heat .cell.sel { outline: 2px solid var(--accent); }
.names { margin-top: 8px; font-size: 13px; color: var(--muted); }
.names b { color: var(--text); }

.best { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.best .pill {
  flex: none; background: var(--yes-bg); border: 1px solid var(--yes); border-radius: 10px; padding: 6px 10px; font-size: 13px;
}

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
input[type=text], input[type=number], input[type=date], select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 44px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
h2:first-child { margin-top: 4px; }
.member { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.member:first-of-type { border-top: 0; }
.member .nm { font-weight: 600; flex: 1; min-width: 100px; }
.member.inactive .nm { color: var(--muted); text-decoration: line-through; }
.linkbox {
  background: var(--bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px; margin-top: 8px;
  word-break: break-all; font-family: ui-monospace, monospace; font-size: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 99px; padding: 6px 10px; font-size: 13px; }
.chip.on { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty h1 { color: var(--text); font-size: 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #e6edf3; color: #111; padding: 8px 14px; border-radius: 99px; font-weight: 600; font-size: 14px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 10; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #fecaca; }
.weekactions { margin-bottom: 12px; }
.member .nm { flex-basis: 100%; }
.member .btn.small { min-height: 32px; padding: 4px 9px; font-size: 12px; }
.btn.armed { background: #7f1d1d; border-color: var(--no); color: #fff; }
.linkslot { flex-basis: 100%; }
.linkslot:empty { display: none; }
.linkbox { font-family: inherit; font-size: 13px; }
.linkhint { color: var(--muted); margin-bottom: 6px; }
.linkfield { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 12px ui-monospace, monospace; margin-bottom: 8px; }
.heat { gap: 3px; }
.heat .cell { padding: 2px 0; min-width: 0; }
.heat .cell .t { font-size: 9px; letter-spacing: -.02em; }
