:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f3f5f7;
  --surface-hover: #eceff2;
  --text: #14181f;
  --text-soft: #353b45;
  --muted: #737c89;
  --muted-2: #98a0aa;
  --divider: #e7eaee;
  --input-line: #d8dde3;
  --accent: #f17822;
  --accent-strong: #db6515;
  --accent-soft: #fff3ea;
  --focus: #2f6fed;
  --danger: #d13b31;
  --shadow-lg: 0 24px 70px rgba(24, 32, 45, .10), 0 3px 12px rgba(24, 32, 45, .05);
  --shadow-menu: 0 14px 40px rgba(24, 32, 45, .16), 0 2px 8px rgba(24, 32, 45, .08);
  --radius-lg: 24px;
  --radius-md: 13px;
  --radius-sm: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { color: inherit; }
button, [role="option"] { -webkit-user-select: none; user-select: none; }
svg { display: block; }

.app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: start center;
  padding: max(10px, env(safe-area-inset-top)) 10px max(16px, env(safe-area-inset-bottom));
}

.app-card {
  width: min(100%, 430px);
  min-height: calc(100dvh - 20px);
  background: var(--surface);
  border: 1px solid rgba(20, 24, 31, .06);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: clip;
}

.topbar {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 4px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  display: inline-grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.icon-button svg,
.registration-toggle svg,
.primary-button svg,
.action-button svg,
.remove-button svg,
.empty-state svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button svg { width: 20px; height: 20px; }
.icon-button:hover { background: var(--surface-subtle); }
.icon-button:active { transform: scale(.94); background: var(--surface-hover); }
.icon-button.compact { width: 36px; height: 36px; border-radius: 10px; }
.icon-button.compact svg { width: 18px; height: 18px; }

.icon-button:focus-visible,
.native-date-input:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.action-button:focus-visible,
.remove-button:focus-visible,
.toggle-dot:focus-visible,
.registration-control:focus-within,
.field-input:focus-visible,
.timebox:focus-within,
.integer-box:focus-within,
.aircraft-option:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 25%, transparent);
  outline-offset: 2px;
}

.date-button {
  position: relative;
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  color: var(--text);
  font-size: 1.06rem;
  font-weight: 720;
  letter-spacing: -.018em;
  cursor: pointer;
  touch-action: manipulation;
}
.date-button:hover { background: var(--surface-subtle); }
.date-button:active { background: var(--surface-hover); }
.date-icon { width: 14px; height: 14px; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.native-date-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  color-scheme: light dark;
}
.native-date-input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.aircraft-toolbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 5px;
  padding: 3px 12px 10px;
  box-shadow: inset 0 -1px var(--divider);
}

.registration-control {
  position: relative;
  min-width: 0;
  height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface-subtle);
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.registration-control:focus-within {
  border-color: var(--input-line);
  background: var(--surface);
}
.registration-control input {
  min-width: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  text-transform: uppercase;
  font-weight: 760;
  text-align: center;
  letter-spacing: .075em;
  padding: 0 0 0 28px;
}
.registration-control input::placeholder { color: var(--muted-2); opacity: 1; letter-spacing: .055em; }
.registration-toggle {
  width: 38px;
  height: 100%;
  border: 0;
  border-radius: 0 11px 11px 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.registration-toggle:hover { color: var(--text-soft); }
.registration-toggle svg { width: 16px; height: 16px; transition: transform .16s ease; }
.registration-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.aircraft-menu {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--divider);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-raised) 96%, transparent);
  box-shadow: var(--shadow-menu);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.aircraft-menu[hidden] { display: none; }
.aircraft-option {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  text-align: left;
  font-size: .91rem;
  font-weight: 720;
  letter-spacing: .045em;
  cursor: pointer;
}
.aircraft-option:hover,
.aircraft-option:focus-visible { background: var(--surface-subtle); outline-offset: -1px; }
.aircraft-option[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.aircraft-option .aircraft-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke-width: 1.75;
  opacity: .92;
}
.aircraft-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

.back-icon { display: none; }
body.export-mode .export-icon { display: none; }
body.export-mode .back-icon { display: block; }

