:root {
  color-scheme: light;
  --canvas: #edf6f4;
  --surface: #fbfffd;
  --surface-strong: #ffffff;
  --ink: #17211f;
  --muted: #667572;
  --line: #cfe0dc;
  --brand: #12635d;
  --brand-strong: #0b4844;
  --brand-soft: #d9efeb;
  --amber: #8f4d00;
  --amber-soft: #fff0d6;
  --green: #277a54;
  --green-soft: #ddf4e8;
  --red: #963525;
  --red-soft: #ffe1da;
  --blue: #315f9f;
  --blue-soft: #e2ecfb;
  --shadow: 0 18px 42px rgba(18, 99, 93, 0.12);
  --shadow-small: 0 10px 22px rgba(18, 99, 93, 0.08);
  --radius: 14px;
  --bottom-space: calc(96px + env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(18, 99, 93, 0.08), transparent 36%),
    radial-gradient(circle at 80% 0%, rgba(183, 104, 18, 0.12), transparent 28%),
    var(--canvas);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Nunito Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(18, 99, 93, 0.34);
  outline-offset: 3px;
}

noscript {
  display: block;
  padding: 16px;
  background: var(--red-soft);
  color: var(--red);
}

.app-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: var(--bottom-space);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(237, 246, 244, 0.86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(207, 224, 220, 0.72);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.connection-pill.online {
  background: var(--green-soft);
  color: var(--green);
}

.connection-pill.offline {
  background: var(--amber-soft);
  color: var(--amber);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.brand-button strong,
.brand-button small {
  display: block;
}

.brand-button small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  background:
    radial-gradient(circle at 70% 22%, rgba(255, 255, 255, 0.4), transparent 28%),
    linear-gradient(145deg, var(--brand), #2c8b73);
  color: white;
  box-shadow: var(--shadow-small);
  font-size: 0.82rem;
  font-weight: 800;
}

.install-button,
.primary-button,
.secondary-button,
.text-button,
.method-card,
.history-row,
.chip {
  min-height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
}

.install-button,
.primary-button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.install-button {
  padding: 9px 14px;
}

.secondary-button,
.text-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand-strong);
  font-weight: 800;
}

.primary-button,
.secondary-button {
  padding: 12px 16px;
}

.text-button {
  min-height: 44px;
  padding: 8px 0;
  border-color: transparent;
  background: transparent;
}

.full {
  width: 100%;
}

.main-panel {
  padding: 16px;
}

.hero-panel,
.panel,
.mode-card,
.bucket,
.warning-panel,
.success-panel,
.empty-state,
.option-panel,
.method-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  background:
    radial-gradient(circle at 92% 18%, rgba(183, 104, 18, 0.13), transparent 22%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(217, 239, 235, 0.82)),
    var(--surface);
}

.hero-panel h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.8rem);
  line-height: 1;
}

.hero-panel p,
.page-title p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
}

.hero-lede {
  font-size: 1.05rem;
}

.hero-actions {
  display: grid;
  gap: 10px;
  min-width: 170px;
}

.profile-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.profile-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(18, 99, 93, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--brand-strong);
  font-size: 0.84rem;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.quick-grid,
.section-grid,
.method-grid,
.entry-grid,
.status-grid,
.photo-layout,
.guide-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.quick-grid,
.section-grid,
.method-grid,
.photo-layout,
.guide-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-card,
.panel,
.bucket,
.warning-panel,
.success-panel,
.empty-state,
.option-panel {
  padding: 18px;
}

.mode-card {
  display: grid;
  gap: 12px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.mode-card:focus-within,
.mode-card:hover {
  box-shadow: 0 20px 46px rgba(18, 99, 93, 0.16);
  transform: translateY(-1px);
}

.mode-card h2,
.panel h2,
.bucket h2,
.warning-panel h2,
.empty-state h2,
.method-card strong {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.2;
}

.mode-card p,
.panel p,
.bucket p,
.warning-panel p,
.empty-state p,
.method-card span,
.option-panel p {
  margin: 0;
  color: var(--muted);
}

.mode-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-soft);
}

