/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

:root {
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #1a2230;
  --border: #263041;
  --text: #e6edf5;
  --text-muted: #8a97a8;
  --primary: #4cc2ff;
  --primary-hover: #2fb1f5;
  --on-primary: #04121c;
  --green: #3ddc84;
  --yellow: #fad65c;
  --red: #ff6b6b;
  --mayday: #ff3b3b;
  --panpan: #ff9f1a;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Roboto Mono", monospace;
}

html,
body {
  height: 100%;
  font-family: "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

input,
button,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.en {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85em;
  font-size: max(12px, 0.85em);
}

.error {
  color: var(--red);
  font-size: 14px;
  margin-bottom: 16px;
}

.plan-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Buttons ===== */
.btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 15px;
  transition: background 0.15s, border-color 0.15s;
}

.btn.primary {
  background: var(--primary);
  color: var(--on-primary);
}

@media (hover: hover) {
  .btn.primary:hover {
    background: var(--primary-hover);
  }
}

.btn.outline {
  background: transparent;
  border-color: var(--border);
}

@media (hover: hover) {
  .btn.outline:hover {
    border-color: var(--primary);
  }
}

.btn.small {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
  min-height: 44px;
}

/* ===== Lobby ===== */
.lobby-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  padding-top: calc(24px + var(--sat));
  padding-bottom: calc(24px + var(--sab));
}

.lobby-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  min-width: 0;
}

.logo {
  text-align: center;
  margin-bottom: 24px;
}

.logo-icon {
  font-size: 40px;
}

.logo h1 {
  font-size: 22px;
  margin-top: 8px;
  line-height: 1.35;
  text-wrap: balance;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 6px;
}

/* MOTTO-20261031-01：全ワールド共通の一文。暗い面なので文字は白 */
.aw-motto {
  margin: 8px auto 0;
  max-width: 720px;
  text-align: center;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: clamp(15px, 3.8vw, 19px);
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-wrap: balance;
  color: #fff;
}

.aw-motto-dash {
  color: #ea6f0a;
}

.role-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface-2);
}

.role-card h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.role-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.role-form label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.callsign-input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 24px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  margin-bottom: 12px;
}

.callsign-input:focus {
  border-color: var(--primary);
}

.callsign-input::placeholder {
  color: var(--text-muted);
  opacity: 0.4;
}

.radio-btn {
  font-size: 16px;
}

/* ===== Shared radio header ===== */
.radio-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + var(--sat));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.head-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  flex: none;
  font-size: 18px;
}

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

.head-kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.head-main h1,
.head-main h2 {
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.callsign-tag {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 6px;
}

.presence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.presence .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.presence.on {
  color: var(--green);
}

.presence.on .dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* ===== Transcript ===== */
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transcript-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.8;
}

