/* ============================================================
   Time Tracker — Light, Clean, Smart
   ============================================================ */

:root {
  --bg: #fafbfc;
  --bg-card: #ffffff;
  --bg-soft: #f5f7fa;
  --bg-soft-2: #eef1f5;
  --bg-input: #ffffff;
  --bg-hover: #f3f5f8;

  --line: #e5e8ed;
  --line-strong: #d6dae0;
  --line-soft: #f0f2f5;

  --text: #0f1729;
  --text-2: #2c3444;
  --text-mid: #5c6478;
  --text-mute: #8a92a3;
  --text-faint: #b6bbc6;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-line: #c8d6f5;

  --english: #2563eb;
  --work: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --good: #059669;
  --pink: #db2777;
  --purple: #7c3aed;

  --shadow-xs: 0 1px 2px rgba(15,23,41,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,41,.06), 0 1px 2px rgba(15,23,41,.04);
  --shadow-md: 0 4px 12px rgba(15,23,41,.06), 0 2px 4px rgba(15,23,41,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,41,.08), 0 4px 8px rgba(15,23,41,.04);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --mono: 'SF Mono', 'JetBrains Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', 'Hiragino Sans', 'Noto Sans JP', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ===================== Lock Screen ===================== */
.lock-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lock-screen.unlocked {
  display: none;
}
.lock-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.lock-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: var(--text);
  color: #fff;
  margin: 0 auto 18px;
}
.lock-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.lock-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin: 0 0 24px;
}
.lock-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lock-form.hidden { display: none; }
.lock-form input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.lock-form input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15,23,41,.06);
}
.lock-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}
.lock-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.lock-forgot {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 12px;
  margin-top: 18px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: var(--sans);
}
.lock-forgot:hover { color: var(--text); }
.lock-recovery {
  margin-top: 18px;
}
.lock-recovery-q {
  margin: 0 0 12px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.lock-recovery input {
  letter-spacing: normal;
  font-family: var(--sans);
}

/* ===================== Top Bar ===================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--text);
  color: #fff;
}
.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.folder-info {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mid);
  padding: 5px 9px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
}
.live-dot.watching { background: var(--good); }
.live-dot.error { background: var(--danger); }
.live-dot.saving { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.today-pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-mid);
  border-radius: 999px;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ===================== Buttons ===================== */
.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 7px 14px;
  cursor: pointer;
  transition: all .14s ease;
  background: var(--bg-card);
  color: var(--text);
  letter-spacing: -0.005em;
}
.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.primary-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost-btn:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.danger-btn { background: #fff; border: 1px solid #fecaca; color: var(--danger); }
.danger-btn:hover { background: #fef2f2; }
.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--text-mid);
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }

/* ===================== View Tabs ===================== */
.view-tabs {
  display: flex;
  gap: 2px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
  overflow-x: auto;
}
.view-tab {
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .12s ease;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}

/* ===================== Layout ===================== */
main {
  padding: 28px 32px 80px;
  max-width: 1500px;
  margin: 0 auto;
}
.view-section { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

/* ===================== Hero ===================== */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 48px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  margin-bottom: 14px;
  text-transform: uppercase;
}
.hero-fraction {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.hero-numer {
  font-family: var(--mono);
  font-size: 76px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.04em;
}
.hero-slash {
  font-family: var(--mono);
  font-size: 48px;
  color: var(--text-faint);
  font-weight: 300;
}
.hero-denom {
  font-family: var(--mono);
  font-size: 38px;
  color: var(--text-mute);
  font-weight: 500;
}
.hero-unit {
  font-size: 18px;
  color: var(--text-mute);
  font-weight: 500;
  margin-left: 4px;
}
.hero-meta {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.hero-percent {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.hero-remaining {
  font-size: 13px;
  color: var(--text-mid);
}
.hero-progress { margin-top: 4px; }
.hero-progress-bar {
  position: relative;
  height: 8px;
  background: var(--bg-soft-2);
  border-radius: 999px;
  overflow: visible;
}
.hero-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--text);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.hero-progress-marker {
  position: absolute;
  top: -6px;
  width: 2px;
  height: 20px;
  background: var(--warn);
  border-radius: 1px;
}
.hero-progress-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  margin-top: 10px;
  letter-spacing: 0.02em;
}
.hero-progress-plan {
  color: var(--warn);
  font-weight: 500;
}

/* Ring */
.hero-right { position: relative; }
.ring-wrap {
  width: 180px;
  height: 180px;
  position: relative;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-soft-2); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--text);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 540.35;
  stroke-dashoffset: 540.35;
  transition: stroke-dashoffset .8s cubic-bezier(.4,0,.2,1);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
