:root {
  --paper: #F1F3ED;
  --rule: #DEE2D2;
  --ink: #1F2A24;
  --ink-soft: #5C6152;
  --muted: #8A8D7C;
  --line: #C9CBB8;
  --card: #FBFCF8;
  --border: #DEE2D2;
  --danger: #C0503A;
  --success: #3F8F5C;
  --warning: #D9A441;
  --kid-1: #E4623F;
  --kid-2: #2E8B84;
  --kid-3: #4A5FBF;
  --kid-4: #B25C9E;
  --kid-5: #3F8F5C;
  --kid-6: #C77B3B;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image: repeating-linear-gradient(180deg, transparent, transparent 31px, var(--rule) 32px);
  min-height: 100vh;
}

.fredoka { font-family: 'Fredoka', sans-serif; }
.mono { font-family: 'JetBrains Mono', monospace; }

button {
  font-family: inherit;
  cursor: pointer;
}
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--kid-3);
  outline-offset: 2px;
}

::selection { background: #D9A44155; }

#app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 88px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 22px;
  gap: 10px;
  border-right: 2px solid var(--ink);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-mascot {
  width: 52px;
  height: 52px;
  object-fit: contain;
  margin-bottom: 6px;
}

.holes {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 8px;
}
.hole {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line);
}

.tab-btn {
  width: 56px;
  min-height: 56px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  border: 2px solid var(--ink);
  color: var(--ink);
}
.tab-btn.active { color: #fff; }
.tab-btn span {
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-btn svg { width: 18px; height: 18px; }

.add-child-btn {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 2px dashed var(--line);
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

.install-btn {
  margin-top: auto;
  margin-bottom: 16px;
  width: 64px;
  padding: 8px 4px;
  border-radius: 10px;
  border: none;
  background: var(--warning);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  display: none;
}
.install-btn.visible { display: block; }

/* ---------- Main ---------- */

.main {
  flex: 1;
  padding: 28px 24px 60px;
  max-width: 880px;
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand h1 { font-size: 26px; font-weight: 600; margin: 0; }
.brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  font-size: 13px;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:disabled { background: var(--line); color: #fff; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn svg { width: 15px; height: 15px; }

/* ---------- Empty state ---------- */

.empty-state {
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-soft);
}
.empty-state h3 { font-size: 20px; margin: 0 0 8px; }
.empty-state p { font-size: 14px; margin: 0 0 16px; }

/* ---------- Hero ---------- */

.hero {
  background: var(--ink);
  color: var(--paper);
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 26px;
}
.hero-eyebrow {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--line);
  margin-bottom: 6px;
}
.hero-body { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.hero-number { font-size: 44px; font-weight: 600; line-height: 1; }
.hero-title { font-size: 16px; font-weight: 600; }
.hero-meta { font-size: 12.5px; color: var(--line); display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.hero-empty { font-size: 14px; color: var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Sections ---------- */

section.list-section { margin-bottom: 26px; }
section.list-section h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
}
.group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.empty-row { font-size: 13px; color: var(--muted); font-style: italic; padding: 8px 0; }

/* ---------- Item row ---------- */

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
}
.item-date { font-size: 12px; color: var(--ink-soft); width: 72px; flex-shrink: 0; }
.item-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.item-icon svg { width: 15px; height: 15px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-score { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.item-due { font-size: 11px; font-weight: 700; color: var(--danger); flex-shrink: 0; }
.icon-btn { background: none; border: none; color: var(--muted); padding: 4px; flex-shrink: 0; }
.icon-btn.danger { color: var(--danger); }
.icon-btn svg { width: 14px; height: 14px; display: block; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31,42,36,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: var(--card); border-radius: 16px; padding: 22px;
  width: 380px; max-width: 100%; border: 2px solid var(--ink);
  max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-size: 18px; margin: 0; }
.modal-head button { background: none; border: none; color: var(--ink-soft); }
.modal-head button svg { width: 18px; height: 18px; }

label.field-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; display: block; }
.field {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 14px; margin-bottom: 12px; font-family: inherit; background: #fff; color: var(--ink);
}
.type-row { display: flex; gap: 6px; margin-bottom: 12px; }
.type-btn {
  flex: 1; padding: 8px 0; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.type-btn.active { border: 2px solid var(--ink); background: var(--ink); color: var(--paper); }
.score-row { display: flex; gap: 8px; }
.score-row > div { flex: 1; }

.save-btn {
  width: 100%; padding: 10px; border-radius: 8px; border: none; margin-top: 4px;
  background: var(--ink); color: var(--paper); font-weight: 600;
}
.save-btn:disabled { background: var(--line); }
.delete-btn {
  margin-top: 14px; width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--danger);
  background: none; color: var(--danger); font-weight: 600; font-size: 13px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 600; z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  #app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row;
    overflow-x: auto; padding: 12px 10px; border-right: none; border-bottom: 2px solid var(--ink);
    gap: 8px;
  }
  .holes { display: none; }
  .sidebar-mascot { width: 40px; height: 40px; margin: 0 4px 0 0; }
  .install-btn { margin: 0 0 0 auto; }
  .main { padding: 18px 14px 50px; }
  .hero-number { font-size: 36px; }
}
