:root {
  color-scheme: light dark;
  --bg: #eef4f2;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --text: #25231f;
  --muted: #66736f;
  --border: #d5dfdc;
  --accent: #226f63;
  --accent-strong: #174f47;
  --gold: #c99a2e;
  --rose: #b85b57;
  --danger: #a33b2f;
  --shadow: 0 20px 56px rgba(28, 62, 56, 0.12);
  --soft-shadow: 0 8px 28px rgba(28, 62, 56, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(145deg, rgba(34, 111, 99, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(201, 154, 46, 0.14), transparent 38%),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 16px;
}

.app-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 850;
  letter-spacing: 0;
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.nav-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 0.94rem;
  font-weight: 650;
}

.nav-button.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 7px 18px rgba(28, 62, 56, 0.11);
}

.storage-note,
.backup-warning {
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid #d8c36d;
  border-radius: var(--radius);
  color: #4f4420;
  background: #fff5c2;
  font-size: 0.92rem;
}

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

.screen {
  display: grid;
  gap: 18px;
}

.screen-header,
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.screen h1,
.calendar-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.screen h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.overline {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quote-panel {
  position: relative;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(34, 111, 99, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(34, 111, 99, 0.11), rgba(201, 154, 46, 0.10)),
    var(--surface);
  box-shadow: var(--soft-shadow);
}

.quote-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--accent), var(--gold), var(--rose));
}

.quote-panel blockquote {
  margin: 0;
  padding: 0 0 0 6px;
  color: var(--text);
  font-size: clamp(1.18rem, 4vw, 1.55rem);
  font-weight: 760;
  line-height: 1.18;
  letter-spacing: 0;
}

.quote-panel figcaption {
  padding-left: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.today-card,
.settings-group {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dry-button {
  width: 100%;
  min-height: 82px;
  border: 0;
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 14px 32px rgba(34, 111, 99, 0.22);
  font-size: 1.36rem;
  font-weight: 880;
}

.dry-button:active,
.button:active,
.step-button:active,
.day-cell:active {
  transform: translateY(1px);
}

.count-row {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 10px;
  align-items: stretch;
}

.step-button,
.icon-button {
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-soft);
  font-size: 1.3rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(28, 62, 56, 0.05);
}

.icon-button {
  width: 48px;
  min-height: 44px;
  overflow: hidden;
  text-indent: -999px;
  position: relative;
}

.icon-button::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-indent: 0;
}

.icon-button:first-child::after {
  content: "<";
}

.icon-button:last-child::after {
  content: ">";
}

.count-input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(34, 111, 99, 0.25);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-soft);
  text-align: center;
  font-size: 2.2rem;
  font-weight: 850;
}

.note-input {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
  background: var(--surface-soft);
  line-height: 1.4;
}

.button {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 750;
}

.button.primary {
  border-color: var(--accent);
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.button.secondary {
  color: var(--accent-strong);
}

.button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.save-button {
  width: 100%;
}

.save-status {
  min-height: 20px;
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat,
.mini-stat {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.stat span,
.mini-stat span,
.quiet {
  color: var(--muted);
  font-size: 0.84rem;
}

.stat strong,
.mini-stat strong {
  font-size: 1.3rem;
}

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

.weekday {
  padding: 4px 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.day-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.96rem;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(28, 62, 56, 0.05);
}

.day-cell.outside {
  color: #aaa49a;
  background: rgba(255, 255, 255, 0.42);
}

.day-cell.today {
  border-color: var(--text);
}

.drink-dot {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 7px;
  height: 7px;
  border-radius: 99px;
  transform: translateX(-50%);
}

.drink-dot.dry {
  background: #2f8f62;
}

.drink-dot.low {
  background: #d5aa2b;
}

.drink-dot.medium {
  background: #d97b2b;
}

.drink-dot.high {
  background: #c94737;
}

.field-label,
.file-label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.target-input {
  width: 120px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 750;
}

.quiet {
  margin: 0;
  line-height: 1.45;
}

.text-button {
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  font-weight: 800;
}

.import-panel {
  display: grid;
  gap: 12px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.conflict-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.error-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid #e5a39a;
  border-radius: var(--radius);
  color: #5f1f18;
  background: #ffe7e3;
  box-shadow: var(--shadow);
}

.confetti-piece {
  position: fixed;
  z-index: 20;
  width: 6px;
  height: 10px;
  border-radius: 2px;
  background: #d7b640;
  pointer-events: none;
  animation: confetti 600ms ease-out forwards;
}

.confetti-piece:nth-child(3n) {
  background: #4f8d65;
}

.confetti-piece:nth-child(4n) {
  background: #d9762e;
}

@keyframes confetti {
  to {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(180deg);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 12px;
  }

  .summary-grid,
  .import-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .screen h1,
  .calendar-header h1 {
    font-size: 1.45rem;
  }

  .today-card,
  .settings-group {
    padding: 14px;
  }

  .day-cell {
    font-size: 0.82rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151c1d;
    --surface: #202929;
    --surface-soft: #172121;
    --text: #f1f7f4;
    --muted: #a8b8b2;
    --border: #344846;
    --accent: #61b897;
    --accent-strong: #88d7b7;
    --gold: #d7b353;
    --rose: #d27a74;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
    --soft-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  }

  .app-nav,
  .step-button,
  .icon-button,
  .count-input,
  .note-input,
  .button,
  .target-input {
    background: var(--surface-soft);
  }

  .quote-panel {
    background:
      linear-gradient(135deg, rgba(97, 184, 151, 0.12), rgba(215, 179, 83, 0.10)),
      var(--surface);
  }

  .day-cell {
    background: #202929;
  }

  .storage-note,
  .backup-warning {
    color: #f4e6a3;
    background: #393116;
    border-color: #68591d;
  }
}