.ring-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  text-transform: uppercase;
}
.ring-date {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 2px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.ring-days {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
}

/* ===================== Countdown Row ===================== */
.countdown-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.countdown-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.countdown-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--cd-color, var(--text));
  opacity: 0.85;
}
.countdown-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.countdown-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.countdown-target {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
}
.countdown-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 4px;
}
.countdown-num {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}
.countdown-num-unit {
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
}
.countdown-bizdays {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
  margin-left: 8px;
  letter-spacing: -0.01em;
}
.countdown-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mid);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.countdown-sub-num { color: var(--text); font-weight: 600; }
.cd-clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.countdown-progress {
  height: 3px;
  background: var(--bg-soft-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.countdown-progress-fill {
  height: 100%;
  background: var(--cd-color, var(--text));
  opacity: 0.85;
  border-radius: 999px;
  transition: width .4s ease;
}

@media (max-width: 1100px) {
  .countdown-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .countdown-row { grid-template-columns: 1fr; }
}

/* ===================== KPI Row ===================== */
.kpi-row,
.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--cat-color, var(--accent));
  opacity: 0.85;
}
.kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.kpi-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-mid);
  margin-top: 4px;
}

/* ===================== Panels ===================== */
.dashboard-grid,
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel-wide { grid-column: 1 / -1; }
.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 12px;
}
.panel h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.panel-sub {
  font-size: 12px;
  color: var(--text-mute);
  margin: 3px 0 0;
}

/* ===================== Category Progress ===================== */
.cat-progress-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cat-prog {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  align-items: center;
}
.cat-prog-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.cat-prog-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--cat-color);
}
.cat-prog-fixed {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.cat-prog-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
  white-space: nowrap;
}
.cat-prog-value strong { color: var(--text); font-weight: 600; }
.cat-prog-bar {
  grid-column: 1 / -1;
  height: 6px;
  background: var(--bg-soft-2);
  border-radius: 999px;
  overflow: hidden;
}
.cat-prog-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--cat-color);
  transition: width .5s ease;
}

/* ===================== Pace Grid ===================== */
.pace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pace-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.pace-card.full { grid-column: 1 / -1; }
.pace-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.pace-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.pace-value-unit { font-size: 12px; color: var(--text-mute); margin-left: 3px; font-weight: 500; }
.pace-sub {
  font-size: 11px;
  color: var(--text-mid);
  margin-top: 4px;
}
.pace-sub.good { color: var(--good); }
.pace-sub.warn { color: var(--warn); }
.pace-sub.danger { color: var(--danger); }