.view-stage { position: relative; overflow: hidden; }
.view-panel {
  width: 100%;
  padding: 10px 12px 14px;
  transition: opacity .18s ease, transform .23s cubic-bezier(.22,.72,.28,1);
}
.tracker-panel { transform: translateX(0); opacity: 1; }
.export-panel {
  position: absolute;
  inset: 0;
  transform: translateX(102%);
  opacity: 0;
  pointer-events: none;
}
body.export-mode .tracker-panel { position: absolute; inset: 0; transform: translateX(-102%); opacity: 0; pointer-events: none; }
body.export-mode .export-panel { position: relative; transform: translateX(0); opacity: 1; pointer-events: auto; }

.empty-state {
  margin: 8px 0;
  padding: 42px 26px;
  border: 0;
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-subtle);
}
.empty-state svg { width: 28px; height: 28px; margin: 0 auto 12px; color: var(--muted-2); }
.empty-state p { margin: 0; font-size: .88rem; line-height: 1.45; }
.empty-state[hidden] { display: none; }

.events-list { display: grid; gap: 0; }
.event-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 49px;
  padding: 6px 1px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.event-card + .event-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 2px;
  right: 2px;
  height: 1px;
  background: var(--divider);
}
.event-main { min-width: 0; }
.event-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.event-row.wrap { flex-wrap: wrap; }
.event-label {
  flex: 0 0 auto;
  min-width: 62px;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 790;
  line-height: 1;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.flight-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.flight-field { min-width: 0; }
.flight-field .event-label {
  display: block;
  min-width: 0;
  margin: 0 0 3px 2px;
  font-size: .61rem;
}
.flight-field .timebox,
.flight-field .integer-box { min-width: 0; width: 100%; }

.event-side {
  /* Give the status control its own fixed-width column. The ball, not the
     label text, defines the horizontal alignment for every event type. */
  --status-column-width: 48px;
  --remove-column-width: 32px;
  width: calc(var(--status-column-width) + var(--remove-column-width));
  min-width: calc(var(--status-column-width) + var(--remove-column-width));
  display: grid;
  grid-template-columns: var(--status-column-width) var(--remove-column-width);
  align-items: center;
  justify-items: center;
  gap: 0;
}
.toggle-control {
  grid-column: 1;
  width: var(--status-column-width);
  min-width: var(--status-column-width);
  display: grid;
  grid-template-rows: auto 32px;
  align-items: center;
  justify-items: center;
  justify-self: center;
  gap: 2px;
}
.event-side-label {
  width: var(--status-column-width);
  color: var(--muted);
  font-size: .61rem;
  font-weight: 790;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: .075em;
  text-align: center;
  text-transform: uppercase;
}

/* In T/O + LDG + TIME mode, align NO DROP with the field headers instead of
   vertically centering the entire control beside the flight row. */
.flight-event .event-side {
  align-self: stretch;
  align-items: start;
  padding-top: 0;
}
.flight-event .toggle-control {
  grid-template-rows: 10px 32px;
  gap: 2px;
}
.flight-event .event-side-label {
  align-self: start;
}
.flight-event .remove-button {
  align-self: center;
  margin-top: 0;
}

.toggle-dot {
  position: relative;
  width: 32px;
  height: 32px;
  justify-self: center;
  margin-inline: auto;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.toggle-dot::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px solid color-mix(in srgb, var(--muted-2) 62%, var(--surface));
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 24, 31, .05);
  transition: background .14s ease, border-color .14s ease, transform .12s ease, box-shadow .14s ease;
}
.toggle-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: transparent;
  transform: translate(-50%, -50%) scale(.6);
  transition: background .14s ease, transform .14s ease;
}
.toggle-dot:hover::before {
  border-color: var(--muted);
  background: var(--surface-subtle);
}
.toggle-dot[aria-pressed="true"]::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 28%, transparent);
}
.toggle-dot[aria-pressed="true"]::after {
  background: #fff;
  transform: translate(-50%, -50%) scale(1);
}
.toggle-dot:active::before { transform: scale(.88); }

