:root {
  --navy: #123a67;
  --blue: #1976d2;
  --sky: #eaf4ff;
  --ink: #172433;
  --muted: #66788a;
  --line: #dce5ee;
  --surface: #ffffff;
  --bg: #f4f7fa;
  --accent: #ffb547;
  --success: #16845b;
  --shadow: 0 10px 28px rgba(20, 52, 84, .10);
  --overlay: rgba(12, 27, 43, .65);
}

html[data-theme="dark"] {
  --navy: #8ec9ff;
  --blue: #54a8f7;
  --sky: #162f47;
  --ink: #edf5fc;
  --muted: #a7b7c6;
  --line: #2d4559;
  --surface: #132535;
  --bg: #0b1824;
  --accent: #ffc66d;
  --success: #72d7ad;
  --shadow: 0 10px 28px rgba(0, 0, 0, .28);
  --overlay: rgba(0, 0, 0, .78);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #dfe8f1;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
html[data-theme="dark"] body { background: #06101a; }

button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(25, 118, 210, .28); outline-offset: 2px; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  padding-bottom: 78px;
  box-shadow: 0 0 40px rgba(20, 52, 84, .14);
}

.topbar {
  height: 68px;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-actions { display: flex; gap: 6px; }

.direction-panel { margin-top: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.direction-panel span, .direction-panel strong, .direction-panel small { display: block; }
.direction-panel span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.direction-panel strong { margin-top: 5px; color: var(--navy); font-size: 19px; }
.direction-panel small { margin-top: 4px; color: var(--muted); }
.english-output { font-family: Inter, "Segoe UI", Arial, sans-serif !important; }

.handover-button {
  width: 100%;
  min-height: 82px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 2px solid #f3a72f;
  border-radius: 19px;
  display: grid;
  grid-template-columns: 48px 1fr 24px;
  align-items: center;
  gap: 11px;
  color: #352006;
  background: linear-gradient(135deg, #ffd36f, #ffb43b);
  text-align: left;
  box-shadow: 0 9px 20px rgba(197, 119, 0, .24);
  cursor: pointer;
}
.handover-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: rgba(255,255,255,.58); font-size: 27px; }
.handover-button strong, .handover-button small { display: block; }
.handover-button strong { font-size: 16px; line-height: 1.3; }
.handover-button small { margin-top: 4px; font-size: 11px; line-height: 1.35; opacity: .78; }
.handover-arrow { font-size: 24px; font-weight: 900; }
.handover-button:active { transform: translateY(1px); }

.brand {
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--navy);
  cursor: pointer;
}
.brand strong { display: block; font-size: 15px; line-height: 1.1; }

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  background: var(--sky);
  color: var(--navy);
  font-size: 25px;
  cursor: pointer;
}

.hidden { visibility: hidden; }

main { padding: 22px 18px 30px; }

.hero {
  padding: 26px 22px;
  border-radius: 24px;
  background: linear-gradient(140deg, #0f3158, #1976d2);
  color: white;
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .hero { background: linear-gradient(140deg, #123a67, #155f9f); }

.eyebrow {
  margin: 0 0 8px;
  color: #bfe0ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hero h1 { margin: 0; font-size: clamp(27px, 8vw, 38px); line-height: 1.12; }
.hero p { margin: 13px 0 0; color: #e6f2ff; line-height: 1.55; font-size: 15px; }

.section-heading { margin: 26px 2px 14px; display: flex; justify-content: space-between; align-items: end; }
.section-heading h2 { margin: 0; font-size: 20px; }
.section-heading span { color: var(--muted); font-size: 12px; }

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

.scene-card, .list-card {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(20, 52, 84, .05);
}

.scene-card { min-height: 86px; padding: 12px 8px; border-radius: 16px; text-align: center; position: relative; }
.scene-card:active, .list-card:active { transform: translateY(1px); }
.scene-icon { display: block; font-size: 25px; margin-bottom: 7px; }
.scene-card strong { display: block; font-size: 11px; line-height: 1.2; }
.scene-card small, .scene-card .arrow { display: none; }
.scene-card.active { border-color: var(--blue); background: var(--sky); box-shadow: inset 0 0 0 1px var(--blue); }

.mode-stack { display: grid; gap: 11px; margin-top: 14px; }
.emergency-numbers { margin-top: 14px; padding: 14px; border: 1px solid #efb6b6; border-radius: 17px; background: #fff4f4; }
.emergency-numbers > strong { display: block; margin-bottom: 9px; color: #922626; font-size: 13px; }
.number-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.number-link { min-height: 58px; padding: 8px; border-radius: 13px; display: grid; place-content: center; text-align: center; text-decoration: none; background: #b72d2d; color: white; }
.number-link strong { display: block; font-size: 22px; line-height: 1; }
.number-link small { display: block; margin-top: 4px; font-size: 10px; }
html[data-theme="dark"] .emergency-numbers { border-color: #743b3b; background: #2b181b; }
html[data-theme="dark"] .emergency-numbers > strong { color: #ffaaaa; }
.mode-row { width: 100%; min-height: 92px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); display: grid; grid-template-columns: 48px 1fr 26px; align-items: center; gap: 13px; text-align: left; cursor: pointer; box-shadow: 0 5px 14px rgba(20,52,84,.05); }
.mode-row.urgent { background: linear-gradient(135deg, var(--navy), var(--blue)); color: white; border: 0; }
html[data-theme="dark"] .mode-row.urgent { background: linear-gradient(135deg, #174f7d, #237fc4); }
.mode-row .mode-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: rgba(255,255,255,.18); font-size: 26px; }
.mode-row:not(.urgent) .mode-icon { background: var(--sky); }
.mode-row strong, .mode-row small { display: block; }
.mode-row strong { font-size: 18px; }
.mode-row small { margin-top: 5px; color: inherit; opacity: .78; line-height: 1.35; }
.mode-row .chevron { color: inherit; }

.scene-tabs { position: sticky; top: 68px; z-index: 5; padding: 10px 0 12px; background: var(--bg); }
.mode-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 20px; color: var(--navy); background: var(--sky); font-size: 11px; font-weight: 800; }

.page-title { margin: 5px 0 6px; font-size: 28px; line-height: 1.15; }
.page-lead { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.list-stack { display: grid; gap: 10px; }

.list-card {
  width: 100%;
  min-height: 62px;
  padding: 10px 13px;
  border-radius: 17px;
  display: grid;
  grid-template-columns: 46px 1fr 25px;
  align-items: center;
  gap: 11px;
}

.list-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: var(--sky); font-size: 23px; }
.list-card strong { display: block; font-size: 16px; line-height: 1.3; }
.list-card small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.35; }
.chevron { color: var(--blue); font-size: 22px; }

.phrase-card {
  min-height: 72px;
  padding: 13px 14px 13px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
  border-width: 2px;
}
.phrase-card strong { font-weight: 750; }
.phrase-card small { color: var(--muted); }
.phrase-action {
  width: 32px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: transparent;
  font-size: 29px;
  line-height: 1;
}
.phrase-card:hover { border-color: var(--blue); background: var(--sky); }

.result-card { border-radius: 25px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow); }
.result-translation { padding: 18px 20px; background: var(--sky); color: var(--navy); font-weight: 700; line-height: 1.45; }
.result-main { padding: 28px 21px; text-align: center; }
.japanese { margin: 0; font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif; font-size: 29px; font-weight: 800; line-height: 1.5; }
.hiragana { margin: 18px 0 5px; color: var(--success); font-family: "Yu Gothic", sans-serif; font-size: 17px; line-height: 1.5; }
.romaji { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.audio-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.primary-button, .secondary-button { min-height: 52px; border-radius: 15px; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; color: white; background: var(--blue); }
.secondary-button { border: 1px solid #b9cde0; color: var(--navy); background: var(--surface); }
.utility-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 21px 21px; }

.notice { padding: 14px 16px; border: 1px solid #f0d9a8; border-radius: 14px; color: #6a4a12; background: #fff8e8; font-size: 12px; line-height: 1.5; margin-top: 15px; }
html[data-theme="dark"] .notice { border-color: #64522f; color: #f5d18d; background: #2b2418; }

.empty-state { text-align: center; padding: 54px 20px; }
.empty-state .empty-icon { font-size: 52px; }
.empty-state h2 { margin: 15px 0 8px; }
.empty-state p { color: var(--muted); line-height: 1.5; }

.about-card { padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.about-card h2 { margin-top: 0; }
.about-card p, .about-card li { color: #526579; line-height: 1.65; }
.credit { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-weight: 700; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 520px);
  height: calc(68px + env(safe-area-inset-bottom));
  padding: 7px 22px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.nav-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.nav-button span { display: block; margin-bottom: 2px; font-size: 22px; }
.nav-button.active { color: var(--blue); }
.nav-button:disabled { color: var(--muted); opacity: .34; cursor: default; }

.ad-dialog { width: min(calc(100% - 32px), 450px); border: 0; border-radius: 23px; padding: 18px; box-shadow: 0 22px 70px rgba(0,0,0,.28); }
.ad-dialog::backdrop, .staff-dialog::backdrop, .about-dialog::backdrop { background: var(--overlay); }
.ad-label { text-align: center; color: var(--muted); font-size: 10px; letter-spacing: .16em; font-weight: 800; }
.ad-placeholder { min-height: 280px; margin: 13px 0 15px; border-radius: 17px; display: grid; place-content: center; text-align: center; background: var(--bg); border: 1px dashed #9dabb8; color: var(--muted); }
.ad-placeholder span { font-size: 22px; font-weight: 800; }
.ad-placeholder small { max-width: 240px; margin-top: 9px; line-height: 1.5; }
.ad-dialog .primary-button { width: 100%; }

.toast { position: fixed; left: 50%; bottom: 88px; transform: translate(-50%, 15px); padding: 11px 16px; border-radius: 30px; background: #172433; color: white; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.staff-dialog { width: min(100%, 520px); max-width: 520px; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: 0; border: 0; background: var(--surface); color: var(--ink); }
.staff-wrap { min-height: 100%; padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.staff-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.staff-top strong { color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.staff-close { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 10px 14px; font-weight: 800; cursor: pointer; }
.staff-message { flex: 1; display: grid; place-content: center; text-align: center; padding: 25px 5px; }
.staff-message p { margin: 0; font-family: "Yu Gothic", sans-serif; font-size: clamp(34px, 10vw, 54px); font-weight: 800; line-height: 1.55; }
.staff-audio { width: 100%; min-height: 54px; }
.staff-answer-panel { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.staff-answer-panel h2 { margin: 0 0 5px; font-size: 17px; }
.staff-answer-panel > p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.staff-answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.staff-answer { min-height: 54px; padding: 9px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg); color: var(--ink); font-family: "Yu Gothic", sans-serif; font-weight: 700; cursor: pointer; }
.staff-reply { margin-top: 13px; padding: 15px; border-radius: 14px; background: var(--sky); color: var(--navy); text-align: center; font-size: 18px; font-weight: 800; }

.about-dialog { width: min(calc(100% - 30px), 470px); max-height: calc(100dvh - 38px); padding: 0; border: 0; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 22px 70px rgba(0,0,0,.32); }
.modal-head { padding: 16px 17px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body p, .modal-body li { color: var(--muted); line-height: 1.65; }
.modal-body h3 { margin: 4px 0 8px; }
.modal-body ul { padding-left: 22px; }
.modal-caution { padding: 12px 13px; border-radius: 13px; background: var(--sky); }
.menu-button { font-size: 22px; }
.direction-nav { color: var(--blue); }
.language-control { min-width: 0; display: grid; place-items: center; gap: 1px; color: var(--blue); font-size: 10px; font-weight: 800; cursor: pointer; }
.language-control span { line-height: 1; }
.language-control select { max-width: 118px; min-height: 28px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface); font: inherit; font-size: 11px; }

@media (min-width: 521px) { body { padding: 18px 0; } .app-shell { min-height: calc(100dvh - 36px); border-radius: 26px; overflow: hidden; } .topbar { position: relative; } }
@media (max-width: 350px) { .scene-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .audio-actions { grid-template-columns: 1fr; } .staff-answer-grid { grid-template-columns: 1fr; } }
