:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --panel: #fffdf8;
  --ink: #18211f;
  --muted: #66706b;
  --line: #ded8cc;
  --accent: #1f7a5a;
  --accent-ink: #ffffff;
  --soft: #eaf3ee;
  --warn: #b7632d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(rgba(247, 244, 237, 0.93), rgba(247, 244, 237, 0.97)),
    radial-gradient(circle at 50% 0, rgba(31, 122, 90, 0.14), transparent 38%);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(24, 33, 31, 0.12);
}

.auth-card h1 {
  font-size: 28px;
}

.auth-card p {
  color: var(--muted);
}

.auth-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
}

.auth-remember {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.auth-remember input {
  width: 20px;
  min-height: 20px;
}

#authError {
  min-height: 18px;
  color: var(--warn);
  font-weight: 700;
}

.is-locked .app-shell {
  pointer-events: none;
  user-select: none;
  filter: blur(2px);
}

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

.app-shell {
  min-height: 100svh;
  padding: env(safe-area-inset-top) 14px calc(76px + env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 7px;
}

.date-label,
.hint,
.suggestion,
small {
  color: var(--muted);
}

.date-label {
  font-size: 13px;
  margin-bottom: 4px;
}

.app-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 12px;
}

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

.metric-tile,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(24, 33, 31, 0.04);
}

.metric-tile {
  min-height: 96px;
  padding: 14px;
  display: grid;
  align-content: space-between;
}

.metric-tile span {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-tile strong {
  font-size: 24px;
  line-height: 1.1;
}

.panel {
  padding: 15px;
  display: grid;
  gap: 12px;
}

.focus-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background: #173f32;
  color: #fffdf8;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.focus-copy {
  display: grid;
  gap: 7px;
}

.focus-copy span {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #d8f2e5;
  font-size: 12px;
  font-weight: 800;
}

.focus-copy h2 {
  color: #ffffff;
  font-size: 22px;
}

.focus-copy p {
  color: #d8e8df;
  line-height: 1.45;
}

.focus-actions {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
}

.focus-actions .primary {
  background: #ffffff;
  border-color: #ffffff;
  color: #173f32;
}

.focus-actions .chip.quiet {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

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

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 74px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.14);
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 13px;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.text-button {
  color: var(--accent);
  background: var(--soft);
  border-color: transparent;
  font-weight: 700;
}

.icon-button {
  width: 46px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.quick-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: var(--soft);
  border-color: transparent;
  font-weight: 700;
}

.chip.quiet {
  background: #ffffff;
  color: var(--muted);
  border-color: var(--line);
}

.checklist {
  display: grid;
  gap: 8px;
}

.check-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.check-row input {
  min-height: 22px;
  margin: 2px 0 0;
}

.check-row strong {
  display: block;
  font-size: 14px;
}

.check-row small {
  display: block;
  margin-top: 2px;
}

.inventory-picks,
.preset-grid,
.inventory-list,
.trend-list,
.event-list,
.health-import-card,
.app-status-grid {
  display: grid;
  gap: 8px;
}

.health-import-card {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.health-import-card div {
  display: grid;
  gap: 4px;
}

.health-import-card span {
  color: var(--muted);
  font-size: 12px;
}

.health-import-card strong {
  font-size: 18px;
}

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

.app-status-grid div {
  min-height: 80px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 11px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.app-status-grid span {
  color: var(--muted);
  font-size: 12px;
}

.app-status-grid strong {
  font-size: 18px;
  line-height: 1.1;
}

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

.preset-button {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  text-align: left;
  padding: 10px;
  background: #ffffff;
}

.preset-button strong {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-button small {
  line-height: 1.25;
}

.inventory-item,
.trend-item,
.event-item {
  display: grid;
  gap: 7px;
  padding: 11px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.inventory-item header,
.trend-item header,
.event-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.inventory-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timer-panel {
  text-align: center;
}

.timer-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}

.timer-face {
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.timer-face span {
  color: var(--accent);
  font-weight: 800;
}

.timer-face strong {
  font-size: 43px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ui-icon {
  display: inline-grid;
  width: 1.35em;
  min-width: 1.35em;
  height: 1.35em;
  place-items: center;
  font-style: normal;
  line-height: 1;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.tabbar button {
  min-height: 46px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
}

.tabbar button span {
  line-height: 1;
  font-size: 16px;
}

.tabbar button.active {
  color: var(--accent);
  background: var(--soft);
}

@media (min-width: 680px) {
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .form-grid,
  .timer-settings,
  .app-status-grid,
  .health-import-card,
  .focus-actions {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 27px;
  }
}
