:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #eef3f9;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8e0eb;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #f59e0b;
  --rose: #dc2626;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(82px + var(--safe-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px;
  background: rgba(247, 248, 251, 0.94);
  border-bottom: 1px solid rgba(216, 224, 235, 0.75);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.42rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.main-content {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 14px 14px 22px;
}

.date-strip {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.date-strip input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.icon-button,
.date-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.primary-button,
.secondary-button,
.danger-button,
.mini-button {
  border-radius: var(--radius);
  font-weight: 750;
  letter-spacing: 0;
}

.primary-button {
  width: 100%;
  padding: 0 16px;
  background: var(--blue);
  color: white;
}

.secondary-button {
  padding: 0 16px;
  background: var(--surface-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger-button {
  padding: 0 16px;
  background: #fee2e2;
  color: #991b1b;
}

.mini-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.mini-button.is-done {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.score-band {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}

.score-dial {
  display: grid;
  place-items: center;
  min-height: 118px;
  border-radius: var(--radius);
  background: conic-gradient(var(--blue) var(--score-angle), #e5edf7 0);
  box-shadow: var(--shadow);
}

.score-dial-inner {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--surface);
}

.score-dial strong {
  display: block;
  font-size: 1.72rem;
  line-height: 1;
}

.score-dial span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

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

.metric {
  min-height: 55px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 1.05rem;
}

.panel {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.flat {
  box-shadow: none;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin-bottom: 0;
}

.section-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.focus-text {
  margin-bottom: 4px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
}

.muted {
  color: var(--muted);
}

.warning {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  background: #fff7ed;
  color: #7c2d12;
}

.impulse {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  background: #ecfdf5;
  color: #14532d;
}

.slider-list {
  display: grid;
  gap: 12px;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.slider-row output {
  color: var(--ink);
  font-weight: 850;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.task-list,
.routine-list,
.area-list,
.score-list,
.recommendation-list {
  display: grid;
  gap: 8px;
}

.task-item,
.routine-item,
.area-item,
.score-item,
.recommendation-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.task-main,
.routine-main,
.area-main,
.score-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.task-title,
.routine-title,
.area-title {
  margin-bottom: 3px;
  font-weight: 800;
  line-height: 1.25;
}

.task-meta,
.routine-meta,
.area-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: #334155;
  font-weight: 750;
}

.badge.growth {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge.maintenance {
  background: #dcfce7;
  color: #166534;
}

.task-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field label,
.field > span,
.settings-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.field input,
.field select,
.field textarea,
.settings-field input,
.settings-field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

.field textarea {
  min-height: 96px;
}

details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

summary {
  min-height: 44px;
  padding: 12px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 760;
}

.details-body {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
}

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

.progress-canvas {
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.heat-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eef2f7;
}

.heat-cell.today {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.area-score-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5edf7;
}

.area-score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.review-grid {
  display: grid;
  gap: 12px;
}

.quality-grid {
  display: grid;
  gap: 10px;
}

.quality-row {
  display: grid;
  grid-template-columns: 1fr 60px;
  gap: 10px;
  align-items: center;
}

.settings-grid {
  display: grid;
  gap: 12px;
}

.area-controls {
  display: grid;
  gap: 9px;
}

.area-controls-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  align-items: center;
}

.area-controls-row input[type="range"] {
  margin-top: 6px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(216, 224, 235, 0.9);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: 6px 2px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.nav-item.is-active {
  background: #eaf1ff;
  color: var(--blue);
}

.nav-icon {
  display: grid;
  place-items: center;
  height: 22px;
  min-width: 22px;
  font-size: 0.9rem;
  line-height: 1;
}

.tutorial {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: block;
  padding: 0;
  background: rgba(15, 23, 42, 0.44);
}

.tutorial[hidden] {
  display: none;
}

.tutorial-panel {
  position: absolute;
  bottom: 18px;
  left: 24px;
  width: calc(100vw - 48px);
  max-width: 430px;
  margin: 0 auto;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 22px 80px rgba(15, 23, 42, 0.24);
}

.tutorial-art {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 1.1fr;
  gap: 8px;
  height: 74px;
  margin-bottom: 16px;
}

.art-bar {
  align-self: end;
  border-radius: var(--radius);
}

.art-blue {
  height: 66px;
  background: #bfdbfe;
}

.art-green {
  height: 48px;
  background: #bbf7d0;
}

.art-amber {
  height: 58px;
  background: #fde68a;
}

.tutorial-step {
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.tutorial-panel p {
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tutorial-setup {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.tutorial-setup label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.tutorial-setup input,
.tutorial-setup select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tutorial-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(90px + var(--safe-bottom));
  left: 14px;
  z-index: 90;
  display: none;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #17202a;
  color: white;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 760;
}

.toast.is-visible {
  display: block;
}

@media (min-width: 720px) {
  .main-content {
    padding: 20px 22px 28px;
  }

  .today-grid,
  .plan-grid,
  .review-grid,
  .progress-grid,
  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
  }

  .wide {
    grid-column: 1 / -1;
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    width: min(620px, calc(100% - 28px));
    transform: translateX(50%);
    border: 1px solid rgba(216, 224, 235, 0.9);
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

@media (max-width: 370px) {
  .main-content {
    padding-inline: 10px;
  }

  .score-band {
    grid-template-columns: 1fr;
  }

  .score-dial {
    min-height: 104px;
  }

  .nav-item {
    font-size: 0.66rem;
  }
}
