:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef2ea;
  --text: #18211d;
  --muted: #58645e;
  --line: #d9ded4;
  --accent: #0f6b55;
  --accent-strong: #0a4d3e;
  --accent-soft: #dcebe4;
  --warn: #a55d08;
  --shadow: 0 14px 40px rgba(24, 33, 29, 0.12);
  --radius: 8px;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111713;
    --surface: #18211d;
    --surface-2: #202b26;
    --text: #f3f6ef;
    --muted: #b7c1ba;
    --line: #34413a;
    --accent: #72d7b7;
    --accent-strong: #9ce8cf;
    --accent-soft: #17392f;
    --warn: #f2b15c;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.36);
  }
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef2ea;
  --text: #18211d;
  --muted: #58645e;
  --line: #d9ded4;
  --accent: #0f6b55;
  --accent-strong: #0a4d3e;
  --accent-soft: #dcebe4;
  --warn: #a55d08;
  --shadow: 0 14px 40px rgba(24, 33, 29, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111713;
  --surface: #18211d;
  --surface-2: #202b26;
  --text: #f3f6ef;
  --muted: #b7c1ba;
  --line: #34413a;
  --accent: #72d7b7;
  --accent-strong: #9ce8cf;
  --accent-soft: #17392f;
  --warn: #f2b15c;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  margin: 0;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

button,
a.button,
.icon-button {
  touch-action: manipulation;
}

svg {
  display: block;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-160%);
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.app-header {
  padding: max(20px, env(safe-area-inset-top)) 16px 0;
}

.header-inner,
.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.1rem);
}

h2 {
  font-size: clamp(1.35rem, 4vw, 2rem);
}

h3 {
  font-size: 1.08rem;
}

.lead {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
}

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

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

.shell {
  padding: 0 16px max(32px, env(safe-area-inset-bottom));
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
}

.hero-panel > img {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.today-card,
.card,
.unlock-form,
.day-detail,
.timeline-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.today-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

.today-card p {
  margin: 0;
}

.today-actions {
  display: grid;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

[data-theme="dark"] .button.primary {
  color: #062019;
}

.button.compact {
  min-height: 40px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 16px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 86%, var(--surface));
  backdrop-filter: blur(14px);
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.controls label {
  font-weight: 800;
}

select,
input {
  min-height: var(--tap);
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

#dateSelect {
  flex: 1 1 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .controls {
    flex-wrap: wrap;
  }
  #dateSelect {
    flex-basis: 100%;
    order: 2;
  }
  #deviceDateBtn {
    order: 3;
  }
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.view > h2 {
  margin: 24px 0 12px;
}

.day-detail {
  overflow: hidden;
}

.day-main {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 0;
}

.panel {
  padding: 20px;
}

.panel + .panel {
  border-left: 1px solid var(--line);
}

.info-list,
.mini-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.info-item,
.nearby-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.info-item p,
.nearby-item p,
.card p,
.private-block p {
  margin: 0;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 800;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  width: fit-content;
  border-radius: var(--radius);
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.nav-link::after {
  content: "\2197";
  font-size: 1.1em;
}

.timeline-list,
.card-grid,
.private-content {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  box-shadow: none;
}

.timeline-date {
  color: var(--accent-strong);
  font-weight: 900;
}

.timeline-item.is-selected {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

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

.card {
  display: grid;
  gap: 12px;
  padding: 18px;
  box-shadow: none;
}

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

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

.card.is-today {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.flight-route {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.flight-point {
  display: grid;
  gap: 4px;
}

.flight-point strong {
  font-size: 0.95rem;
}

.flight-point span {
  color: var(--accent-strong);
  font-weight: 800;
}

.flight-arrow {
  color: var(--muted);
  font-size: 1.4rem;
}

.flight-arrow::before {
  content: "\2708\0020\2192";
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 12px;
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.unlock-form {
  display: grid;
  gap: 10px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: none;
}

.unlock-form label {
  font-weight: 800;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.form-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
}

.private-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}

.private-block h3 {
  margin-bottom: 10px;
}

.private-table {
  display: grid;
  gap: 8px;
}

.private-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.private-row:first-child {
  border-top: 0;
}

.private-row span:first-child {
  color: var(--muted);
  font-weight: 700;
}

.private-row code {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.secure-asset {
  display: grid;
  gap: 10px;
}

.secure-asset p {
  margin: 0;
  color: var(--muted);
}

.secure-error {
  color: var(--warn) !important;
  font-weight: 700;
}

.secure-preview {
  display: grid;
  gap: 10px;
  width: 100%;
}

.secure-frame {
  width: 100%;
  min-height: 70dvh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.secure-image {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (max-width: 860px) {
  .header-inner,
  .hero-panel,
  .day-main,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .header-inner {
    display: grid;
  }

  .hero-panel > img {
    min-height: 210px;
  }

  .panel + .panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .shell,
  .app-header {
    padding-left: 12px;
    padding-right: 12px;
  }

  .tabs {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 5px;
  }

  .tab {
    min-height: 42px;
    font-size: 0.9rem;
  }

  .today-card,
  .panel,
  .card,
  .timeline-item,
  .unlock-form {
    padding: 14px;
  }

  .timeline-item,
  .private-row,
  .password-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .button,
  .tab,
  .icon-button,
  .nav-link {
    transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
  }

  .button:active,
  .tab:active,
  .icon-button:active {
    transform: scale(0.98);
  }
}
