:root {
  color-scheme: light;
  --bg: #f3efe6;
  --card: rgba(255, 253, 248, 0.9);
  --card-solid: #fffdf8;
  --ink: #1f2924;
  --muted: #6c756f;
  --line: rgba(31, 41, 36, 0.12);
  --accent: #5e7568;
  --accent-dark: #3f554a;
  --accent-pale: #dfe8e1;
  --warm: #c79d6d;
  --danger: #9c5148;
  --shadow: 0 18px 50px rgba(40, 48, 43, 0.08);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.78), transparent 32%),
    radial-gradient(circle at 95% 12%, rgba(210, 224, 214, 0.46), transparent 28%),
    var(--bg);
}

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

button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(94, 117, 104, 0.22);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 28px;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.settings-button,
.icon-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

.settings-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.settings-button span {
  font-size: 20px;
  line-height: 1;
  transform: rotate(90deg);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  font-size: 22px;
}

.dashboard {
  display: grid;
  gap: 16px;
}

.insight-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.hero-card,
.panel,
.stat-card {
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.hero-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: linear-gradient(155deg, rgba(255, 253, 248, 0.97), rgba(244, 247, 242, 0.91));
  padding: 28px 32px 24px;
}

.hero-card::before,
.hero-card::after {
  position: absolute;
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.hero-card::before {
  right: -95px;
  top: -125px;
  width: 280px;
  height: 280px;
  background: rgba(199, 157, 109, 0.08);
}

.hero-card::after {
  bottom: -155px;
  left: -120px;
  width: 300px;
  height: 300px;
  background: rgba(94, 117, 104, 0.05);
}

.hero-copy {
  position: relative;
  z-index: 1;
  text-align: center;
}

.date-line {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 13px;
}

.hero-copy h2 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(23px, 3vw, 32px);
  font-weight: 500;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.hero-copy .subtle {
  margin: 8px 0 0;
}

.timer-wrap {
  position: relative;
  display: grid;
  width: min(68vw, 310px);
  aspect-ratio: 1;
  place-items: center;
  margin: 16px auto 10px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 10px 18px rgba(63, 85, 74, 0.08));
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 9;
}

.ring-track { stroke: rgba(94, 117, 104, 0.13); }

.ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s linear;
}

.timer-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.timer-state {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: clamp(50px, 8vw, 72px);
  font-weight: 450;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.timer-sound {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.preset-group {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  width: min(100%, 600px);
  margin: 0 auto;
  padding: 4px 0 10px;
}

.preset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  padding: 9px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.preset.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.preset:disabled {
  cursor: default;
  opacity: 0.55;
}

.primary-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  width: min(100%, 600px);
  margin: 0 auto;
}

.primary-actions .secondary-button {
  min-width: 124px;
}

.primary-button,
.secondary-button,
.danger-button {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 680;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.985);
}

.primary-button {
  background: var(--accent-dark);
  color: white;
}

.primary-button:disabled { opacity: 0.62; }

.secondary-button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
}

.danger-button {
  border-color: rgba(156, 81, 72, 0.17);
  background: rgba(156, 81, 72, 0.08);
  color: var(--danger);
}

.hidden { display: none !important; }

.microcopy {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.panel {
  min-width: 0;
  border-radius: var(--radius-lg);
  background: var(--card);
  padding: 18px;
}

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

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 17px;
}

.summary-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-pale);
  color: var(--accent-dark);
  padding: 6px 9px;
  font-size: 11px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  padding: 5px;
  font-size: 12px;
  font-weight: 700;
}

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

.heat-day {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid rgba(31, 41, 36, 0.025);
  border-radius: 5px;
  background: #ebe9e1;
  padding: 0;
  cursor: help;
}

