:root {
  --bg: #eff4f6;
  --bg-2: #dde9e5;
  --ink: #10201d;
  --muted: #4a5f59;
  --card: #ffffff;
  --line: #c8d6d1;
  --primary: #0b7a66;
  --primary-soft: #d2f1e8;
  --accent: #e4a11b;
  --accent-soft: #fff0cf;
  --danger: #b93a3a;
  --surface-1: #ffffff;
  --surface-2: #f4fbf8;
  --surface-soft: #f2f8f4;
  --surface-chip: #334f47;
  --distance-text: #236999;
  --distance-bg: #d9ecfb;
}

:root[data-theme="dark"] {
  --bg: #0f1716;
  --bg-2: #172320;
  --ink: #e6f2ee;
  --muted: #9ab6ad;
  --card: #1a2824;
  --line: #2f4540;
  --primary: #28b18e;
  --primary-soft: #203b34;
  --accent: #f3b239;
  --accent-soft: #3b3220;
  --danger: #ff8f8f;
  --surface-1: #1a2824;
  --surface-2: #16201d;
  --surface-soft: #15211e;
  --surface-chip: #3f6258;
  --distance-text: #85bef0;
  --distance-bg: #1f3442;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Zen Kaku Gothic New", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 8% 2%, #b9ddd0 0, transparent 24%),
    radial-gradient(circle at 95% 100%, #d5e6b0 0, transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.container {
  width: min(1160px, calc(100% - 26px));
  margin: 24px auto 60px;
  position: relative;
  z-index: 1;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--surface-1) 0%, var(--surface-2) 100%);
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
}

.hero h1 {
  margin: 4px 0 6px;
  font-size: clamp(1.55rem, 2.8vw, 2.25rem);
  line-height: 1.2;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.source-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.hero-status {
  min-width: 188px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface-soft);
}

.hero-status p {
  font-size: 0.8rem;
  margin: 0;
}

.hero-status strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  color: var(--primary);
}

.primary-btn,
.ghost-btn,
.danger-btn {
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 12px;
}

.primary-btn {
  margin-top: 10px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--surface-1);
  color: var(--ink);
}

.danger-btn {
  border: 1px solid #e7bcbc;
  background: #fff6f6;
  color: var(--danger);
}

.range-tabs {
  margin-top: 12px;
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-1) 72%, transparent);
  border: 1px solid var(--line);
}

.list-tabs {
  margin-top: 0;
  margin-bottom: 8px;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.summary-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.05fr 1.4fr;
  gap: 12px;
}

.insight-card,
.kpi-card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.insight-card {
  padding: 16px;
}

.insight-card h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.insight-card p {
  margin: 8px 0 10px;
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1.35;
}

.insight-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  padding: 14px;
}

.kpi-card h2 {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.kpi-card p {
  margin: 8px 0 0;
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--primary);
}

.panel {
  margin-top: 12px;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-panel canvas {
  min-height: 280px;
}

.week-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.week-kpi {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #fff, #f6fbf8);
}

.week-kpi h3 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.week-kpi p {
  margin: 6px 0 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
}

.controls {
  margin-bottom: 10px;
}

.date-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#date-filter {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  background: var(--surface-1);
}

#jump-today,
#clear-date,
#sort-order {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

#search {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
}

#search:focus {
  outline: 2px solid #a9d9cc;
  outline-offset: 1px;
}

.entry-list {
  display: grid;
  gap: 10px;
}

.entry {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
}

.entry h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.entry-section-title {
  margin: 8px 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}

.entry .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
}

.chip-step {
  color: var(--primary);
  background: var(--primary-soft);
}

.chip-distance {
  color: var(--distance-text);
  background: var(--distance-bg);
}

.chip-sleep {
  color: #9a6202;
  background: var(--accent-soft);
}

.chip-source {
  color: #fff;
  background: var(--surface-chip);
}

.note-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.entry details {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-1) 70%, transparent);
}

.entry details summary {
  cursor: pointer;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.entry details .note-list {
  padding: 0 14px 10px 28px;
}

.mini-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  z-index: 20;
  cursor: pointer;
}

.editor {
  border: none;
  padding: 0;
  width: min(760px, calc(100% - 20px));
  border-radius: 18px;
}

.editor::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.editor-form {
  margin: 0;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.editor-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.editor-sub {
  margin: 2px 0 -2px;
  font-size: 0.88rem;
  color: var(--muted);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.editor label {
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
}

.editor input,
.editor textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  color: var(--ink);
}

.editor-note {
  grid-column: 1 / -1;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lock-msg {
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 700;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.65;
}

.bg-shape-a {
  width: 240px;
  height: 240px;
  background: #79c6b0;
  top: -80px;
  left: -75px;
}

.bg-shape-b {
  width: 220px;
  height: 220px;
  background: #acd167;
  right: -70px;
  bottom: 40px;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .week-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .container {
    width: min(1160px, calc(100% - 18px));
    margin-top: 14px;
  }

  .editor {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }
}
