:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #2c3338;
  --muted: #6b7680;
  --line: #e4e0d6;
  --brand: #3f7d52;
  --brand-soft: #e3efe6;
  --accent: #c97b3c;
  --outdoor: #3f7d52;
  --indoor: #5a7da0;
  --screen: #9b6bae;
  --personal: #b0905a;
  --danger: #b3493f;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 8px;
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-mark { font-size: 1.4rem; }
.brand-name { color: var(--brand); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  overflow-x: auto;
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .95rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--bg); }
.tab.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* Content */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 18px 64px;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.view-head h1 { font-size: 1.5rem; margin: 0; }
.view-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .92rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e6c4c0; }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 1.1rem; color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* Cards / grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card .meta { color: var(--muted); font-size: .85rem; }
.card-actions { display: flex; gap: 6px; margin-top: 12px; }

.tag {
  display: inline-block;
  font-size: .74rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  margin: 2px 3px 0 0;
}
.tag.skill { background: var(--brand-soft); border-color: #cfe2d4; color: #2f5e3d; }
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; }
.set-outdoor { background: var(--outdoor); }
.set-indoor { background: var(--indoor); }
.set-screen { background: var(--screen); }
.set-personal { background: var(--personal); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

/* Forms */
.field { margin-bottom: 14px; }
.field label { display:block; font-weight:600; font-size:.88rem; margin-bottom:5px; }
.field input[type=text], .field input[type=number], .field input[type=date],
.field input[type=time], .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: .95rem; font-family: inherit; background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.checks { display:flex; flex-wrap:wrap; gap:6px; }
.check-pill {
  display:inline-flex; align-items:center; gap:6px;
  padding: 6px 10px; border:1px solid var(--line); border-radius:999px;
  font-size:.85rem; cursor:pointer; user-select:none;
}
.check-pill input { margin:0; }
.check-pill.on { background: var(--brand-soft); border-color:#cfe2d4; color:#2f5e3d; }
.hint { color: var(--muted); font-size:.82rem; margin-top:4px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,24,28,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { display:flex; align-items:center; justify-content:space-between; padding: 16px 18px; border-bottom:1px solid var(--line); }
.modal-head h2 { margin:0; font-size:1.15rem; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display:flex; justify-content:flex-end; gap:8px; padding: 14px 18px; border-top:1px solid var(--line); }

/* Today view */
.meter {
  background: var(--surface); border:1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.meter h3 { margin:0 0 10px; font-size:1rem; }
.meter-bar { display:flex; height:22px; border-radius:999px; overflow:hidden; background:var(--bg); }
.meter-seg { height:100%; }
.meter-legend { display:flex; gap:16px; margin-top:10px; flex-wrap:wrap; font-size:.82rem; color:var(--muted); }

.timeline { display:flex; flex-direction:column; gap:10px; }
.slot-row {
  display:flex; gap:14px; align-items:stretch;
  background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.slot-row.done { opacity:.6; }
.slot-time { font-weight:700; min-width:74px; color:var(--ink); }
.slot-time small { display:block; font-weight:400; color:var(--muted); }
.slot-main { flex:1; }
.slot-main h4 { margin:0 0 3px; }
.slot-side { display:flex; flex-direction:column; gap:6px; align-items:flex-end; }

/* Planner grid */
.planner-controls { display:flex; gap:8px; align-items:center; margin-bottom:14px; flex-wrap:wrap; }
.week-scroll { overflow-x:auto; border:1px solid var(--line); border-radius: var(--radius); background:var(--surface); }
.week-grid { display:grid; grid-template-columns: 60px repeat(7, minmax(120px,1fr)); min-width:760px; }
.wg-cell { border-right:1px solid var(--line); border-bottom:1px solid var(--line); min-height:46px; padding:3px; }
.wg-head { position:sticky; top:0; background:var(--surface); font-weight:600; text-align:center; padding:8px 4px; border-bottom:2px solid var(--line); font-size:.85rem; }
.wg-head.today { color:var(--brand); }
.wg-hour { font-size:.75rem; color:var(--muted); text-align:right; padding:4px 6px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); }
.wg-cell:hover { background: var(--brand-soft); cursor:pointer; }
.block {
  border-radius:6px; padding:3px 6px; font-size:.74rem; color:#fff; margin-bottom:2px;
  cursor:pointer; line-height:1.2;
}
.block.set-outdoor { background: var(--outdoor); }
.block.set-indoor { background: var(--indoor); }
.block.set-screen { background: var(--screen); }
.block.set-personal { background: var(--personal); }

/* Monthly focus */
.focus-banner {
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  margin-bottom:16px; border-left:4px solid var(--accent); flex-wrap:wrap;
}
.focus-banner h3 { margin:2px 0; font-size:1.15rem; }
.focus-eyebrow {
  font-size:.74rem; font-weight:700; letter-spacing:.04em;
  color:var(--accent); text-transform:uppercase;
}
.focus-acts { margin-top:8px; }
.focus-actions { display:flex; gap:6px; flex-shrink:0; }
.focus-chip {
  display:inline-block; background:var(--brand-soft); border:1px solid #cfe2d4;
  color:#2f5e3d; border-radius:999px; padding:8px 16px; font-size:.9rem; margin-bottom:16px;
}

/* Month */
.month-grid { display:grid; grid-template-columns: repeat(7,1fr); gap:6px; }
.month-dow { text-align:center; font-size:.78rem; color:var(--muted); font-weight:600; padding:4px; }
.month-day {
  background:var(--surface); border:1px solid var(--line); border-radius:8px;
  min-height:74px; padding:6px; cursor:pointer;
}
.month-day:hover { border-color: var(--brand); }
.month-day.other { opacity:.4; }
.month-day.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.month-day .dnum { font-size:.82rem; font-weight:600; }
.month-dots { display:flex; flex-wrap:wrap; gap:3px; margin-top:5px; }
.month-dots .dot { width:7px; height:7px; margin:0; }

/* Progress */
.prog-student { margin-bottom: 26px; }
.prog-bar-row { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
.prog-label { min-width:170px; font-size:.9rem; }
.prog-track { flex:1; background:var(--bg); border-radius:999px; height:14px; overflow:hidden; border:1px solid var(--line); }
.prog-fill { height:100%; background:var(--brand); }
.prog-count { min-width:90px; font-size:.82rem; color:var(--muted); text-align:right; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color:#fff; padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; box-shadow: var(--shadow); z-index: 80;
}
.toast.hidden { display:none; }

.maps-row { margin-top: 8px; }
.maps-row a { color: var(--brand); text-decoration: none; font-weight: 600; }
.maps-row a:hover { text-decoration: underline; }

.hidden { display: none; }

.match-box { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.match-row { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:.82rem; color:var(--muted); margin-bottom:5px; }

/* Lists */
.list-card { cursor: pointer; }
.tpl-row { display:grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap:10px; }
.tpl-card {
  display:flex; flex-direction:column; gap:3px; text-align:left;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px; cursor:pointer; box-shadow:var(--shadow); font:inherit; color:inherit;
}
.tpl-card:hover { border-color:var(--brand); }
.tpl-icon { font-size:1.6rem; }
.tpl-name { font-weight:700; }
.tpl-desc { font-size:.8rem; color:var(--muted); }

.list-section { margin-bottom:14px; }
.sec-head { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.sec-name {
  flex:1; font-weight:700; font-size:1rem; border:none; background:transparent;
  padding:4px 2px; border-bottom:1px solid transparent; color:var(--ink); font-family:inherit;
}
.sec-name:hover { border-bottom-color:var(--line); }
.sec-name:focus { outline:none; border-bottom-color:var(--brand); }
.items { display:flex; flex-direction:column; }
.item-row { display:flex; align-items:center; gap:10px; padding:5px 0; border-bottom:1px solid var(--line); }
.item-row:last-child { border-bottom:none; }
.item-box { width:18px; height:18px; flex:0 0 auto; cursor:pointer; }
.item-text {
  flex:1; min-width:0; border:none; background:transparent; padding:5px 4px;
  font-size:.95rem; font-family:inherit; color:var(--ink); border-radius:4px;
}
.item-text:focus { outline:none; background:var(--bg); }
.item-qty { width:64px; flex:0 0 auto; border:1px solid var(--line); border-radius:6px; padding:4px 6px; font-size:.85rem; font-family:inherit; }
.item-row.done .item-text { text-decoration:line-through; color:var(--muted); }
.item-add { display:flex; gap:8px; margin-top:10px; }
.add-text { flex:1; padding:8px 10px; border:1px solid var(--line); border-radius:8px; font-size:.92rem; font-family:inherit; background:#fff; }
.list-foot { display:flex; gap:8px; flex-wrap:wrap; margin-top:6px; }

@media (max-width: 600px) {
  .brand { padding: 10px 14px 6px; }
  .content { padding: 16px 12px 64px; }
  .prog-label { min-width: 110px; }
}

@media print {
  .app-header, .planner-controls, .view-head .btn, .view-head > div:last-child,
  .modal-overlay, .toast { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .week-scroll { overflow: visible; border: none; box-shadow: none; }
  .week-grid { min-width: 0; }
  .wg-cell:hover { background: none; }
  .card, .slot-row { box-shadow: none; break-inside: avoid; }
  .item-add, .list-foot, .sec-head .icon-btn, .item-row .icon-btn { display: none !important; }
  .item-qty { border: none; }
}