.heat-day[data-level="1"],
.heatmap-legend i[data-level="1"] { background: #dce6df; }

.heat-day[data-level="2"],
.heatmap-legend i[data-level="2"] { background: #b9cbbf; }

.heat-day[data-level="3"],
.heatmap-legend i[data-level="3"] { background: #839f8e; }

.heat-day[data-level="4"],
.heatmap-legend i[data-level="4"] { background: #4f6c5c; }

.heat-day.today {
  box-shadow: 0 0 0 2px var(--warm);
}

.heat-day::after {
  position: absolute;
  right: 50%;
  bottom: calc(100% + 7px);
  z-index: 5;
  padding: 5px 7px;
  transform: translateX(50%);
  border-radius: 7px;
  background: #26332d;
  color: white;
  content: attr(data-label);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.heat-day:hover::after,
.heat-day:focus-visible::after {
  opacity: 1;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
}

.heatmap-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: #ebe9e1;
}

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

.stat-card {
  min-width: 0;
  border-radius: var(--radius-md);
  background: var(--card);
  padding: 13px 7px 12px;
  text-align: center;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.stat-card strong {
  display: block;
  overflow: hidden;
  margin: 2px 0 1px;
  font-size: clamp(21px, 3vw, 27px);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.records-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.records-panel .section-heading {
  flex: 0 0 auto;
  margin-bottom: 3px;
}

.empty-state {
  color: var(--muted);
  padding: 14px 0 8px;
  text-align: center;
}

.empty-state p {
  margin: 8px 0 0;
  font-size: 12px;
}

.empty-symbol {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 20px;
}

.session-list {
  display: grid;
  min-height: 0;
}

.session-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.session-item:first-child { border-top: 0; }

.session-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-pale);
  color: var(--accent-dark);
}

.session-main {
  min-width: 0;
}

.session-main strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-main span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item > div:last-child {
  display: flex;
  align-items: center;
}

.session-minutes {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  white-space: nowrap;
}

.delete-session {
  border: 0;
  background: transparent;
  color: #a7aaa7;
  padding: 6px 3px 6px 7px;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  padding: 14px 8px 0;
}

.field-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.field-inline select {
  min-width: 148px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-solid);
  color: var(--ink);
  padding: 9px 12px;
}

.volume-field input {
  width: min(60%, 240px);
  accent-color: var(--accent);
}

.dialog-card {
  width: min(calc(100% - 28px), 560px);
  max-height: min(90dvh, 760px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  background: #fffdf9;
  box-shadow: 0 30px 100px rgba(31, 41, 36, 0.2);
  color: var(--ink);
  padding: 0;
}

.dialog-card::backdrop {
  background: rgba(31, 41, 36, 0.38);
  backdrop-filter: blur(5px);
}

.dialog-card form {
  padding: 24px;
}

.dialog-heading h2 {
  margin: 5px 0 4px;
}

.feeling-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin: 20px 0;
}

.feeling-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.feeling-options span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  padding: 12px;
  text-align: center;
}

.feeling-options input:checked + span {
  border-color: var(--accent);
  background: var(--accent-pale);
  color: var(--accent-dark);
  font-weight: 650;
}

.field-stack {
  display: grid;
  gap: 7px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 13px;
}

.field-stack input,
.field-stack textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  padding: 12px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 9px;
  margin-top: 20px;
}

.compact-dialog {
  width: min(calc(100% - 28px), 430px);
}

.row-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.settings-list {
  display: grid;
  margin-top: 14px;
}

.sound-settings {
  display: grid;
  gap: 14px;
  margin-bottom: 2px;
  border-radius: 16px;
  background: rgba(223, 232, 225, 0.52);
  padding: 16px;
}

.setting-copy strong,
.setting-copy small,
.setting-row strong,
.setting-row small {
  display: block;
}

.setting-copy small,
.setting-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.setting-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.data-actions {
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.file-button {
  position: relative;
  overflow: hidden;
  text-align: center;
}

.file-button input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 99;
  max-width: calc(100vw - 28px);
  overflow: hidden;
  transform: translate(-50%, 24px);
  border-radius: 999px;
  background: #25342c;
  color: white;
  padding: 11px 15px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  text-overflow: ellipsis;
  transition: 0.22s ease;
  white-space: nowrap;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (min-width: 860px) {
  .dashboard {
    grid-template-columns: minmax(270px, 0.72fr) minmax(500px, 1.55fr);
    align-items: stretch;
  }

  .hero-card {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
    padding-right: clamp(32px, 5vw, 64px);
    padding-left: clamp(32px, 5vw, 64px);
  }

  .insight-column {
    grid-column: 1;
    grid-row: 1;
  }
}

@media (min-width: 860px) and (min-height: 700px) {
  body { overflow: hidden; }

  .app-shell {
    display: grid;
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .dashboard,
  .insight-column,
  .hero-card {
    min-height: 0;
  }

  .insight-column {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .records-panel {
    overflow: hidden;
  }

  .session-list {
    overflow: auto;
    scrollbar-color: rgba(94, 117, 104, 0.22) transparent;
    scrollbar-width: thin;
  }

  .timer-wrap {
    width: min(40vh, 330px);
  }
}

@media (max-width: 859px) {
  .app-shell {
    width: min(100%, 720px);
  }

  .hero-card {
    order: -1;
  }

  .records-panel {
    max-height: 360px;
  }

  .session-list {
    overflow: auto;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topbar {
    margin-bottom: 12px;
    padding: 0 4px;
  }

  .topbar h1 { font-size: 25px; }

  .hero-card {
    border-radius: 24px;
    padding: 22px 16px 18px;
  }

  .hero-copy h2 {
    font-size: 23px;
  }

  .timer-wrap {
    width: min(68vw, 270px);
    margin-top: 14px;
  }

  .timer-display {
    font-size: 52px;
  }

  .preset-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .primary-actions {
    grid-template-columns: 1fr;
  }

  .primary-actions .secondary-button {
    min-width: 0;
  }

  .panel {
    padding: 16px;
  }

  .heatmap { gap: 5px; }

  .dialog-card form {
    padding: 20px;
  }

  .sound-settings {
    padding: 14px;
  }

  .field-inline select {
    min-width: 138px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
