:root {
  color-scheme: light dark;
  --bg-a: #f5f7ff;
  --bg-b: #eef3fd;
  --bg-c: #faf8f3;
  --card: rgba(255, 255, 255, 0.84);
  --card-strong: rgba(255, 255, 255, 0.97);
  --secondary-card: rgba(245, 247, 252, 0.9);
  --text: #111827;
  --muted: #6b7280;
  --stroke: rgba(255, 255, 255, 0.72);
  --shadow: rgba(30, 100, 220, 0.08);
  --blue: #0a84ff;
  --cyan: #32ade6;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;
  --indigo: #5856d6;
  --pink: #ff2d55;
  --teal: #30b0c7;
  --gray: #8e8e93;
  --brown: #a2845e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
}

html, body, #app {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(135deg, var(--bg-a), var(--bg-b) 52%, var(--bg-c));
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body.dark {
  --bg-a: #111722;
  --bg-b: #14212d;
  --bg-c: #1d1824;
  --card: rgba(44, 47, 55, 0.92);
  --card-strong: rgba(38, 42, 50, 0.96);
  --secondary-card: rgba(31, 36, 46, 0.94);
  --text: #f5f7fb;
  --muted: #a6adba;
  --stroke: rgba(255, 255, 255, 0.09);
  --shadow: rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(18px);
}

.app-shell::before {
  width: 220px;
  height: 220px;
  right: -70px;
  top: -120px;
  background: rgba(10, 132, 255, 0.11);
}

.app-shell::after {
  width: 180px;
  height: 180px;
  left: -90px;
  top: 150px;
  background: rgba(50, 173, 230, 0.09);
}

.top-inset {
  padding: calc(var(--safe-top) + 6px) 16px 10px;
  z-index: 3;
}

.topbar {
  border-radius: 26px;
  padding: 14px;
  background: linear-gradient(135deg, var(--card-strong), var(--card));
  border: 1px solid var(--stroke);
  box-shadow: 0 12px 24px var(--shadow);
}

.top-row,
.row,
.menu-header,
.section-pill,
.detail-tabs,
.calendar-nav,
.control-row {
  display: flex;
  align-items: center;
}

.top-row {
  gap: 12px;
}

.icon-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--secondary-card);
  border: 1px solid var(--stroke);
  font-size: 18px;
  font-weight: 800;
}

.header-copy {
  min-width: 0;
}

.header-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 800;
}

.airline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.airline img {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
}

.spacer {
  flex: 1;
}

.mode-picker {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding: 6px;
  border-radius: 20px;
  background: rgba(142, 142, 147, 0.14);
}

.mode-button {
  position: relative;
  z-index: 1;
  min-height: 38px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.mode-button.active {
  color: var(--blue);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 4px 10px rgba(10, 132, 255, 0.09);
}

body.dark .mode-button.active {
  background: rgba(255, 255, 255, 0.10);
}

.content {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: auto;
  padding-bottom: calc(var(--safe-bottom) + 28px);
  overscroll-behavior: contain;
}

.empty {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 28px;
}

.empty-icon {
  color: var(--blue);
  font-size: 34px;
  font-weight: 800;
}

.empty h2 {
  margin: 14px 0 6px;
  font-size: 21px;
}

.empty p {
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.list {
  padding-bottom: 30px;
}

.section {
  padding: 6px 14px 2px;
}

.section-pill {
  width: fit-content;
  max-width: 100%;
  gap: 10px;
  margin: 0 auto;
  padding: 9px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 20px var(--shadow);
  font-size: 17px;
  font-weight: 800;
}

body.dark .section-pill {
  background: rgba(44, 47, 55, 0.92);
}

.pill-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: var(--blue);
  background: rgba(10, 132, 255, 0.12);
}

.event-row {
  position: relative;
  display: flex;
  gap: 12px;
  min-height: 66px;
  margin: 3px 14px;
  padding: 6px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.78));
  border: 1px solid var(--stroke);
  box-shadow: 0 8px 18px var(--row-shadow, rgba(10, 132, 255, 0.10));
  text-align: left;
  width: calc(100% - 28px);
}

body.dark .event-row {
  background: linear-gradient(135deg, rgba(43, 48, 58, 0.96), rgba(36, 41, 50, 0.86));
}

.event-row::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 5px;
  border-radius: 5px;
  background: linear-gradient(var(--event-color), color-mix(in srgb, var(--event-color), transparent 55%));
}

.event-icon {
  width: 46px;
  height: 46px;
  margin-left: 2px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--event-color);
  background: color-mix(in srgb, var(--event-color), transparent 86%);
  font-size: 20px;
}

.event-main {
  min-width: 0;
  flex: 1;
}

.event-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 800;
}

