:root {
  color-scheme: light;
  --bg: #f7fbf9;
  --panel: #ffffff;
  --ink: #252629;
  --muted: #74777b;
  --line: #e8eceb;
  --coral: #ff7f88;
  --coral-soft: #fff1f2;
  --mint: #60d2b8;
  --mint-dark: #159779;
  --mint-soft: #e8faf5;
  --sky: #72b9ed;
  --sky-soft: #eef8ff;
  --butter: #ffd667;
  --butter-soft: #fff9e7;
  --danger: #d04b57;
  --shadow: 0 14px 36px rgba(78, 108, 101, 0.12);
  --soft-shadow: 0 8px 22px rgba(78, 108, 101, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Text", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus {
  outline: none;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(54, 191, 158, 0.42);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 14px calc(env(safe-area-inset-bottom) + 100px);
}

.topbar,
.section-heading,
.time-row,
.data-actions,
.chart-heading,
.chart-title-row,
.range-toggle,
.chart-legend {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  min-height: 76px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.topbar > div {
  position: relative;
}

.eyebrow,
.panel-label,
.stat-card span,
label span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 40px;
  line-height: 1;
  font-weight: 880;
}

h2 {
  font-size: 19px;
}

.title-spark,
.title-spark::before {
  position: absolute;
  width: 6px;
  height: 18px;
  border-radius: 6px;
  background: var(--coral);
  content: "";
}

.title-spark {
  top: 18px;
  right: -23px;
  transform: rotate(15deg);
}

.title-spark::before {
  top: 8px;
  left: 12px;
  height: 13px;
  transform: rotate(45deg);
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #303235;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(82, 126, 115, 0.15), inset 0 -2px 0 rgba(95, 210, 184, 0.12);
  font-size: 20px;
  font-weight: 850;
}

.today-panel,
.entry-card,
.history-section,
.chart-panel {
  border: 1px solid rgba(232, 236, 235, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.today-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
}

.today-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.today-date {
  margin: 6px 0 0;
  font-size: 23px;
  font-weight: 850;
  white-space: nowrap;
}

.today-date::after {
  display: block;
  width: 58px;
  height: 6px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--coral);
  opacity: 0.48;
  content: "";
}

.mood-line {
  margin: 12px 0 0;
  color: var(--mint-dark);
  font-size: 12px;
  font-weight: 750;
}

.clock-mascot {
  align-self: center;
  width: 122px;
  max-width: 100%;
  filter: drop-shadow(0 9px 10px rgba(69, 184, 158, 0.16));
  animation: mascot-breathe 3.6s ease-in-out infinite;
}

.quick-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.primary-action,
.secondary-action {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  min-width: 0;
  min-height: 136px;
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 26px;
  padding: 12px 8px 11px;
  overflow: hidden;
  isolation: isolate;
  box-shadow: inset 0 5px 8px rgba(255, 255, 255, 0.54), inset 0 -9px 18px rgba(137, 64, 75, 0.1), 0 10px 20px rgba(77, 101, 96, 0.15);
  transition: transform 160ms ease, filter 160ms ease;
}

.primary-action::before,
.secondary-action::before {
  position: absolute;
  top: 10px;
  left: 16px;
  width: 44%;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.46);
  filter: blur(1px);
  content: "";
  transform: rotate(-8deg);
  z-index: -1;
}

.primary-action {
  color: #fff;
  background: linear-gradient(155deg, #ff9aa2 0%, #ff717d 74%, #f96070 100%);
}

.secondary-action {
  color: #087d65;
  background: linear-gradient(155deg, #bff7e8 0%, #72dfc4 72%, #54c9ad 100%);
  box-shadow: inset 0 5px 8px rgba(255, 255, 255, 0.62), inset 0 -9px 18px rgba(24, 126, 101, 0.11), 0 10px 20px rgba(77, 101, 96, 0.15);
}

.primary-action:active,
.secondary-action:active,
.tab-button:active {
  transform: scale(0.97);
}

.primary-action.is-done,
.secondary-action.is-done {
  filter: saturate(0.78);
}

.primary-action img,
.secondary-action img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(54, 68, 65, 0.14));
}

.action-label {
  margin-top: 3px;
  font-size: 19px;
  font-weight: 850;
  text-shadow: 0 1px 2px rgba(41, 55, 52, 0.14);
}

.action-note {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.76;
}

.action-wait {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 136px;
  border: 1px solid #dceee9;
  border-radius: 26px;
  color: var(--muted);
  background: linear-gradient(155deg, #fbfffe, #eef8f5);
  box-shadow: inset 0 5px 8px rgba(255, 255, 255, 0.7), 0 10px 20px rgba(77, 101, 96, 0.1);
  text-align: center;
}

.action-wait strong {
  color: var(--mint-dark);
  font-size: 18px;
}

.action-wait span {
  margin-top: 7px;
  font-size: 12px;
}

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

.stat-card {
  display: grid;
  align-content: start;
  min-width: 0;
  min-height: 132px;
  padding: 11px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.stat-card.start-stat {
  border-color: #ffd7da;
  background: var(--coral-soft);
}

.stat-card.end-stat {
  border-color: #ccefe8;
  background: var(--mint-soft);
}

.stat-card.duration-stat {
  border-color: #f7e9af;
  background: var(--butter-soft);
}

.stat-card img {
  width: 36px;
  height: 36px;
  margin-bottom: 5px;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(65, 89, 84, 0.1));
}

.stat-card span {
  min-height: 30px;
  font-size: 12px;
  line-height: 1.25;
}

.stat-card strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
  line-height: 1;
  white-space: nowrap;
}