.tx {
  max-width: 88%;
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.tx.tx-mine {
  align-self: flex-end;
  border-color: rgba(76, 194, 255, 0.45);
  background: rgba(76, 194, 255, 0.08);
}

.tx.tx-mayday {
  border: 2px solid var(--mayday);
  background: rgba(255, 59, 59, 0.14);
}

.tx.tx-panpan {
  border: 2px solid var(--panpan);
  background: rgba(255, 159, 26, 0.12);
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tx-from {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

.tx-meta time {
  margin-left: auto;
  font-family: var(--mono);
}

.tx-text {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

/* ===== Composer (4W) ===== */
.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fourw {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.w {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 14px;
  min-width: 0;
}

.w b {
  font-family: inherit;
  color: var(--text-muted);
  font-weight: 400;
}

.w.auto {
  background: var(--surface-2);
  color: var(--text-muted);
}

.w.field-w {
  flex: 1 1 200px;
  background: var(--bg);
  padding-top: 0;
  padding-bottom: 0;
}

.w.field-w:focus-within {
  border-color: var(--primary);
}

.w.wide {
  flex-basis: 100%;
}

.w input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 16px;
  padding: 4px 0;
  min-height: 44px;
}

.w input::placeholder {
  font-family: "Helvetica Neue", "Hiragino Sans", "Noto Sans JP", Arial, sans-serif;
  color: var(--text-muted);
  opacity: 0.6;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.chip {
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  min-height: 44px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}

@media (hover: hover) {
  .chip:hover {
    border-color: var(--primary);
  }
}

.preview {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--primary);
  min-height: 1.4em;
  word-break: break-word;
}

.preview:empty::before {
  content: "\00a0";
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.words {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.word {
  flex: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

@media (hover: hover) {
  .word:hover {
    border-color: var(--primary);
  }
}

.word.toggle.on {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #1a1400;
}

.btn-transmit {
  flex: none;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  min-height: 44px;
  font-weight: 800;
  font-size: 15px;
}

.btn-transmit .en {
  color: inherit;
  opacity: 0.7;
}

.btn-transmit:disabled {
  opacity: 0.35;
  cursor: default;
}

.emergency {
  display: flex;
  gap: 8px;
}

.btn-emergency {
  flex: 1;
  background: transparent;
  border: 2px solid;
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 44px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 14px;
}

.btn-emergency.mayday {
  border-color: var(--mayday);
  color: var(--mayday);
}

.btn-emergency.panpan {
  border-color: var(--panpan);
  color: var(--panpan);
}

.btn-emergency.armed.mayday {
  background: var(--mayday);
  color: #fff;
}

.btn-emergency.armed.panpan {
  background: var(--panpan);
  color: #1a0f00;
}

.composer-note {
  font-size: 13px;
  color: var(--red);
}

.composer-note:empty {
  display: none;
}

/* ===== Pilot screen ===== */
.radio-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ===== Tower console ===== */
.console {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  height: 100dvh;
}

.board {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
  padding-bottom: var(--sab);
}

.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + var(--sat));
  border-bottom: 1px solid var(--border);
}

.board-head h1 {
  font-size: 20px;
}

.board-op {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sound-btn {
  margin: 10px 16px 0;
  background: rgba(255, 159, 26, 0.12);
  border: 1px solid var(--panpan);
  color: var(--panpan);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.sw.f-green {
  background: var(--green);
}

.sw.f-yellow {
  background: var(--yellow);
  opacity: 0.7;
}

.sw.f-red {
  background: var(--red);
  opacity: 0.6;
}

.sw.f-gray {
  background: #4a5566;
}

.rooms {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rooms-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.board .plan-note {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
}

.room button {
  position: relative;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--border);
  border-left: 6px solid #4a5566;
  border-radius: var(--radius-sm);
  padding: 10px 12px 10px 12px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room.selected button {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.room.f-green button {
  background: rgba(61, 220, 132, 0.2);
  border-left-color: var(--green);
}

.room.f-yellow button {
  background: rgba(250, 214, 92, 0.1);
  border-left-color: rgba(250, 214, 92, 0.7);
}

.room.f-red button {
  background: rgba(255, 107, 107, 0.1);
  border-left-color: rgba(255, 107, 107, 0.6);
}

.room.f-gray button {
  color: var(--text-muted);
}

.room.em-mayday button {
  background: rgba(255, 59, 59, 0.22);
  border: 2px solid var(--mayday);
  border-left: 6px solid var(--mayday);
  animation: em-pulse 1.2s ease-in-out infinite;
}

.room.em-panpan button {
  background: rgba(255, 159, 26, 0.18);
  border: 2px solid var(--panpan);
  border-left: 6px solid var(--panpan);
}

@keyframes em-pulse {
  50% {
    background: rgba(255, 59, 59, 0.08);
  }
}

.room-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-cs {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.room.f-gray .room-cs {
  color: var(--text-muted);
}

.room-em {
  font-size: 12px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--mayday);
  color: #fff;
}

.em-panpan .room-em {
  background: var(--panpan);
  color: #1a0f00;
}

.room-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.room-ago {
  margin-left: auto;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.room-last {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 14px;
}

.room-online {
  position: absolute;
  right: 10px;
  bottom: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a5566;
}

.room-online.on {
  background: var(--green);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pane-empty {
  margin: auto;
  color: var(--text-muted);
  font-size: 14px;
}

.pane-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.pane .head-back {
  display: none;
}

.btn-ack {
  background: var(--mayday);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  min-height: 44px;
  font-size: 12px;
  font-weight: 800;
}

/* ===== Mobile ===== */
@media (max-width: 760px) {
  .radio-screen {
    border: none;
  }

  .console {
    grid-template-columns: 1fr;
  }

  .console .pane {
    display: none;
  }

  .console.pane-open .board {
    display: none;
  }

  .console.pane-open .pane {
    display: flex;
  }

  .pane .head-back {
    display: block;
  }

  .lobby-card {
    padding: 28px 16px;
  }
}

/* ===== Airffic ID（共通ログイン・任意） ===== */
.airffic-login {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 20px;
  min-width: 0;
}

.airffic-login > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.airffic-login .btn {
  max-width: 100%;
}

.airffic-login-title {
  font-size: 13px;
  color: var(--text-muted);
}

.airffic-email {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.airffic-email input {
  flex: 1 1 180px;
  width: 0;
  min-width: 0;
  padding: 10px 12px;
  font-size: 16px;
  min-height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.airffic-email input:focus {
  border-color: var(--primary);
}

.airffic-email input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.airffic-email .btn {
  flex: 1 0 auto;
  width: auto;
  white-space: nowrap;
}

#airffic-signed-in .btn {
  align-self: flex-start;
  width: auto;
}

.airffic-delete {
  font-size: 12px;
  color: var(--text-muted);
}

.airffic-delete summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.airffic-delete > * + * {
  margin-top: 8px;
}

.airffic-delete label {
  flex: 1 1 100%;
}

.airffic-login-note {
  font-size: 12px;
  color: var(--text-muted);
}

.airffic-id {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ===== 左上の地球儀・右上のしるしと Airffic ID（HOME-GLOBES-20261031-02） ===== */
.aw-globe {
  position: fixed;
  left: 12px;
  top: calc(12px + var(--sat));
  z-index: 50;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--text);
}

.aw-corner {
  position: fixed;
  right: 12px;
  top: calc(12px + var(--sat));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
}

.aw-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
}

.lobby-container {
  padding-top: calc(72px + var(--sat));
}

/* LANDMARK-20261103-01：見ている人の国の名所（<airffic-landmark>）。場所は最初から確保して画面を動かさない */
.aw-landmark { display: flex; width: min(220px, 60vw); height: 104px; margin: 0 auto 8px; }

/* Keep the message-word reference easy to open on phones. */
.composer details.plan-note > summary{min-height:44px;padding:12px 0;cursor:pointer}

/* SITE-INTRO-VIDEO-20261118：中央そろえの見出しの下に置く紹介動画 */
.logo .aw-intro-video { margin-left: auto; margin-right: auto; text-align: center; }