.track-button {
  width: 68px;
  height: 36px;
  margin-left: 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: rgba(10, 132, 255, 0.10);
  border: 1px solid rgba(10, 132, 255, 0.16);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.chevron {
  width: 34px;
  height: 34px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: var(--secondary-card);
  color: color-mix(in srgb, var(--event-color), transparent 25%);
  font-weight: 900;
}

.subtitle {
  margin-top: -2px;
  color: var(--muted);
  white-space: pre-line;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.cards {
  padding: 6px 16px 32px;
}

.settings-card,
.calendar-card,
.detail-card {
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 20px var(--shadow);
}

.calendar-card,
.detail-card {
  border-radius: 24px;
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--blue);
  font-size: 21px;
  font-weight: 800;
}

.card-subtitle {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.field-label {
  display: block;
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--secondary-card);
  outline: none;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--secondary-card);
  border-radius: 16px;
  padding: 0 8px 0 0;
}

.input-row .input {
  background: transparent;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 48px;
  border-radius: 18px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.secondary-button {
  color: var(--blue);
  background: rgba(10, 132, 255, 0.10);
}

.info-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--secondary-card);
  text-align: left;
}

.info-icon {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--row-color, var(--blue));
  background: color-mix(in srgb, var(--row-color, var(--blue)), transparent 88%);
}

.info-label {
  color: var(--muted);
  font-weight: 600;
}

.info-value {
  margin-left: auto;
  font-weight: 800;
}

.message {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(var(--count, 2), 1fr);
  gap: 8px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(142, 142, 147, 0.15);
}

.segmented button {
  min-height: 34px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.segmented button.active {
  color: var(--text);
  background: var(--card-strong);
}

.result-text {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.calendar-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.calendar-header h2 {
  margin: 0 0 4px;
  font-size: 21px;
}

.calendar-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.calendar-nav {
  margin-left: auto;
  gap: 8px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid var(--stroke);
}

body.dark .calendar-nav {
  background: var(--secondary-card);
}

.calendar-nav button {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: var(--card-strong);
  font-weight: 900;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px 6px;
  margin-top: 14px;
}

.weekday {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.day-cell {
  min-height: 46px;
  border-radius: 16px;
  padding: 4px;
  color: var(--cell-color, var(--text));
  background: var(--cell-fill, transparent);
  border: 1px solid var(--cell-stroke, transparent);
  font-size: 15px;
  font-weight: 800;
}

.day-cell.selected {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-color: rgba(10, 132, 255, 0.18);
}

.day-count {
  display: block;
  font-size: 11px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(0, 0, 0, 0.22);
}

.drawer {
  position: fixed;
  z-index: 6;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: min(74vw, 320px);
  padding: calc(var(--safe-top) + 18px) 16px 16px;
  border-radius: 0 28px 28px 0;
  background: var(--card-strong);
  border: 1px solid var(--stroke);
  box-shadow: 10px 0 28px rgba(0, 0, 0, 0.18);
  transform: translateX(-105%);
  transition: transform 0.26s cubic-bezier(.2,.8,.2,1);
}

.drawer.open {
  transform: translateX(0);
}

.menu-header {
  gap: 12px;
  margin-bottom: 24px;
}

.menu-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.menu-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.menu-subtitle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  border-radius: 18px;
  padding: 10px 12px;
  text-align: left;
}

.menu-item.active {
  background: rgba(10, 132, 255, 0.12);
  color: var(--blue);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.28);
}

.sheet,
.detail-screen {
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  border-radius: 24px 24px 0 0;
  background: var(--bg-a);
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
}

.sheet-header,
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-title,
.detail-title {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
}

.option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--secondary-card);
  border: 1px solid rgba(142, 142, 147, 0.12);
}

.option.selected {
  background: rgba(142, 142, 147, 0.14);
  border-color: rgba(142, 142, 147, 0.24);
  font-weight: 800;
}

.selected-badge {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(142, 142, 147, 0.18);
  font-size: 12px;
  font-weight: 900;
}

.detail-screen {
  position: fixed;
  inset: 0;
  z-index: 7;
  max-height: none;
  border-radius: 0;
}

.detail-tabs {
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tab {
  min-width: 108px;
  min-height: 38px;
  border-radius: 16px;
  padding: 0 12px;
  background: rgba(142, 142, 147, 0.14);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  color: var(--blue);
  background: rgba(10, 132, 255, 0.12);
}

.metric {
  padding: 10px 0;
  border-bottom: 1px solid rgba(142, 142, 147, 0.14);
}

.metric:last-child {
  border-bottom: 0;
}

.metric-title {
  color: var(--metric-color, var(--blue));
  font-size: 13px;
  font-weight: 900;
}

.metric-value {
  margin-top: 3px;
  font-size: 16px;
  font-weight: 700;
}

.crew-block {
  padding: 14px;
  border-radius: 16px;
  background: rgba(175, 82, 222, 0.10);
  border: 1px solid rgba(175, 82, 222, 0.16);
  white-space: pre-line;
}

.weather-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid rgba(142, 142, 147, 0.14);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

.icon-spinner {
  border-color: rgba(10, 132, 255, 0.25);
  border-top-color: var(--blue);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 720px) {
  .top-inset,
  .cards {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
  }

  .list {
    max-width: 760px;
    margin: 0 auto;
  }

  .sheet {
    max-width: 620px;
    margin: 0 auto;
    border-radius: 24px 24px 0 0;
  }
}