/* ===================== Charts ===================== */
.chart-wrap {
  height: 280px;
  position: relative;
}
.chart-wrap.small { height: 220px; }
.metric-toggle,
.cal-mode-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}
.metric-btn,
.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  border-radius: 4px;
  transition: all .12s ease;
}
.metric-btn:hover,
.mode-btn:hover { color: var(--text); }
.metric-btn.active,
.mode-btn.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ===================== Calendar ===================== */
.cal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.cal-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cal-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cal-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
  color: var(--text);
  letter-spacing: -0.01em;
}
.cal-month-wrap {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  transition: all .12s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cal-cell:hover {
  border-color: var(--text-faint);
  background: var(--bg-soft);
}
.cal-cell.outside { opacity: 0.45; background: var(--bg-soft); }
.cal-cell.outside .cal-cell-date { color: var(--text-faint); }
.cal-cell.today {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}
.cal-cell-date {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.cal-cell-hours {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: auto;
  letter-spacing: -0.02em;
}
.cal-cell-bars {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  height: 3px;
}
.cal-cell-bars span {
  flex: 1;
  border-radius: 2px;
  background: var(--bg-soft-2);
}
.cal-cell-bars span.on { background: var(--cat-color, var(--accent)); }

/* Heatmap intensity (light theme — soft tints of the brand text color) */
.cal-cell.heat-0 { background: var(--bg-card); }
.cal-cell.heat-1 { background: #eaf0ff; border-color: #d6e1fa; }
.cal-cell.heat-2 { background: #c8d6f5; border-color: #a8bdec; }
.cal-cell.heat-3 { background: #93afe7; border-color: #7799d8; }
.cal-cell.heat-4 { background: #4a73d4; border-color: #3a5dc0; }
.cal-cell.heat-3 .cal-cell-date,
.cal-cell.heat-3 .cal-cell-hours,
.cal-cell.heat-4 .cal-cell-date,
.cal-cell.heat-4 .cal-cell-hours { color: #fff; }

/* Risk-based coloring (絶対値ベースで「ペース未達」を可視化) */
.cal-cell.risk-empty { background: var(--bg-card); }
.cal-cell.risk-severe {
  background: #fee2e2;
  border-color: #fca5a5;
}
.cal-cell.risk-severe .cal-cell-date,
.cal-cell.risk-severe .cal-cell-hours { color: #b91c1c; }
.cal-cell.risk-warn {
  background: #fef3c7;
  border-color: #fcd34d;
}
.cal-cell.risk-warn .cal-cell-date { color: #92400e; }
.cal-cell.risk-warn .cal-cell-hours { color: #b45309; }
.cal-cell.risk-mid {
  background: #fefce8;
  border-color: #fde68a;
}
.cal-cell.risk-mid .cal-cell-hours { color: #a16207; }
.cal-cell.risk-ok {
  background: #dcfce7;
  border-color: #86efac;
}
.cal-cell.risk-ok .cal-cell-date,
.cal-cell.risk-ok .cal-cell-hours { color: #15803d; }

/* Year grid */
.cal-year-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}
.cal-year-month {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
}
.cal-year-month h4 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 600;
}
.cal-year-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-year-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--bg-soft-2);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  padding: 1px;
  position: relative;
  line-height: 1;
}
.cal-year-cell:hover { transform: scale(1.5); z-index: 2; box-shadow: var(--shadow-md); }
.cal-year-day {
  font-size: 9px;
  color: var(--text-mute);
  font-weight: 500;
}
.cal-year-h {
  font-size: 10px;
  color: var(--text);
  font-weight: 700;
  margin-top: 1px;
}
/* On colored backgrounds, ensure readability */
.cal-year-cell.risk-severe .cal-year-day,
.cal-year-cell.risk-warn .cal-year-day,
.cal-year-cell.risk-mid .cal-year-day { color: rgba(15,23,41,0.55); }
.cal-year-cell.risk-severe .cal-year-h { color: #7f1d1d; }
.cal-year-cell.risk-warn .cal-year-h { color: #78350f; }
.cal-year-cell.risk-mid .cal-year-h { color: #713f12; }
.cal-year-cell.risk-ok .cal-year-day { color: rgba(255,255,255,0.85); }
.cal-year-cell.risk-ok .cal-year-h { color: #fff; }
/* Heat colors keep their existing styling but text needs visibility on dark heat-3/4 */
.cal-year-cell.heat-3 .cal-year-day,
.cal-year-cell.heat-4 .cal-year-day { color: rgba(255,255,255,0.7); }
.cal-year-cell.heat-3 .cal-year-h,
.cal-year-cell.heat-4 .cal-year-h { color: #fff; }
.cal-year-cell.heat-1 { background: #d6e1fa; }
.cal-year-cell.heat-2 { background: #93afe7; }
.cal-year-cell.heat-3 { background: #4a73d4; }
.cal-year-cell.heat-4 { background: var(--text); }
/* Risk version (year grid) */
.cal-year-cell.risk-empty { background: var(--bg-soft-2); }
.cal-year-cell.risk-severe { background: #fca5a5; }
.cal-year-cell.risk-warn { background: #fcd34d; }
.cal-year-cell.risk-mid { background: #fde68a; }
.cal-year-cell.risk-ok { background: #4ade80; }

/* Calendar legend */
.cal-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-mid);
}
.cal-legend-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-right: 4px;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cal-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  display: inline-block;
}
.cal-legend-dot.risk-empty { background: var(--bg-card); }
.cal-legend-dot.risk-severe { background: #fee2e2; border-color: #fca5a5; }
.cal-legend-dot.risk-warn { background: #fef3c7; border-color: #fcd34d; }
.cal-legend-dot.risk-mid { background: #fefce8; border-color: #fde68a; }
.cal-legend-dot.risk-ok { background: #dcfce7; border-color: #86efac; }

/* Detail Panel */
.cal-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,41,.32);
  backdrop-filter: blur(2px);
  z-index: 60;
}
.cal-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--bg-card);
  border-left: 1px solid var(--line);
  z-index: 61;
  display: flex;
  flex-direction: column;
  animation: slideIn .22s ease;
  box-shadow: var(--shadow-lg);
}
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.detail-header h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
}
.detail-summary {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.detail-total {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.detail-cats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-cat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.detail-cat-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-mid);
}
.detail-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.detail-cat-hours {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}
.detail-records {
  flex: 1;
  overflow-y: auto;
  padding: 12px 22px;
}
.detail-record {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .12s;
}
.detail-record:hover { border-color: var(--text-faint); box-shadow: var(--shadow-xs); }
.detail-record-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.detail-record-cat {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.detail-record-hours {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
}
.detail-record-meta {
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--mono);
}
.detail-record-note {
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 4px;
  line-height: 1.5;
}
.detail-empty {
  text-align: center;
  color: var(--text-mute);
  padding: 28px;
  font-size: 13px;
}
.detail-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

/* ===================== Input ===================== */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.input-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.input-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.input-form label.full { grid-column: 1 / -1; }
.input-form label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}
.input-form input,
.input-form select,
.input-form textarea {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.input-form input:focus,
.input-form select:focus,
.input-form textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15,23,41,.06);
}
.input-form input[type="color"] {
  height: 38px;
  padding: 3px;
  width: 56px;
  cursor: pointer;
}
.input-form textarea {
  resize: vertical;
  min-height: 64px;
  font-family: var(--sans);
  line-height: 1.5;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.time-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.time-input-row input { flex: 1; }
.quick-hour-presets {
  display: flex;
  gap: 3px;
}
.quick-hour-presets button {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text-mid);
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.quick-hour-presets button:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--text-faint);
}
.session-calc {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: var(--accent-soft);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  font-weight: 600;
}

/* Record list */
.list-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.week-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.week-nav.hidden { display: none; }
.ghost-btn-sm {
  padding: 5px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.week-nav .ghost-btn-sm {
  background: transparent;
  border-color: transparent;
}
.week-nav .ghost-btn-sm:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--line);
}
.week-nav .ghost-btn-sm:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.week-label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 0 8px;
  white-space: nowrap;
  min-width: 130px;
  text-align: center;
}
.list-controls input,
.list-controls select,
.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--sans);
}
.filter-select:focus,
.list-controls input:focus {
  outline: none;
  border-color: var(--text-faint);
}
.record-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 600px;
  overflow-y: auto;
}
.record-item {
  display: grid;
  grid-template-columns: 90px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: all .12s;
}
.record-item:hover { border-color: var(--text-faint); background: var(--bg-soft); }
.record-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 500;
}
.record-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  min-width: 0;
  font-size: 13px;
}
.record-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.record-cat-name {
  white-space: nowrap;
  color: var(--text);
}
.record-note {
  color: var(--text-mute);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.record-hours {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  letter-spacing: -0.01em;
}
.record-actions {
  display: flex;
  gap: 4px;
}
.record-actions button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 11px;
  transition: all .12s;
}
.record-actions button:hover { color: var(--text); border-color: var(--line); background: var(--bg-card); }
.record-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
}

/* ===================== Analytics ===================== */
.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.analytics-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.period-tabs {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}
.period-tab {
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: all .12s;
}
.period-tab:hover { color: var(--text); }
.period-tab.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ===================== Lifestyle ===================== */
.ls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.ls-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.ls-sub { font-size: 12px; color: var(--text-mute); margin: 4px 0 0; }
.ls-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ls-date-input {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
}
.ls-toggle-section {
  margin-bottom: 18px;
}
.ls-toggle-section:last-of-type { margin-bottom: 8px; }
.ls-section-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-mid);
}
.ls-section-title.bad { color: #b45309; }
.ls-section-title.good { color: #15803d; }
.ls-section-title.sleep { color: #1e40af; }
.ls-section-hint {
  margin-left: 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-mute);
  letter-spacing: 0;
}
.ls-section-title.meals { color: #b45309; }

/* Meals */
.ls-meal-section { margin-bottom: 18px; }
.ls-meals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ls-meal-row {
  display: grid;
  grid-template-columns: 100px auto 1fr;
  gap: 12px;
  align-items: center;
}
.ls-meal-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.ls-meal-icon { font-size: 18px; }
.ls-meal-status {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.ls-meal-status button {
  background: transparent;
  border: none;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--sans);
  white-space: nowrap;
  transition: all .12s;
}
.ls-meal-status button:hover {
  color: var(--text);
  background: var(--bg-card);
}
.ls-meal-status button.active.none {
  background: var(--text-mute);
  color: #fff;
}
.ls-meal-status button.active.small {
  background: #fef3c7;
  color: #92400e;
}
.ls-meal-status button.active.normal {
  background: #dcfce7;
  color: #15803d;
}
.ls-meal-status button.active.over {
  background: #fee2e2;
  color: #b91c1c;
}
.ls-meal-memo {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--sans);
  width: 100%;
}
.ls-meal-memo:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15,23,41,.06);
}

@media (max-width: 720px) {
  .ls-meal-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Sleep section */
.ls-sleep-section { margin-bottom: 18px; }
.ls-sleep-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ls-sleep-input {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  width: 90px;
  text-align: center;
  transition: all .2s;
}
.ls-sleep-input.severe { background: #fee2e2; border-color: #dc2626; color: #991b1b; }
.ls-sleep-input.warn { background: #fef3c7; border-color: #d97706; color: #92400e; }
.ls-sleep-input.good { background: #dbeafe; border-color: #2563eb; color: #1e40af; }
.ls-sleep-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(15,23,41,.06); }
.ls-sleep-unit {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-mute);
  margin-left: -6px;
}
.ls-sleep-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.ls-sleep-presets button {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  color: var(--text-mid);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  min-width: 38px;
}
.ls-sleep-presets button:hover { background: var(--bg-soft); border-color: var(--text-faint); }
.ls-sleep-presets button.active.severe { background: #fee2e2; border-color: #dc2626; color: #991b1b; }
.ls-sleep-presets button.active.warn { background: #fef3c7; border-color: #d97706; color: #92400e; }
.ls-sleep-presets button.active.good { background: #dbeafe; border-color: #2563eb; color: #1e40af; }
.ls-sleep-clear {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-mute);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}
.ls-sleep-clear:hover { background: var(--bg-soft); color: var(--text); }
.ls-sleep-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  font-family: var(--mono);
}
.ls-leg.severe { color: #b91c1c; }
.ls-leg.warn { color: #92400e; }
.ls-leg.good { color: #1e40af; }
.ls-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ls-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mute);
  font-family: var(--sans);
}
.ls-toggle-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.ls-toggle-btn .ls-icon { font-size: 18px; filter: grayscale(0.6); transition: filter .15s; }
.ls-toggle-btn.on .ls-icon { filter: none; }
.ls-toggle-btn.on.bad {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
  font-weight: 600;
}
.ls-toggle-btn.on.good {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
  font-weight: 600;
}
.ls-memo-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}
.ls-memo-wrap textarea {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  resize: vertical;
  line-height: 1.5;
}
.ls-memo-wrap textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15,23,41,.06);
}

/* Save row */
.ls-save-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.ls-save-status {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 500;
  margin-right: auto;
  font-family: var(--mono);
}
.ls-save-status.dirty {
  color: #d97706;
  font-weight: 600;
}

/* 30-day strip */
.ls-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 6px;
}
.ls-strip-day {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 6px;
  cursor: pointer;
  transition: all .12s;
  text-align: center;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ls-strip-day:hover { border-color: var(--text-faint); background: var(--bg-soft); }
.ls-strip-day.selected { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.ls-strip-day.today { border-color: var(--accent); }
.ls-strip-day.empty { opacity: 0.6; background: var(--bg-soft); }
.ls-strip-date {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}
.ls-strip-dow {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-mute);
  margin-top: 2px;
}
.ls-strip-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
}
.ls-strip-icons span {
  font-size: 11px;
}
.ls-strip-sleep {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-soft);
  color: var(--text-mute);
}
.ls-strip-sleep.severe { background: #fee2e2; color: #991b1b; }
.ls-strip-sleep.warn { background: #fef3c7; color: #92400e; }
.ls-strip-sleep.good { background: #dbeafe; color: #1e40af; }

/* Stats */
.ls-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.ls-stat-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.ls-stat-card .ls-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ls-stat-card .ls-stat-icon {
  font-size: 14px;
  margin-right: 5px;
}
.ls-stat-card .ls-stat-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.ls-stat-card .ls-stat-sub {
  font-size: 11px;
  color: var(--text-mid);
  margin-top: 4px;
}
.ls-stat-card.bad-stat .ls-stat-value { color: #b91c1c; }
.ls-stat-card.good-stat .ls-stat-value { color: #15803d; }
.ls-stat-card[data-stat] {
  cursor: pointer;
  transition: all .12s;
}
.ls-stat-card[data-stat]:hover {
  background: var(--bg-card);
  border-color: var(--text-faint);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}
.ls-strip-day { /* clickable cursor already set */ }

/* Detail modal body */
.ls-detail-body {
  padding: 22px;
  overflow-y: auto;
  max-height: 70vh;
}
.ls-detail-headline {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.ls-detail-section {
  margin-bottom: 16px;
}
.ls-detail-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ls-detail-subheader {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ls-detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 13px;
}
.ls-detail-item.bad { background: #fef2f2; color: #991b1b; }
.ls-detail-item.good { background: #f0fdf4; color: #15803d; }
.ls-detail-item.meal-over { background: #fee2e2; color: #b91c1c; }
.ls-detail-item.meal-normal { background: #dcfce7; color: #15803d; }
.ls-detail-item.meal-small { background: #fef3c7; color: #92400e; }
.ls-detail-item.meal-none { background: var(--bg-soft); color: var(--text-mid); }
.ls-detail-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
}
.ls-detail-value.sleep-severe { color: #991b1b; }
.ls-detail-value.sleep-warn { color: #92400e; }
.ls-detail-value.sleep-good { color: #1e40af; }
.ls-detail-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-left: auto;
}
.ls-detail-memo {
  font-size: 12px;
  color: var(--text-mid);
  margin-left: auto;
  font-style: italic;
}
.ls-detail-memo-text {
  background: var(--bg-soft);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.5;
}
.ls-detail-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ls-detail-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.ls-detail-list-date {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
  min-width: 100px;
}
.ls-detail-list-value {
  font-family: var(--mono);
  font-weight: 700;
  margin-left: auto;
}
.ls-detail-list-value.sleep-severe { color: #991b1b; }
.ls-detail-list-value.sleep-warn { color: #92400e; }
.ls-detail-list-value.sleep-good { color: #1e40af; }
.ls-detail-list-memo {
  font-size: 12px;
  color: var(--text-mid);
  font-style: italic;
}
.ls-detail-meal-counts {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
}
.ls-detail-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-mute);
  font-size: 12px;
}
.ls-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.ls-meal-stat-breakdown {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
}
.ls-mb { padding: 2px 6px; border-radius: 4px; }
.ls-mb.normal { background: #dcfce7; color: #15803d; }
.ls-mb.small { background: #fef3c7; color: #92400e; }
.ls-mb.over { background: #fee2e2; color: #b91c1c; }
.ls-mb.none { background: var(--bg-soft-2); color: var(--text-mute); }

/* ===================== Diary ===================== */
.diary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.diary-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.diary-sub { font-size: 12px; color: var(--text-mute); margin: 4px 0 0; }

.diary-composer-panel { background: var(--bg-card); }
.diary-now-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
  padding: 4px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.diary-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diary-composer textarea {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
  transition: border-color .12s, box-shadow .12s;
}
.diary-composer textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15,23,41,.06);
}
.diary-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.diary-mood-picker {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.diary-mood-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .12s;
  display: grid;
  place-items: center;
  filter: grayscale(0.5);
}
.diary-mood-btn:hover {
  background: var(--bg-card);
  filter: grayscale(0);
}
.diary-mood-btn.active {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  filter: grayscale(0);
  transform: scale(1.05);
}
.diary-meta-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.diary-meta-row input[type="text"]:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15,23,41,.06);
}
.diary-composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.diary-char-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}

/* Anger Control */
.anger-panel { background: var(--bg-card); }
.anger-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.anger-stat {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.anger-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.anger-stat-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.anger-stat-value-unit {
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
}
.anger-stat-trend {
  font-size: 10px;
  margin-top: 4px;
  font-family: var(--mono);
  font-weight: 600;
}
.anger-stat-trend.up { color: #b91c1c; }
.anger-stat-trend.down { color: #15803d; }
.anger-stat-trend.flat { color: var(--text-mute); }
.anger-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) {
  .anger-charts { grid-template-columns: 1fr; }
}
.anger-chart-block {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
}
.anger-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 14px;
}
.anger-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
}
.anger-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.anger-bar-graph {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}
.anger-bar-fill {
  width: 100%;
  background: #ef4444;
  border-radius: 3px 3px 0 0;
  transition: height .4s ease;
  min-height: 2px;
}
.anger-bar-fill.zero {
  background: var(--bg-soft-2);
}
.anger-bar-num {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
}
.anger-bar-lbl {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-mute);
}
#angerFilterBtn.active {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
  font-weight: 700;
}

/* Filters */
.diary-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.diary-filters input,
.diary-filters select {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--sans);
}

/* List */
.diary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 720px;
  overflow-y: auto;
  padding-right: 4px;
}
.diary-post {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .12s;
}
.diary-post:hover {
  border-color: var(--text-faint);
  box-shadow: var(--shadow-xs);
}
.diary-post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.diary-post-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 600;
}
.diary-post-mood { font-size: 16px; }
.diary-post-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}
.diary-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 1px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.diary-tag:hover { background: var(--accent); color: #fff; }
.diary-post-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.diary-post-actions {
  display: none;
  gap: 4px;
  margin-top: 8px;
  justify-content: flex-end;
}
.diary-post:hover .diary-post-actions {
  display: flex;
}
.diary-post-actions button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-mute);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 11px;
}
.diary-post-actions button:hover { color: var(--text); border-color: var(--text-faint); }

/* ===================== Posts ===================== */
.posts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.posts-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.posts-sub { font-size: 12px; color: var(--text-mute); margin: 4px 0 0; }
.posts-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.posts-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.post-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  font-family: var(--sans);
}
.post-toggle-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.post-toggle-btn .post-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-mid);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.post-toggle-btn.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.post-toggle-btn.on .post-badge {
  background: var(--cd-color, var(--accent));
  color: #fff;
}
.posts-diary-status {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-mid);
  font-family: var(--mono);
}
.posts-diary-status.has-diary {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
  font-weight: 600;
}

/* 30-day grid: rows = platforms, cols = days */
.posts-grid-wrap { overflow-x: auto; }
.posts-grid {
  display: grid;
  grid-template-columns: 110px repeat(30, 22px);
  gap: 3px;
  font-family: var(--mono);
  align-items: center;
  min-width: 800px;
}
.posts-grid-header {
  display: contents;
}
.posts-grid-header .posts-grid-label {
  font-size: 10px;
  color: var(--text-mute);
}
.posts-grid-header .posts-grid-day {
  width: 22px;
  text-align: center;
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: -0.02em;
}
.posts-grid-row {
  display: contents;
}
.posts-grid-name {
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  font-family: var(--sans);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
}
.posts-grid-name .post-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.posts-grid-cell {
  width: 22px;
  height: 22px;
  background: var(--bg-soft-2);
  border-radius: 3px;
  cursor: pointer;
  transition: transform .1s;
}
.posts-grid-cell.on { background: var(--cd-color, var(--accent)); }
.posts-grid-cell.today { box-shadow: 0 0 0 2px var(--accent); }
.posts-grid-cell:hover { transform: scale(1.5); z-index: 2; }

/* Stats */
.posts-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

/* Calendar cell post indicator */
.cal-cell-posts {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.cal-cell-post-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
}

/* ===================== Analytics: Category breakdown / pace ===================== */
.ana-cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ana-cat-row {
  display: grid;
  grid-template-columns: 1.2fr auto 70px 1fr;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ana-cat-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.ana-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.ana-cat-row-hours {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}
.ana-cat-row-pct {
  font-family: var(--mono);
  color: var(--text-mid);
  font-size: 12px;
  text-align: right;
  font-weight: 600;
}
.ana-cat-row-bar {
  height: 6px;
  background: var(--bg-soft-2);
  border-radius: 999px;
  overflow: hidden;
}
.ana-cat-row-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
}

.ana-cat-pace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}
.ana-cat-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.ana-cat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--cat-color, var(--accent));
}
.ana-cat-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ana-cat-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.ana-cat-progress { margin-bottom: 12px; }
.ana-cat-progress-text {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--text-mid);
}
.ana-cat-progress-text strong { color: var(--text); }
.ana-cat-pct {
  font-weight: 700;
  color: var(--text);
}
.ana-cat-pace-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.ana-cat-pace-item {
  flex: 1;
  min-width: 80px;
}
.ana-cat-pace-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ana-cat-pace-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.ana-cat-pace-status {
  font-family: var(--mono);
  font-size: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ana-cat-pace-status.status-good { background: #dcfce7; color: #15803d; }
.ana-cat-pace-status.status-warn { background: #fef3c7; color: #92400e; }
.ana-cat-pace-status.status-severe { background: #fee2e2; color: #b91c1c; }
.ana-cat-pace-status.status-done { background: #dbeafe; color: #1e40af; }

/* ===================== Tasks ===================== */
.tasks-link-status {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tasks-link-status.linked {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}
.tasks-link-status.warn {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}
.tasks-link-status.none {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.tasks-link-status .h-status-pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.tasks-link-status.linked .h-status-pill { background: #dcfce7; color: #15803d; }
.tasks-link-status.warn .h-status-pill { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.tasks-link-status.none .h-status-pill { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }


.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.tasks-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.tasks-sub { font-size: 12px; color: var(--text-mute); margin: 4px 0 0; }
.tasks-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.tasks-controls input,
.tasks-controls select {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
}
.tasks-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.task-origin-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.task-origin-badge.tracker { background: var(--bg-soft); color: var(--text-mid); }
.task-origin-badge.synced { background: var(--accent-soft); color: var(--accent); }
.task-origin-badge.goal { background: #f0fdf4; color: #15803d; }
.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .12s;
}
.task-item:hover {
  border-color: var(--text-faint);
  background: var(--bg-soft);
}
.task-item.completed {
  opacity: 0.55;
}
.task-item.overdue {
  border-color: #fca5a5;
  background: #fff1f1;
}
.task-status-pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.task-status-pill.s-active { background: #dbeafe; color: #1e40af; }
.task-status-pill.s-done { background: #dcfce7; color: #15803d; }
.task-status-pill.s-paused { background: #fef3c7; color: #92400e; }
.task-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.task-meta {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 2px;
  font-family: var(--mono);
}
.task-due {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 600;
  white-space: nowrap;
}
.task-due.overdue { color: #b91c1c; }
.task-due.soon { color: #d97706; }
.task-link-icon {
  color: var(--text-mute);
  font-size: 14px;
}
.task-link-icon:hover { color: var(--accent); }

.task-complete-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg-card);
  color: var(--text-mute);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .12s;
}
.task-complete-btn:hover {
  border-color: #15803d;
  color: #15803d;
  background: #f0fdf4;
}
.task-complete-btn.is-done {
  border-color: #15803d;
  background: #dcfce7;
  color: #15803d;
}
.task-complete-btn.is-done:hover {
  border-color: #92400e;
  background: #fef3c7;
  color: #92400e;
}
.task-complete-btn.placeholder {
  border: none;
  background: transparent;
  pointer-events: none;
}

/* ===================== Settings ===================== */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cat-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 11px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: all .12s;
}
.cat-row:hover { border-color: var(--text-faint); }
.cat-row-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.cat-row-name {
  font-weight: 500;
  color: var(--text);
}
.cat-row-type {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mid);
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 4px;
}
.cat-row-target {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
}
.cat-row-target strong { color: var(--text); font-weight: 600; }
.cat-row-fixed {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.maintenance-actions {
  display: flex;
  gap: 8px;
}
.settings-hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

/* Holiday master */
.holiday-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.holiday-status {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.holiday-status.linked {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}
.holiday-status .h-status-pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.holiday-status .h-status-pill.ok {
  background: #dcfce7;
  color: #15803d;
}
.holiday-status .h-status-pill.prompt {
  background: #fef3c7;
  color: #92400e;
}
.holiday-status .h-status-pill.none {
  background: var(--bg-card);
  color: var(--text-mute);
  border: 1px solid var(--line);
}
.holiday-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 480px;
  overflow-y: auto;
}
.holiday-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .12s;
}
.holiday-row:hover { border-color: var(--text-faint); }
.holiday-row .h-date {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.holiday-row .h-dow {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  margin-left: 4px;
}
.holiday-row .h-name { font-size: 13px; color: var(--text); font-weight: 500; }
.holiday-row .h-memo { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.holiday-row .h-actions {
  display: flex;
  gap: 4px;
}
.holiday-row .h-actions button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 11px;
}
.holiday-row .h-actions button:hover { color: var(--text); border-color: var(--line); background: var(--bg-soft); }

/* ===================== Modal ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,41,.32);
  backdrop-filter: blur(2px);
  z-index: 100;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 101;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.modal form,
.modal .setup-body {
  padding: 22px;
  overflow-y: auto;
}

/* Setup */
.setup-body { padding: 22px; }
.setup-intro {
  color: var(--text-mid);
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.6;
}
.setup-section-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin: 18px 0 8px;
  text-transform: uppercase;
  font-weight: 500;
}
.setup-cat-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.setup-cat-row input {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--sans);
}
.setup-cat-row input[type="color"] {
  width: 36px;
  padding: 2px;
  height: 32px;
}
.setup-cat-row .muted { color: var(--text-mute); font-size: 11px; }
.setup-note {
  color: var(--text-mute);
  font-size: 12px;
  margin: 12px 0;
}

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  border: 1px solid var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toastIn .22s ease;
}
.toast.error { background: var(--danger); border-color: var(--danger); color: #fff; }
.toast.success { background: var(--good); border-color: var(--good); color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translateX(-50%); }
}

/* ===================== Empty state ===================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-mute);
}
.empty-state .em-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}
.empty-state .em-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 4px;
}

/* ===================== Responsive ===================== */
@media (max-width: 1100px) {
  .dashboard-grid,
  .analytics-grid { grid-template-columns: 1fr; }
  .input-grid { grid-template-columns: 1fr; }
  .panel-wide { grid-column: auto; }
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .hero-right { display: flex; justify-content: center; }
}
@media (max-width: 720px) {
  main { padding: 18px; }
  .topbar { padding: 12px 18px; flex-wrap: wrap; gap: 10px; }
  .view-tabs { padding: 0 18px; }
  .hero { padding: 24px; }
  .hero-numer { font-size: 52px; }
  .hero-slash { font-size: 32px; }
  .hero-denom { font-size: 26px; }
  .form-row-2 { grid-template-columns: 1fr; }
  .record-item { grid-template-columns: 1fr auto; gap: 6px; }
  .record-item .record-cat,
  .record-item .record-note { grid-column: 1 / -1; }
  .cat-row { grid-template-columns: auto 1fr auto auto; }
  .cat-row-target,
  .cat-row-fixed { display: none; }
}

/* ============================================================
   PWA + Mobile responsive (hamburger drawer)
   ============================================================ */

/* 旧 XLSX フォルダピッカー UI は本番では非表示。
   コード自体は残っているのでローカル開発用に残すが、UI には出さない。 */
.legacy-hidden { display: none !important; }

/* ハンバーガーボタン: PC では非表示。モバイル時のみ display:inline-flex で出す */
.hamburger-btn {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  margin-right: 8px;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--bg-hover); }
.hamburger-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ドロワー背景。モバイル時に view-tabs.open と同時に表示 */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 41, 0.42);
  z-index: 90;
  animation: drawerBackdropIn 0.18s ease-out;
}
@keyframes drawerBackdropIn { from { opacity: 0; } to { opacity: 1; } }

/* iOS の safe-area-inset を尊重 (ノッチ・ホームインジケータ被り防止) */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  main { padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 24px)); }
}

/* ===== モバイルブレークポイント (<= 720px) ===== */
@media (max-width: 720px) {
  .hamburger-btn { display: inline-flex; }

  /* topbar は折り返さず、ハンバーガー + brand + 右側を 1 行に */
  .topbar {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: nowrap;
    min-height: 56px;
  }
  .brand { flex: 1; min-width: 0; }
  .brand-text { min-width: 0; }
  .brand-title { font-size: 14px; }
  .brand-sub { display: none; }   /* 表示スペース節約: dashboard 内に同情報あり */
  .topbar-right { gap: 6px; flex-shrink: 0; }
  .today-pill { font-size: 10px; padding: 4px 8px; }
  .user-pill { padding: 3px 6px 3px 10px; margin-left: 4px; font-size: 12px; gap: 6px; }
  .user-pill-name { max-width: 6em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-pill-logout { padding: 2px 8px; font-size: 11px; }

  /* nav-tabs をドロワー化 (左から滑り込む) */
  .view-tabs {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 78%;
    max-width: 320px;
    z-index: 100;
    background: var(--bg-card);
    border-right: 1px solid var(--line);
    border-bottom: none;
    flex-direction: column;
    align-items: stretch;
    padding: 64px 0 24px;
    gap: 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: 8px 0 24px -8px rgba(15, 23, 41, 0.18);
  }
  .view-tabs.open { transform: translateX(0); }
  .view-tab {
    padding: 14px 24px;
    border-bottom: none;
    border-left: 3px solid transparent;
    text-align: left;
    margin-bottom: 0;
    font-size: 14px;
    width: 100%;
  }
  .view-tab.active {
    border-bottom-color: transparent;
    border-left-color: var(--text);
    background: var(--bg-soft);
  }

  /* main 内のレイアウト調整: 既存ルールを補強 */
  main { padding: 16px 14px 80px; }

  /* hero/dashboard 内の主要文字をモバイル向けに少しスリムに */
  .hero { padding: 20px 16px; }
  .hero-fraction { flex-wrap: wrap; }

  /* ボタン群が並ぶ panel-header はモバイルでは縦 stack */
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* 入力フォーム: 横並びを縦に */
  .input-form .form-row-2 { grid-template-columns: 1fr; }

  /* テーブル/カード一覧の左右スクロール許可 (極端に狭い列に対する保険) */
  .records-list, .anger-charts { overflow-x: auto; }
}

/* PWA standalone モード (ホーム画面追加後) で、topbar の高さを少し下げる */
@media all and (display-mode: standalone) {
  .topbar { padding-top: max(10px, env(safe-area-inset-top, 0px)); }
}
