:root {
  --bg: #f7f1e9;
  --card: #fffdf9;
  --ink: #2b1d14;
  --muted: #7a6656;
  --line: #e9dfd2;
  --brown: #3b2416;
  --caramel: #d9a066;
  --caramel-ink: #6b4318;
  --saddle: #8a5a2b;
  --red: #b4372f;
  --amber: #a86400;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(59, 36, 22, .06), 0 4px 14px rgba(59, 36, 22, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; -webkit-text-size-adjust: 100%; }
a { color: var(--brown); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brown); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
#nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
#nav a, #nav button {
  color: #ecdccb; text-decoration: none; background: none; border: 0; font: inherit; font-size: .9rem;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
#nav a.active { background: rgba(255,255,255,.12); color: #fff; }
#nav a:hover, #nav button:hover { color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 80px; }

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.auth { max-width: 420px; margin: 24px auto; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid #d8cab9; border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--caramel); outline-offset: 1px; border-color: var(--brown); }
textarea { resize: vertical; min-height: 80px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.note-callout { background: #fbf1e3; border: 1px solid #ecd3b0; color: var(--caramel-ink); border-radius: 10px; padding: 8px 10px; font-size: .85rem; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--brown); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn.lime { background: var(--caramel); color: var(--brown); }
.btn.ghost { background: transparent; color: var(--brown); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid #efcdca; }
.btn.block { width: 100%; margin-top: 16px; }
.btn.sm { padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.error { color: var(--red); font-size: .9rem; margin-top: 10px; min-height: 1.2em; }
.tabs { display: flex; background: #efe5d9; border-radius: 10px; padding: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; border: 0; background: none; font: inherit; font-weight: 600; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* week header */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.weekbar h1 { font-size: 1.15rem; margin: 0; text-align: center; flex: 1; }
.weekbar .btn { flex: 0 0 auto; }

/* day card */
.day { padding: 0; overflow: hidden; }
.day-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px 10px; }
.day-date { font-weight: 800; font-size: 1.05rem; }
.day-date .dow { color: var(--saddle); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--caramel); color: var(--brown); text-align: center; max-width: 62%; }
.badge.off { background: #ece3d8; color: var(--muted); }
.badge.full { background: var(--brown); color: #fff; }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 16px 10px; }
.meta div { font-size: .85rem; }
.meta b { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.focus { margin: 0 16px 10px; padding: 8px 10px; background: #faf5ee; border-left: 3px solid var(--caramel); border-radius: 6px; font-size: .9rem; }
.slots { border-top: 1px solid var(--line); }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 54px; }
.slot:last-child { border-bottom: 0; }
.slot .n { width: 24px; height: 24px; border-radius: 50%; background: #f2e9de; color: var(--muted); font-size: .8rem; font-weight: 700; display: grid; place-items: center; flex: 0 0 24px; }
.slot.filled .n { background: var(--saddle); color: #fff; }
.slot .who { flex: 1; font-weight: 600; }
.slot .who .me { font-size: .75rem; color: var(--saddle); font-weight: 700; margin-left: 6px; }
.slot select { flex: 1; padding: 8px 10px; }
.slot .x { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.slot .x:hover { color: var(--red); background: #fbeeed; }
.day.off .day-head, .day.off .meta { opacity: .6; }
.off-msg { padding: 14px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.day.past { opacity: .7; }
.day.today { border-color: var(--saddle); box-shadow: 0 0 0 2px rgba(138, 90, 43,.2), var(--shadow); }

/* coach editor */
.editor { background: #fcf8f2; border-top: 1px solid var(--line); padding: 12px 16px 14px; display: grid; gap: 10px; }
.editor .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor label { margin: 0 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.editor input, .editor select { padding: 8px 10px; }
.seg { display: flex; border: 1px solid #d8cab9; border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: #fff; font: inherit; font-size: .85rem; padding: 8px 4px; cursor: pointer; border-right: 1px solid #d8cab9; }
.seg button:last-child { border-right: 0; }
.seg button small { display: block; font-size: .72rem; font-weight: 400; opacity: .75; margin-top: 2px; }
.seg button.on { background: var(--brown); color: #fff; font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: .9rem; margin: 0; }
.switch input { width: 44px; height: 26px; appearance: none; -webkit-appearance: none; background: #d9ccbd; border-radius: 999px; position: relative; cursor: pointer; padding: 0; border: 0; flex: 0 0 44px; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--saddle); }
.switch input:checked::after { left: 21px; }

/* players list */
.plist a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.plist a:last-child { border-bottom: 0; }
.plist .nm { font-weight: 600; }
.pill { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: #f2e9de; color: var(--muted); font-weight: 600; }
.pill.warn { background: #fff3df; color: var(--amber); }
.pill.wait { background: #f3e3cf; color: var(--caramel-ink); }
.pending-note { background: #fbf1e3; border: 1px solid #ecd3b0; border-left: 4px solid var(--caramel); border-radius: 10px; padding: 12px 14px; color: var(--ink); }
.card.pending-note { box-shadow: none; }

/* notes */
.notes-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.plus { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--caramel); color: var(--brown); font-size: 1.6rem; line-height: 1; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.plus:hover { filter: brightness(.95); }
.note { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.note .ts { font-size: .78rem; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.note .body { white-space: pre-wrap; line-height: 1.45; }
.note-new { border: 2px dashed #e2c398; background: #fdf8f0; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px); background: var(--brown); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; transition: transform .2s; max-width: calc(100% - 32px); z-index: 50; box-shadow: var(--shadow); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

@media (max-width: 520px) {
  .brand span { display: none; }
  .meta { grid-template-columns: 1fr 1fr; }
  .editor .grid { grid-template-columns: 1fr; }
}