.remove-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted-2);
  display: grid;
  place-items: center;
  align-self: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: color .12s ease, background .12s ease, transform .12s ease;
}
.remove-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.65;
}
.event-side > .remove-button:only-child { grid-column: 2; }
.remove-button:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}
.remove-button:active {
  transform: scale(.9);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.timebox,
.integer-box {
  position: relative;
  min-width: 87px;
  height: 37px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--surface-subtle);
  overflow: hidden;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.timebox:focus-within,
.integer-box:focus-within { border-color: var(--input-line); background: var(--surface); }
.timebox { touch-action: manipulation; }
.block-timebox {
  width: 136px;
  min-width: 136px;
  height: 43px;
}
.block-timebox .timebox-visual { font-size: 1.03rem; }
.timebox-visual {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr .46fr 1fr 1fr;
  place-items: center;
  padding: 0 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  pointer-events: none;
}
.time-colon { color: var(--muted); transform: translateY(-1px); }
.timebox-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  /* Keep the native input fully present for iOS WebKit's focus/keyboard
     heuristics. Hide its text rather than making the whole control nearly
     transparent; the custom visual layer beneath remains what the user sees. */
  opacity: 1;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  background: transparent;
  padding: 0;
  pointer-events: auto;
  cursor: text;
}
.timebox.readonly,
.integer-box.readonly { background: transparent; border-color: var(--divider); }
.timebox.readonly .timebox-input { pointer-events: none; }
.timebox.readonly::after {
  content: "CALC";
  position: absolute;
  top: 2px;
  right: 4px;
  color: var(--muted-2);
  font-size: .4rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.integer-box { display: block; min-width: 68px; }
.integer-box input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  font-size: .94rem;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
}
.integer-box input[readonly] { color: var(--text); opacity: 1; }
.flight-duration-box.integer-box,
.flight-duration-box.integer-box.readonly {
  min-width: 0;
  width: 100%;
  height: 37px;
  border-color: transparent;
  border-radius: 9px;
  background: var(--surface-subtle);
}
.flight-duration-box.integer-box input,
.flight-duration-box.integer-box input[readonly] {
  color: var(--text);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.035em;
  opacity: 1;
}
.suffix { color: var(--muted); font-weight: 700; font-size: .7rem; letter-spacing: .04em; }

