:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #101010;
  --panel-strong: #171511;
  --text: #f5f0e6;
  --muted: #b7ad9a;
  --soft: #7e7669;
  --line: rgba(212, 175, 55, 0.26);
  --line-strong: rgba(212, 175, 55, 0.55);
  --gold: #d4af37;
  --gold-bright: #f4d675;
  --teal: #7cc7bd;
  --danger-soft: #30241a;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(244, 214, 117, 0.08), rgba(5, 5, 5, 0) 270px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
  letter-spacing: 0;
}

button,
a,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

body.modal-open {
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.hero {
  display: grid;
  gap: 14px;
  padding: 8px 0 14px;
}

.date-label {
  margin: 0;
  color: var(--gold-bright);
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 11em;
  font-size: clamp(2rem, 12vw, 3.35rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.priority-panel {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(212, 175, 55, 0.15), rgba(16, 16, 16, 0.96));
  box-shadow: var(--shadow);
}

.priority-title {
  margin: 0;
  color: var(--gold-bright);
  font-size: 0.76rem;
  font-weight: 800;
}

.priority-copy {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.55;
}

.priority-copy.small {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.scai-switch {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--panel);
}

.scai-switch input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 58px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: #2a2a2a;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f8f3e7;
  transition: transform 160ms ease;
}

.scai-switch input:checked + .switch-track {
  border-color: rgba(244, 214, 117, 0.75);
  background: #806719;
}

.scai-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(24px);
}

.scai-switch input:focus-visible + .switch-track {
  outline: 3px solid rgba(124, 199, 189, 0.68);
  outline-offset: 3px;
}

.switch-copy {
  display: grid;
  gap: 3px;
}

.switch-title {
  font-size: 1rem;
  font-weight: 800;
}

.switch-status {
  color: var(--muted);
  font-size: 0.82rem;
}

.ticket-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(124, 199, 189, 0.32);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(124, 199, 189, 0.1), rgba(16, 16, 16, 0.95));
}

.ticket-panel-copy {
  display: grid;
  gap: 4px;
}

.ticket-title {
  margin: 0;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 900;
}

.ticket-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.45;
}

.ticket-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ticket-slot {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  text-align: left;
}

.ticket-slot.has-ticket {
  border-color: rgba(124, 199, 189, 0.65);
  background: rgba(124, 199, 189, 0.13);
}

.ticket-slot-name {
  font-size: 0.86rem;
  font-weight: 900;
}

.ticket-slot-status {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 2px -16px 14px;
  padding: 10px 16px;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(16px);
}

.tab-button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #111;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.tab-button.is-active {
  border-color: var(--line-strong);
  background: var(--gold);
  color: #101010;
}

.tab-button:focus-visible,
.map-button:focus-visible,
.ticket-slot:focus-visible,
.ticket-action-button:focus-visible,
.plain-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible {
  outline: 3px solid rgba(124, 199, 189, 0.72);
  outline-offset: 3px;
}

.panels {
  min-height: 50vh;
}

.tab-panel[hidden] {
  display: none;
}

.day-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.day-heading h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.15;
}

.day-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.route-list,
.memo-list {
  display: grid;
  gap: 14px;
}

.route-card,
.memo-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
}

.route-card.is-muted {
  border-style: dashed;
  opacity: 0.68;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.route-number {
  color: var(--gold-bright);
  font-size: 0.8rem;
  font-weight: 900;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(244, 214, 117, 0.42);
  border-radius: 999px;
  color: var(--gold-bright);
  font-size: 0.72rem;
  font-weight: 800;
}

.badge.muted {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--muted);
}

.route-card h3,
.memo-card h3 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.35;
}

.route-time {
  margin: 0;
  color: var(--teal);
  font-size: 0.92rem;
  font-weight: 800;
}

.step-chips {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 0 16px 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.step-chips::-webkit-scrollbar {
  display: none;
}

.step-chips li {
  flex: 0 0 auto;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.25;
  list-style-position: inside;
  scroll-snap-align: start;
}

.section-label {
  margin: 0;
  color: var(--gold-bright);
  font-size: 0.78rem;
  font-weight: 900;
}

.notes {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.notes li::marker {
  color: var(--gold);
}

.branch-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(244, 214, 117, 0.22);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--gold-bright);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.5;
}

.map-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border: 1px solid rgba(244, 214, 117, 0.72);
  border-radius: 8px;
  background: var(--gold);
  color: #111;
  font-weight: 900;
  text-decoration: none;
}

.route-actions {
  display: grid;
  gap: 8px;
}

.route-actions.has-ticket-action {
  grid-template-columns: minmax(0, 1fr);
}

.ticket-action-button {
  min-height: 50px;
  border: 1px solid rgba(124, 199, 189, 0.58);
  border-radius: 8px;
  background: rgba(124, 199, 189, 0.13);
  color: var(--text);
  font-weight: 900;
}

.ticket-action-button.has-ticket {
  background: var(--teal);
  color: #07100e;
}

.ticket-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.82);
}

.ticket-modal[hidden] {
  display: none;
}

.ticket-modal-card {
  display: grid;
  gap: 12px;
  width: min(100%, 480px);
  max-height: 92vh;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #101010;
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.55);
}

.ticket-modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ticket-modal-title {
  margin: 0;
  color: var(--gold-bright);
  font-size: 1rem;
  font-weight: 900;
}

.plain-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
}

.plain-button {
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.ticket-preview {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
}

.ticket-preview img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  image-rendering: auto;
}

.ticket-empty {
  margin: 0;
  color: #111;
  font-weight: 900;
  text-align: center;
}

.ticket-modal-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.45;
}

.ticket-modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.secondary-button {
  border: 1px solid rgba(244, 214, 117, 0.62);
  background: var(--gold);
  color: #111;
}

.danger-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #ffd6c7;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 0;
  }

  .tabs {
    margin-inline: 0;
    padding-inline: 0;
  }

  .route-actions.has-ticket-action {
    grid-template-columns: 1.05fr 0.95fr;
  }
}
