:root {
  --bg: #FBF9F5;
  --bg-2: #F5EEE5;
  --card: #FFFFFF;
  --card-2: #F7EAEA;
  --cream: #F5EEE5;
  --line: #E9E0D8;
  --accent: #E9D0D0;
  --accent-soft: #F7EAEA;
  --text: #776B63;
  --text-2: #AFA39B;
  --muted: #AFA39B;
  --warn: #C9A9A9;
  --warn-bg: #F7EAEA;
  --danger: #A67C76;
  --danger-bg: #F7EAEA;
  --shadow: 0 10px 30px rgba(119, 107, 99, 0.05);
  --on-accent: #776B63;
  --radius: 14px;
  --sidebar: 248px;
  --tab: 78px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { transition: transform 180ms ease, background 180ms ease, opacity 180ms ease; }
button:active { transform: scale(0.98); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.03em; margin: 0; }
h1 { font-size: 2rem; line-height: 1.12; }
h2 { font-size: 1.15rem; }
p { margin: 0; }

.app-shell { min-height: 100vh; }
.sidebar {
  display: none;
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  object-fit: cover; background: var(--cream);
  border: 1px solid var(--line);
}
.brand-mark.lg { width: 88px; height: 88px; border-radius: 16px; margin-bottom: 8px; }
.brand-mark::after { display: none; }
.content { animation: fadein 280ms ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel, .stat-card { animation: fadein 320ms ease; }
.habit-row, .timeline li, .session-list li { transition: background 180ms ease; }
.inline-form, .filter-bar { flex-wrap: wrap; }
.people-grid { display: grid; }
.brand-mark::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px; top: 8px; bottom: 8px;
  border: 1.5px solid var(--accent);
  border-radius: 2px 4px 4px 2px;
}
.brand-mark.lg { width: 46px; height: 46px; border-radius: 14px; margin-bottom: 8px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link, .sheet-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 0 12px; border-radius: 12px;
  color: var(--text-2);
}
.nav-link svg, .sheet-link svg, .tab svg { width: 18px; height: 18px; stroke-width: 1.75; }
.nav-link.is-active, .tab.is-active {
  background: var(--accent-soft);
  color: var(--text);
}
.side-user {
  margin-top: auto; display: flex; gap: 10px; align-items: center;
  padding: 10px; background: var(--card); border-radius: 14px; border: 1px solid var(--line);
}
.side-user strong, .side-user span { display: block; }
.side-user span { color: var(--text-2); font-size: 0.85rem; }
.main-column { min-height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px 0;
}
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.92rem; }
.content { padding: 8px 20px calc(var(--tab) + 28px); max-width: 860px; }
.page-head { align-items: flex-end; margin: 18px 0 22px; }
.eyebrow { color: var(--text-2); font-size: 0.95rem; margin-bottom: 2px; font-weight: 500; }
.panel, .stat-card, .auth-card {
  background: var(--card);
  border: 1px solid rgba(233, 224, 216, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card { padding: 18px; }
.stat-label, .stat-meta, .muted { color: var(--text-2); font-size: 0.86rem; }
.stat-value { font-size: 1.85rem; font-weight: 600; margin: 6px 0 2px; letter-spacing: -0.04em; }
.split-panels { display: grid; gap: 12px; }
.habit-list, .session-list, .timeline, .goal-list, .mini-list, .chip-list, .check-list {
  list-style: none; margin: 0; padding: 0;
}
.page-head, .panel-head, .person-head, .goal-top, .form-actions, .date-switch, .filter-bar, .inline-form {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.habit-row, .session-list li, .timeline li {
  display: flex; align-items: center; gap: 12px;
  min-height: 58px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.habit-row:first-child, .session-list li:first-child, .timeline li:first-child { border-top: 0; }
.habit-copy, .timeline li div, .session-list li div { flex: 1; min-width: 0; }
.habit-copy span, .timeline span, .session-list span, .mini-list li { color: var(--text-2); font-size: 0.9rem; }
.habit-row.is-done strong, .timeline li.is-done strong { color: var(--text-2); }
.habit-row.is-paused { opacity: 0.7; }
.check {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--accent-soft); background: var(--card-2);
  display: grid; place-items: center; padding: 0; cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.check svg { width: 15px; height: 15px; opacity: 0; color: var(--on-accent); }
.check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.check[aria-pressed="true"] svg { opacity: 1; }
.icon-btn, .btn, .tab {
  border: 0; background: transparent; cursor: pointer;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; color: var(--text-2);
}
.icon-btn:hover, .btn-quiet:hover { background: var(--cream); }
.btn {
  background: var(--accent); color: var(--on-accent); border-radius: 8px;
  min-height: 40px; padding: 0 14px; font-weight: 600;
}
.btn-quiet { background: var(--cream); color: var(--text); }
.btn-block { width: 100%; }
.pill {
  background: var(--cream); color: var(--text-2); border-radius: 8px;
  padding: 4px 10px; font-size: 0.8rem; text-transform: capitalize;
}
.timeline time { width: 64px; color: var(--text-2); font-size: 0.88rem; }
.timeline-lg li { align-items: flex-start; padding: 14px 0; }
.empty { text-align: left; padding: 28px 4px 18px; }
.empty h3 { margin-bottom: 4px; font-size: 1.05rem; }
.empty p { color: var(--text-2); margin-bottom: 14px; }
.text-action {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 2px;
  color: var(--text); border-bottom: 1px solid var(--accent); border-radius: 0;
}
.text-action:hover { opacity: 0.7; }
.file-drop {
  position: relative;
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.file-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.file-drop .file-name { color: var(--text-2); font-size: 0.86rem; }
.file-drop:hover { background: var(--card-2); }
.modal-panel {
  width: min(440px, calc(100% - 32px));
  margin: 10vh auto 0;
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 40px rgba(119, 107, 99, 0.12);
}
.modal-panel h2 { margin-bottom: 14px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  min-height: 32px;
  padding: 0 4px;
  cursor: pointer;
}
.modal-panel .form-actions, .modal-panel .btn { margin-top: 4px; }
.sheet-panel { border-radius: 16px 16px 0 0; left: 0; right: 0; bottom: 0; }
.panel-head a { color: var(--text-2); font-size: 0.92rem; }
.file-drop { position: relative; }
.file-drop:hover { background: var(--card-2); }
.side-user strong { font-weight: 600; }
.upload-box { margin: 16px 0; }
.side-user { border: 0; background: transparent; padding: 8px; }
.avatar { border-radius: 8px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; color: var(--text-2); font-size: 0.72rem; }
.sheet[hidden], .modal[hidden] { display: none; }
.sheet, .modal { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(119, 107, 94, 0.18); border: 0; }
.sheet-panel, .modal-panel {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  background: var(--card); border-radius: 16px; padding: 18px;
  border: 1px solid var(--line);
  animation: rise 220ms ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-panel { top: 8vh; bottom: auto; max-height: 82vh; overflow: auto; }
.sheet-handle { width: 36px; height: 4px; border-radius: 4px; background: var(--accent-soft); margin: 4px auto 10px; }
.sheet-link { width: 100%; border-radius: 12px; }
.avatar {
  display: grid; place-items: center; border-radius: 50%; overflow: hidden;
  background: var(--cream); color: var(--text); font-weight: 700;
}
.avatar.sm { width: 32px; height: 32px; font-size: 0.78rem; }
.avatar.md { width: 44px; height: 44px; }
.avatar.accent-2 { background: #F7EAEA; }
.nav-toggle {
  display: none; width: 42px; height: 42px; border: 0; border-radius: 12px;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.toast-stack { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab) + 12px); z-index: 40; display: grid; gap: 8px; }
.toast { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.toast.is-error { background: var(--danger-bg); color: var(--danger); }
.banner { background: var(--warn-bg); color: var(--text); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 0.92rem; color: var(--text-2); }
input, select, textarea {
  width: 100%; min-height: 48px; border: 0; border-radius: 14px;
  background: var(--bg); padding: 12px 14px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: 12px; padding: 10px 12px; }
.form-note { background: var(--cream); border-radius: 12px; padding: 10px 12px; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: auto; min-height: 0; }
.days { display: flex; gap: 6px; border: 0; padding: 0; }
.day { display: grid; place-items: center; }
.day input { position: absolute; opacity: 0; }
.day span {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; background: var(--cream);
}
.day input:checked + span { background: var(--accent); color: var(--on-accent); }
.timer-readout { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.04em; margin: 8px 0; }
.timer-controls, .chip-list, .people-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-list li { background: var(--cream); border-radius: 999px; padding: 6px 12px; }
.people-grid { display: grid; gap: 12px; margin-bottom: 14px; }
.bar { height: 8px; background: var(--cream); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar span { display: block; height: 100%; background: var(--accent); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.cal-label { text-align: center; color: var(--muted); font-size: 0.75rem; }
.cal-day {
  min-height: 52px; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 6px; text-align: left;
}
.cal-day.is-today { border-color: var(--accent); }
.cal-day.is-empty { background: transparent; border-color: transparent; }
.dots { display: flex; gap: 3px; margin-top: 6px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: none; }
.dots.has-habits i:nth-child(1), .dots.has-study i:nth-child(2), .dots.has-activities i:nth-child(3) { display: block; }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(460px, 100%); padding: 28px 22px; }
.setup-card { width: min(640px, 100%); }
.auth-card h1 { margin: 8px 0; }
.lede { color: var(--text-2); margin-bottom: 16px; }
.check-list li { padding: 4px 0 4px 16px; position: relative; }
.check-list li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); position: absolute; left: 0; top: 11px; }
.check-list li.bad::before { background: var(--danger); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-list li { padding: 7px 0; border-top: 1px solid var(--line); }
.goal-list li { padding: 12px 0; border-top: 1px solid var(--line); }
.filter-bar, .inline-form { justify-content: flex-start; margin: 8px 0 12px; }
.filter-bar select, .inline-form input { width: auto; min-width: 0; }
.schedule-wrap { overflow: auto; border: 1px solid var(--line); background: #fff; }
.schedule { border-collapse: collapse; min-width: 1100px; width: 100%; background: #fff; }
.schedule th, .schedule td { border: 1px solid #E9E0D8; height: 34px; padding: 2px 6px; font-size: 0.82rem; font-weight: 500; vertical-align: middle; }
.schedule thead th { background: #FBF9F5; text-align: center; position: sticky; top: 0; }
.schedule tbody th { position: sticky; left: 0; background: #FBF9F5; white-space: nowrap; width: 78px; }
.schedule thead th.is-today { background: #F7EAEA; }
.schedule td { cursor: pointer; min-width: 110px; }
.schedule td:hover { background: #FBF9F5; }
.slot-item { display: block; width: 100%; border: 0; background: transparent; text-align: left; color: var(--text); padding: 0; cursor: pointer; }
.slot-item.is-done { color: var(--text-2); text-decoration: line-through; }
.schedule-side { background: #fff; vertical-align: top; min-width: 220px; cursor: default; }
.schedule-meta { color: var(--text-2); margin: 0 0 10px; }
body[data-page="planner"] .content { max-width: none; }
.schedule-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.schedule { border-collapse: separate; border-spacing: 0; min-width: 920px; width: 100%; }
.schedule th, .schedule td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; vertical-align: top; font-weight: 500; }
.schedule thead th { position: sticky; top: 0; background: var(--cream); z-index: 2; text-align: left; min-width: 108px; }
.schedule tbody th { position: sticky; left: 0; background: var(--bg); z-index: 1; white-space: nowrap; color: var(--text-2); font-size: 0.82rem; }
.schedule thead th.is-today { background: var(--accent-soft); }
.schedule thead th span { display: block; color: var(--text-2); font-size: 0.78rem; }
.schedule-side { min-width: 220px; background: var(--card-2); }
.slot-item, .slot-add { display: block; width: 100%; border: 0; border-radius: 8px; text-align: left; cursor: pointer; }
.slot-item { background: var(--accent-soft); color: var(--text); padding: 6px 8px; margin-bottom: 4px; }
.slot-item.is-done { color: var(--text-2); text-decoration: line-through; }
.slot-add { background: transparent; color: var(--muted); min-height: 28px; }
.slot-add:hover { background: var(--cream); color: var(--text); }
@media (min-width: 768px) {
  .schedule { min-width: 1080px; }
  .schedule thead th { min-width: 120px; }
}

@media (min-width: 768px) and (max-width: 1099px) {
  .sidebar { display: flex; width: 84px; padding: 18px 10px; }
  .brand { justify-content: center; padding: 4px; }
  .brand-name, .nav-link span, .side-user div { display: none; }
  .nav-link { justify-content: center; min-height: 46px; padding: 0; }
  .side-user { justify-content: center; padding: 8px; }
  .main-column { margin-left: 84px; transition: margin-left 200ms ease; }
  .tabbar, .brand-mobile { display: none; }
  .nav-toggle { display: inline-grid; place-items: center; }
  .topbar { padding: 18px 28px 0; gap: 12px; justify-content: flex-start; }
  .topbar-user { margin-left: auto; }
  .content { padding: 12px 28px 40px; max-width: none; }
  .stat-grid, .split-panels, .people-grid { grid-template-columns: 1fr 1fr; }
  .calendar { gap: 8px; }
  .cal-day { min-height: 78px; font-size: 1rem; }
  .timer-readout { font-size: 3.2rem; }
  .toast-stack { left: auto; right: 28px; bottom: 24px; width: 320px; }
  body.nav-open .sidebar { width: 232px; }
  body.nav-open .brand { justify-content: flex-start; }
  body.nav-open .brand-name, body.nav-open .nav-link span, body.nav-open .side-user div { display: block; }
  body.nav-open .nav-link { justify-content: flex-start; padding: 0 12px; }
  body.nav-open .side-user { justify-content: flex-start; }
  body.nav-open .main-column { margin-left: 232px; }
}
@media (min-width: 1100px) {
  .sidebar { display: flex; }
  .main-column { margin-left: var(--sidebar); }
  .brand-mobile, .tabbar, .nav-toggle { display: none; }
  .content { padding: 18px 32px 48px; max-width: 1040px; }
  .toast-stack { left: auto; right: 32px; bottom: 24px; width: 320px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid.compact { grid-template-columns: repeat(4, 1fr); }
  .split-panels, .people-grid { grid-template-columns: 1fr 1fr; }
  .modal-panel { left: 50%; right: auto; width: min(480px, calc(100% - 48px)); transform: translateX(-50%); }
  .cal-day { min-height: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

[data-theme="mono"] {
  --bg: #0E0E0E;
  --bg-2: #141414;
  --card: #1A1A1A;
  --card-2: #111111;
  --cream: #242424;
  --line: #2E2E2E;
  --accent: #F4F4F4;
  --accent-soft: #8D8D8D;
  --text: #F7F7F7;
  --text-2: #BDBDBD;
  --muted: #8A8A8A;
  --warn: #E4E4E4;
  --warn-bg: #262626;
  --danger: #F0F0F0;
  --danger-bg: #2A2A2A;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  --on-accent: #111111;
}
[data-theme="mono"] .tabbar, [data-theme="mono"] .sidebar { background: rgba(20, 20, 20, 0.82); }
[data-theme="mono"] .avatar.accent-2 { background: #2A2A2A; color: #F7F7F7; }
[data-theme="mono"] .banner { color: #F0F0F0; }
.theme-choices { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.theme-choice { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.theme-choice input { width: auto; min-height: 0; }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); }
.swatch-warm { background: linear-gradient(135deg, #FBF9F5 50%, #E9D0D0 50%); }
.swatch-mono { background: linear-gradient(135deg, #0E0E0E 50%, #F4F4F4 50%); }