.event-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding-top: 9px;
  margin-top: 3px;
  box-shadow: inset 0 1px var(--divider);
}
.event-actions.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.action-button {
  min-height: 43px;
  border: 0;
  border-radius: 11px;
  background: var(--surface-subtle);
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  font-weight: 790;
  font-size: .67rem;
  letter-spacing: .055em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.action-button svg { width: 14px; height: 14px; stroke-width: 2; }
.action-button:hover { background: var(--surface-hover); }
.action-button:active { transform: scale(.97); }
.action-button.primary-ish { background: var(--accent-soft); color: var(--accent-strong); }
.action-button.primary-ish:hover { background: color-mix(in srgb, var(--accent-soft) 72%, var(--accent) 12%); }
.action-button:disabled { opacity: .42; cursor: not-allowed; }

.panel-heading { padding: 5px 2px 14px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 1.2rem; line-height: 1.2; letter-spacing: -.025em; }
.section-label,
.eyebrow {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 820;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.stats-card {
  display: grid;
  gap: 0;
  padding: 0 0 10px;
  box-shadow: inset 0 -1px var(--divider);
}
.stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 45px;
  box-shadow: inset 0 -1px var(--divider);
}
.stat-row:last-child { box-shadow: none; }
.stat-label { color: var(--text-soft); font-size: .83rem; font-weight: 650; }
.stat-value {
  min-width: 88px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .85rem;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}
.export-section { padding: 17px 0 1px; }
.export-hint { margin: 5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.export-section .primary-button { width: 100%; margin-top: 12px; }
.status-message { min-height: 1.3em; margin: 8px 2px 0; color: var(--muted); font-size: .76rem; text-align: center; }

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 11px;
  padding: 0 15px;
  font-weight: 740;
  font-size: .86rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.primary-button {
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-button svg { width: 16px; height: 16px; }
.secondary-button { border: 1px solid var(--divider); background: var(--surface); color: var(--text-soft); }
.primary-button:hover { opacity: .92; }
.secondary-button:hover { background: var(--surface-subtle); }
.primary-button:active, .secondary-button:active { transform: scale(.98); }
.primary-button:disabled { opacity: .35; cursor: not-allowed; }

.modal {
  width: min(92vw, 420px);
  max-height: min(90dvh, 720px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.modal::backdrop { background: rgba(10, 15, 22, .48); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal-card {
  display: grid;
  gap: 14px;
  max-height: 90dvh;
  overflow: auto;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--divider) 90%, transparent);
  border-radius: 22px;
  background: var(--surface-raised);
  box-shadow: 0 28px 90px rgba(8, 13, 20, .25);
}
.modal-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.modal-header h2 { margin: 3px 0 0; font-size: 1.2rem; line-height: 1.2; letter-spacing: -.025em; }
.field-label {
  display: block;
  margin: 0 0 5px 1px;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 790;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.field-input {
  width: 100%;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  padding: 0 11px;
  outline: 0;
  font-weight: 650;
  transition: border-color .12s ease, background .12s ease;
}
.field-input:focus { border-color: var(--input-line); background: var(--surface); }
.uppercase { text-transform: uppercase; }
.field-grid { display: grid; gap: 9px; }
.two-col { grid-template-columns: 1fr 1fr; }
.settings-group {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.settings-group legend {
  width: 100%;
  padding: 0 1px 7px;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 790;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.tracking-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 2px;
  border: 1px solid var(--divider);
  border-radius: 11px;
  background: var(--surface-subtle);
  overflow: clip;
}
.radio-row {
  position: relative;
  min-width: 0;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
}
.radio-row:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--divider) 80%, transparent), 0 1px 2px rgba(24, 32, 45, .06);
}
.radio-row input { position: absolute; opacity: 0; pointer-events: none; }
.radio-row span {
  display: block;
  width: 100%;
  min-width: 0;
  font-weight: 720;
  font-size: .7rem;
  line-height: 1.15;
  text-align: center;
  letter-spacing: .005em;
  white-space: normal;
}
.settings-note { margin: -1px 1px 0; color: var(--muted); font-size: .74rem; line-height: 1.4; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 1px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 18px);
  z-index: 50;
  max-width: calc(100vw - 28px);
  padding: 9px 13px;
  border-radius: 999px;
  background: #171b22;
  color: #fff;
  box-shadow: 0 12px 34px rgba(8, 13, 20, .24);
  font-size: .78rem;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .app-shell { padding: 0; }
  .app-card {
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
  .view-panel { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .modal {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }
  .modal-card {
    border-radius: 22px 22px 0 0;
    border-inline: 0;
    border-bottom: 0;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .topbar,
  .aircraft-toolbar,
  .view-panel { padding-inline: 9px; }
  .flight-layout { gap: 4px; }
  .event-card { gap: 3px; }
  .event-label { min-width: 57px; font-size: .63rem; }
  .block-timebox { width: 128px; min-width: 128px; }
  .radio-row span { font-size: .66rem; }
  .timebox-visual { padding-inline: 5px; font-size: .89rem; }
  .block-timebox .timebox-visual { font-size: .99rem; }
}

@media (min-width: 700px) {
  .app-shell { padding-top: 24px; }
  .app-card { min-height: 720px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #121820;
    --surface-raised: #161d26;
    --surface-subtle: #1b232d;
    --surface-hover: #222c38;
    --text: #f1f4f7;
    --text-soft: #d1d7de;
    --muted: #8f9aa7;
    --muted-2: #6f7b88;
    --divider: #232d38;
    --input-line: #3a4654;
    --accent: #ff8a38;
    --accent-strong: #ff9a54;
    --accent-soft: #2d2118;
    --shadow-lg: 0 24px 70px rgba(0,0,0,.34);
    --shadow-menu: 0 16px 42px rgba(0,0,0,.42);
  }
  .primary-button { background: #eef2f5; color: #151a20; border-color: #eef2f5; }
  .toast { background: #eef2f5; color: #151a20; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Prevent mobile browsers (especially iOS Safari) from auto-zooming focused form fields.
   max() preserves any input styling that is already larger than 16px. */
input,
select,
textarea {
  font-size: max(16px, 1em) !important;
}


/* Export-page day backup controls */
.backup-section {
  border-top: 1px solid var(--divider);
  margin-top: 8px;
  padding-top: 18px;
}

.backup-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.backup-actions .primary-button,
.backup-actions .secondary-button {
  width: 100%;
  margin-top: 0;
}

.backup-download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.backup-download-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.secondary-button:disabled {
  opacity: .35;
  cursor: not-allowed;
}