.mode-icon[data-icon="calendar-check"] {
  background:
    linear-gradient(var(--brand), var(--brand)) 12px 13px / 18px 3px no-repeat,
    linear-gradient(var(--brand), var(--brand)) 12px 22px / 18px 3px no-repeat,
    var(--brand-soft);
}

.mode-icon[data-icon="sun"] {
  background:
    radial-gradient(circle, var(--amber) 0 34%, transparent 36%),
    linear-gradient(90deg, transparent 0 17px, var(--amber) 17px 25px, transparent 25px),
    linear-gradient(0deg, transparent 0 17px, var(--amber) 17px 25px, transparent 25px),
    var(--amber-soft);
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row.wrap {
  flex-wrap: wrap;
}

.button-row.right {
  justify-content: flex-end;
}

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

.status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-dot.ok {
  background: var(--green-soft);
  color: var(--green);
}

.status-dot.watch,
.status-dot.low {
  background: var(--amber-soft);
  color: var(--amber);
}

.reading-line,
.history-values {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reading-line {
  margin: 14px 0 10px;
}

.reading-line span,
.dose,
.status-card em {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-style: normal;
}

.page-title {
  padding: 6px 2px 10px;
}

.method-card {
  display: grid;
  gap: 8px;
  padding: 20px;
  border-color: var(--line);
  text-align: left;
}

.method-card.beta {
  border-color: rgba(183, 104, 18, 0.34);
  background: linear-gradient(145deg, #fff, var(--amber-soft));
}

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

.option-panel {
  min-width: 0;
  border: 1px solid var(--line);
}

.option-panel legend {
  padding: 0;
  font-size: 1.08rem;
  font-weight: 900;
}

.option-panel p {
  margin: 8px 0 12px;
  font-size: 0.92rem;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 800;
  box-shadow: var(--shadow-small);
}

.chip.selected {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.sticky-actions {
  position: fixed;
  right: max(16px, calc((100vw - 1040px) / 2 + 16px));
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: max(16px, calc((100vw - 1040px) / 2 + 16px));
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 36px rgba(23, 33, 31, 0.14);
  backdrop-filter: blur(18px);
}

.sticky-actions div:first-child {
  min-width: 0;
}

.sticky-actions strong,
.sticky-actions span {
  display: block;
}

.sticky-actions span {
  color: var(--muted);
  font-size: 0.88rem;
}

.photo-uploader,
.photo-preview {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  padding: 18px;
}

.photo-meta {
  margin-bottom: 14px;
}

.photo-uploader {
  display: grid;
  align-content: center;
  gap: 12px;
}

.file-pick,
.file-inline {
  position: relative;
  overflow: hidden;
}

.file-pick {
  display: grid;
  min-height: 56px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand);
  color: white;
  font-weight: 900;
}

.file-pick input,
.file-inline input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.file-pick:focus-within,
.file-inline:focus-within {
  outline: 3px solid rgba(18, 99, 93, 0.34);
  outline-offset: 3px;
}

.photo-preview {
  display: grid;
  place-items: center;
}

.photo-preview img,
.thumb {
  display: block;
  max-width: 100%;
  border-radius: var(--radius);
  object-fit: cover;
}

.photo-preview img {
  max-height: 520px;
}

.photo-frame {
  position: relative;
  display: inline-grid;
  max-width: 100%;
}

.photo-frame img {
  width: 100%;
}

.region-box {
  position: absolute;
  display: grid;
  align-items: start;
  justify-items: start;
  min-width: 28px;
  min-height: 28px;
  border: 2px solid var(--brand);
  border-radius: 10px;
  background: rgba(18, 99, 93, 0.12);
  box-shadow: 0 0 0 999px rgba(23, 33, 31, 0.03);
  pointer-events: none;
}

.region-box.chart {
  border-color: var(--blue);
  background: rgba(49, 95, 159, 0.12);
}

.region-box span {
  margin: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
}

.region-review {
  margin-top: 14px;
}

.region-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.region-controls {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.button-row.compact {
  gap: 6px;
}

.button-row.compact .secondary-button {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.thumb {
  width: 96px;
  height: 96px;
}

.framing-guide {
  position: relative;
  display: grid;
  width: min(360px, 100%);
  aspect-ratio: 4 / 3;
  place-items: center;
  border: 2px dashed rgba(18, 99, 93, 0.42);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-soft), #ffffff);
  color: var(--brand-strong);
  font-weight: 900;
}

.guide-strip,
.guide-chart {
  position: absolute;
  border-radius: 8px;
}

.guide-strip {
  left: 22%;
  width: 12%;
  height: 58%;
  background: rgba(183, 104, 18, 0.34);
}

.guide-chart {
  right: 18%;
  width: 36%;
  height: 54%;
  background: rgba(49, 95, 159, 0.2);
}

.status-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.status-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.status-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.status-card strong {
  font-size: 1.2rem;
}

.status-card.okay em {
  background: var(--green-soft);
  color: var(--green);
}

.status-card.low em,
.status-card.critical em {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-card.high em {
  background: var(--red-soft);
  color: var(--red);
}

.ordered-list,
.plain-list {
  margin: 8px 0 0;
  padding-left: 22px;
}

.ordered-list li,
.plain-list li {
  margin: 6px 0;
}

.bucket {
  margin-top: 14px;
}

.guide-stack {
  display: grid;
  gap: 0;
  margin-top: 8px;
}

.guide-line {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid rgba(207, 224, 220, 0.72);
}

.guide-line:first-of-type {
  border-top: 0;
}

.guide-line strong {
  color: var(--ink);
}

.guide-line p {
  margin: 0;
  color: var(--muted);
}

.item-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.line-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.line-item h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.step-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 900;
}

.warning-panel {
  margin-bottom: 14px;
  border-color: rgba(183, 104, 18, 0.38);
  background: var(--amber-soft);
}

.success-panel {
  margin-bottom: 14px;
  border-color: rgba(39, 122, 84, 0.34);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow-small);
}

.history-row small {
  display: block;
  color: var(--muted);
}

.empty-state {
  display: grid;
  gap: 12px;
  justify-items: start;
}

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

.profile-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.profile-form input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
}

.wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.danger,
.danger-zone .secondary-button {
  color: var(--red);
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(39, 122, 84, 0.34);
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.notice.offline,
.notice.update {
  border-color: rgba(183, 104, 18, 0.38);
  background: var(--amber-soft);
  color: var(--amber);
}

.notice .text-button {
  color: inherit;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

@media (max-width: 780px) {
  .main-panel {
    padding: 12px;
  }

  .hero-panel,
  .quick-grid,
  .section-grid,
  .method-grid,
  .photo-layout,
  .guide-grid,
  .status-grid,
  .profile-form,
  .region-control-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    display: grid;
  }

  .hero-actions {
    min-width: 0;
  }

  .status-grid {
    gap: 10px;
  }

  .history-row {
    grid-template-columns: 1fr;
  }

  .connection-pill {
    display: none;
  }

  .sticky-actions {
    position: static;
    display: grid;
    margin-top: 14px;
  }

  .sticky-actions .button-row {
    display: grid;
  }
}

@media (max-width: 520px) {
  :root {
    --bottom-space: calc(120px + env(safe-area-inset-bottom));
  }

  .button-row {
    display: grid;
  }

  .tab-bar {
    right: 0;
    left: 0;
    border-radius: 0;
  }
}

.tab-bar {
  position: fixed;
  right: max(12px, calc((100vw - 1040px) / 2 + 12px));
  bottom: 0;
  left: max(12px, calc((100vw - 1040px) / 2 + 12px));
  z-index: 22;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -12px 30px rgba(23, 33, 31, 0.11);
  backdrop-filter: blur(18px);
}

.tab-bar button {
  display: grid;
  min-height: 50px;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.tab-bar button.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}