.chart-panel {
  display: grid;
  gap: 12px;
  padding: 15px 13px 10px;
  margin-top: 12px;
}

.chart-heading,
.chart-title-row {
  justify-content: space-between;
  gap: 10px;
}

.chart-heading h2::after {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 0 8px 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 8px 5px 0 rgba(96, 210, 184, 0.48);
  content: "";
}

.chart-title-row.compact {
  justify-content: flex-start;
}

.range-toggle {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(72, 103, 96, 0.09);
}

.range-button {
  min-width: 54px;
  height: 34px;
  border-radius: 15px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 850;
}

.range-button.is-active {
  color: #fff;
  background: linear-gradient(145deg, #6ad8bd, #20ae8c);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.45), 0 4px 8px rgba(26, 157, 127, 0.2);
}

.chart-block {
  display: grid;
  gap: 9px;
}

.chart-block h3 {
  margin: 0;
  font-size: 14px;
}

.chart-title-row > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chart-legend {
  flex-wrap: wrap;
  gap: 11px;
}

.chart-legend span {
  color: var(--muted);
  font-size: 11px;
}

.legend-dot,
.legend-bar {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  vertical-align: -1px;
}

.legend-dot {
  border-radius: 50%;
}

.legend-bar {
  border-radius: 3px;
  background: #a7e8d8;
}

.legend-dot.start {
  background: var(--sky);
}

.legend-dot.end {
  background: #ff98a4;
}

.chart-canvas {
  min-height: 236px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.chart-canvas svg {
  display: block;
  width: 100%;
  height: 236px;
}

.combo-chart-canvas,
.combo-chart-canvas svg {
  min-height: 236px;
  height: 236px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 236px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.chart-grid-line {
  stroke: #edf1f0;
  stroke-width: 1;
}

.chart-axis-label,
.chart-axis-right-label,
.chart-x-label {
  fill: #85898d;
  font-size: 10px;
}

.chart-axis-right-label {
  fill: #df6f7a;
}

.chart-bar-soft {
  fill: rgba(169, 234, 217, 0.24);
}

.chart-bar {
  fill: #a3e6d5;
}

.chart-line-start,
.chart-line-end {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-start {
  stroke: var(--sky);
}

.chart-line-end {
  stroke: #ff98a4;
}

.chart-point-start {
  fill: var(--sky);
  stroke: #fff;
  stroke-width: 1.5;
}

.chart-point-end {
  fill: #ff98a4;
  stroke: #fff;
  stroke-width: 1.5;
}

.entry-card,
.history-section {
  padding: 17px;
  margin-top: 4px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.entry-form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
}

.time-row {
  gap: 10px;
}

.time-row label {
  flex: 1;
  min-width: 0;
}

input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfefd;
  outline: none;
}

input:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(96, 210, 184, 0.16);
}

.save-button,
.ghost-button,
.danger-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.save-button {
  width: 100%;
  color: #fff;
  background: linear-gradient(145deg, #73ddc3, #27ad8d);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.34), 0 8px 16px rgba(34, 167, 136, 0.2);
}

.ghost-button {
  color: #158b71;
  background: var(--mint-soft);
}

.danger-button {
  color: var(--danger);
  background: var(--coral-soft);
}

.data-actions {
  gap: 8px;
}

.empty-state {
  display: grid;
  gap: 7px;
  padding: 34px 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state::before {
  content: "☆";
  color: var(--butter);
  font-size: 38px;
  line-height: 1;
}

.empty-state strong {
  color: var(--ink);
}

.record-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 12px;
  border: 1px solid #dff1ec;
  border-radius: 8px;
  background: #f8fdfb;
}

.record-item:nth-child(even) {
  border-color: #ffe0e2;
  background: #fff8f8;
}

.record-date {
  margin: 0 0 6px;
  font-weight: 800;
}

.record-meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.record-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #158b71;
  background: var(--mint-soft);
  font-weight: 850;
}

.mini-button.delete {
  color: var(--danger);
  background: var(--coral-soft);
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid rgba(228, 235, 233, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 -12px 30px rgba(67, 98, 91, 0.1);
  backdrop-filter: blur(18px);
}

.tab-button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 62px;
  border-radius: 20px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  transition: transform 160ms ease, color 160ms ease, background 160ms ease;
}

.tab-button.is-active {
  color: #087b64;
  background: linear-gradient(145deg, #d2f9ef, #82e3ca);
  box-shadow: inset 0 3px 5px rgba(255, 255, 255, 0.68), 0 6px 14px rgba(46, 177, 144, 0.18);
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  left: 18px;
  z-index: 20;
  max-width: 420px;
  min-height: 46px;
  margin: 0 auto;
  border: 1px solid #ccefe6;
  border-radius: 20px;
  padding: 12px 18px;
  color: #0c705b;
  background: rgba(240, 255, 250, 0.96);
  box-shadow: 0 12px 30px rgba(53, 112, 97, 0.2);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

dialog {
  width: min(calc(100vw - 32px), 420px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(32, 38, 36, 0.38);
}

.dialog-card {
  padding: 20px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-card p {
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

@keyframes mascot-breathe {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-4px) rotate(1deg);
  }
}

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

  h1 {
    font-size: 36px;
  }

  .today-panel {
    grid-template-columns: minmax(0, 1fr) 92px;
    padding: 14px;
  }

  .today-date {
    font-size: 20px;
  }

  .primary-action,
  .secondary-action {
    min-height: 126px;
  }

  .action-label {
    font-size: 17px;
  }

  .stat-card {
    padding: 9px 7px;
  }

  .stat-card strong {
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
