:root {
  color-scheme: light;
  --bg: #f7efe7;
  --surface: #fffaf5;
  --surface-strong: #ffffff;
  --ink: #24201c;
  --muted: #6f665c;
  --line: #dfd0c1;
  --accent: #236b62;
  --accent-dark: #174d46;
  --accent-soft: #dceeea;
  --warning: #9d4b28;
  --warning-soft: #ffe7d9;
  --madopar: #356bb3;
  --ongentys: #7f4f9b;
  --done: #327454;
  --shadow: 0 20px 60px rgba(60, 41, 26, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 250, 245, 0.9), rgba(247, 239, 231, 0.8) 28rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

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

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

.user-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 720;
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 12vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.icon-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.hero-panel,
.food-panel,
.proposal-panel,
.auth-card {
  margin-bottom: 18px;
  border: 1px solid rgba(84, 67, 49, 0.14);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 22px;
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 80px);
  align-content: center;
  padding-bottom: 40px;
}

.auth-card {
  margin-top: 20px;
  padding: 18px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.segmented-control button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 820;
}

.segmented-control button.active {
  color: #fff;
  background: var(--accent);
}

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

.auth-message {
  min-height: 1.4rem;
  margin: 12px 0 0;
  color: var(--warning);
  line-height: 1.35;
}

.auth-help {
  padding: 2px 4px 0;
}

.auth-help h2 {
  margin-bottom: 10px;
  font-size: 1.22rem;
}

.auth-help ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: help-step;
}

.auth-help li {
  position: relative;
  min-height: 38px;
  padding-left: 48px;
  color: var(--muted);
  line-height: 1.38;
  counter-increment: help-step;
}

.auth-help li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
  content: counter(help-step);
}

.auth-help strong {
  color: var(--ink);
}

.next-dose {
  min-height: 3.2rem;
  font-size: clamp(2rem, 11vw, 3.4rem);
  font-weight: 850;
  line-height: 0.98;
  letter-spacing: 0;
}

.next-meta {
  min-height: 1.5rem;
  margin-top: 10px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions,
.inline-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.primary-action,
.secondary-action,
.text-button,
.food-button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  font-weight: 820;
  letter-spacing: 0;
  cursor: pointer;
}

.primary-action {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 26px rgba(35, 107, 98, 0.22);
}

.primary-action:active {
  background: var(--accent-dark);
}

.primary-action.compact,
.secondary-action {
  min-height: 48px;
  padding: 0 14px;
}

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

.food-panel {
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 4;
  padding: 12px;
}

.food-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--accent-soft);
}

.food-button strong {
  flex: 0 0 auto;
  font-size: 1.22rem;
}

.food-panel p {
  margin: 10px 3px 0;
  color: var(--muted);
  line-height: 1.35;
}

.food-panel.blocked .food-button {
  background: var(--warning-soft);
}

.proposal-panel {
  padding: 18px;
  border-color: rgba(157, 75, 40, 0.26);
}

.proposal-panel h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.proposal-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 8px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.text-button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--accent-dark);
  background: transparent;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0 0 90px;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 12px;
  bottom: 100px;
  left: 21px;
  width: 2px;
  background: var(--line);
  content: "";
}

.dose-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
}

.dose-dot {
  z-index: 1;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 4px solid var(--bg);
  border-radius: 999px;
  color: #fff;
  background: var(--madopar);
  font-size: 0.86rem;
  font-weight: 850;
}

.dose-card.ongentys .dose-dot {
  background: var(--ongentys);
}

.dose-card.done .dose-dot {
  background: var(--done);
}

.dose-body {
  min-width: 0;
  padding: 15px;
  border: 1px solid rgba(84, 67, 49, 0.14);
  border-radius: 8px;
  background: rgba(255, 250, 245, 0.88);
}

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

.dose-name {
  margin: 0 0 3px;
  font-size: 1.16rem;
  font-weight: 850;
}

.dose-time {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 850;
}

.dose-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.dose-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.mini-action {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 780;
}

.mini-action.confirm {
  border-color: transparent;
  color: #fff;
  background: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--done);
  background: rgba(50, 116, 84, 0.12);
  font-size: 0.88rem;
  font-weight: 780;
}

.conflict-pill {
  color: var(--warning);
  background: var(--warning-soft);
}

.hidden {
  display: none !important;
}

.sheet-dialog {
  width: min(calc(100% - 28px), 440px);
  margin: auto auto 18px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sheet-dialog::backdrop {
  background: rgba(36, 32, 28, 0.36);
}

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

.sheet-dialog h2 {
  margin-bottom: 16px;
  font-size: 1.45rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 740;
}

input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-size: 1.05rem;
}

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

.settings-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

@media (min-width: 540px) {
  .hero-actions,
  .inline-actions {
    grid-template-columns: 1fr 1fr;
  }

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