/* Chrome stays neutral so the court carries the warmth. Light and dark are both
   first class: a coach in a sunlit gym needs the light one. */
:root {
  color-scheme: light dark;
  --background: #F7F5F2;
  --panel: #FFFFFF;
  --panel-raised: #EEEAE5;
  --border: #E2DDD6;
  --text: #17191C;
  --text-dim: #6B7078;
  --accent: #E05A33;
  --accent-blue: #1F6FEB;
  --good: #1A7F37;
  --bad: #CF222E;
  --court-line: #FBF8F2;
  --shadow: 0 10px 30px rgba(20, 22, 26, 0.14);
  --role-setter: #A84B00;
  --role-oh: #3777BE;
  --role-mb: #895CD2;
  --role-op: #454A54;
  --role-lib: #8F7028;
  --floor: #D8AC78;
  --rounded: ui-rounded, "SF Pro Rounded", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --settings-width: 350px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #14161A;
    --panel: #1B1E23;
    --panel-raised: #24282F;
    --border: #2E333A;
    --text: #ECEDEF;
    --text-dim: #9AA0A8;
    --accent: #F78166;
    --accent-blue: #58A6FF;
    --good: #3FB950;
    --bad: #F85149;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ---- Layout ---- */

.app {
  display: grid;
  grid-template-columns: var(--settings-width) minmax(0, 1fr);
  min-height: 100vh;
}

.settings {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  border-right: 1px solid var(--border);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 22.37%; flex: none; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.brand p { margin: 1px 0 0; color: var(--text-dim); font-size: 13px; }
.settings-done { display: none; }

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 28px;
  overscroll-behavior: contain;
}

.main {
  min-width: 0;
  padding: 0 24px 40px;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.32);
}

/* Tablets: Team & Settings becomes a sheet, rotation controls move above the courts. */
@media (max-width: 1099px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .settings {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    height: auto;
    border-right: 0;
    box-shadow: var(--shadow);
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    visibility: hidden;
  }
  body.settings-open .settings { transform: none; visibility: visible; }
  .settings-done { display: inline-flex; }
}

@media (min-width: 1100px) {
  #team-button { display: none; }
  .coaching { display: none !important; }
}

/* ---- Groups ---- */

.group { margin-top: 18px; }
.group h2 {
  margin: 0 0 6px 4px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 12px;
}
.card.list { padding: 0 0 0 12px; }

.footnote {
  margin: 6px 4px 0;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.35;
}

.list-button, .switch-row, .select-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px 0 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.card.list > :last-child { border-bottom: 0; }
.list-button { color: var(--accent-blue); }
.list-button i { width: 20px; text-align: center; }
.list-button:hover { color: var(--text); }

.switch-row > span:first-child, .select-row > span:first-child { flex: 1; }
.switch-row { cursor: pointer; user-select: none; }
/* Keep hidden inputs inside the sidebar's scroll area. Without a positioned row,
   their containing block is the sticky sidebar and they extend the whole page. */
.switch-row { position: relative; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  background: var(--panel-raised);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background 0.18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}
.switch-row input:checked + .switch { background: var(--accent-blue); box-shadow: none; }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.switch-row.plain { border: 0; padding: 0; }

.select-row select {
  max-width: 55%;
  padding: 6px 8px;
  color: var(--text-dim);
  background: var(--panel-raised);
  border: 0;
  border-radius: 8px;
}

/* ---- Buttons ---- */

.text-button {
  min-height: 44px;
  padding: 0 4px;
  color: var(--accent-blue);
  background: none;
  border: 0;
}
.text-button.strong { font-weight: 600; }

.button {
  min-height: 40px;
  padding: 0 16px;
  color: var(--text);
  background: var(--panel-raised);
  border: 0;
  border-radius: 10px;
  font-weight: 500;
}
.button.primary { color: #fff; background: var(--accent-blue); font-weight: 600; }
.button.destructive { color: #fff; background: var(--bad); font-weight: 600; }
.button:disabled { opacity: 0.45; }

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--panel-raised);
  border-radius: 9px;
}
.segment {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.segment[aria-checked="true"] {
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  .segment[aria-checked="true"] { background: #5A5E66; }
}
.system-segmented .segment { min-height: 40px; font-size: 15px; }

/* ---- Toolbar ---- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  margin: 0 -24px;
  padding: 8px 24px;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
}

.setup-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 4px 12px 4px 4px;
  background: none;
  border: 0;
  border-radius: 10px;
  text-align: left;
}
.setup-button:hover { background: var(--panel-raised); }
.setup-text { display: grid; min-width: 0; padding-left: 8px; }
.setup-name {
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setup-system { color: var(--text-dim); font-size: 12px; }
.setup-button i { color: var(--accent); font-size: 12px; width: 12px; flex: none; }

.toolbar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  color: var(--accent-blue);
  background: var(--panel);
  border: 0;
  border-radius: 999px;
  font-weight: 500;
}
.tool-button i.fa-chevron-down { font-size: 10px; width: 10px; flex: none; }
.tool-button.icon-only { width: 40px; justify-content: center; padding: 0; }
.tool-button:hover { background: var(--panel-raised); }

/* ---- Banners ---- */

.save-banner {
  margin: 8px 0;
  padding: 10px 14px;
  color: var(--text);
  background: var(--panel);
  border-left: 4px solid var(--bad);
  border-radius: 10px;
}
.save-banner strong { display: block; color: var(--bad); }
.save-banner p { margin: 2px 0 6px; font-size: 13px; color: var(--text-dim); }
.save-banner .banner-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }

.import-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin: 8px 0 16px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--accent-blue);
  border-radius: 14px;
}
.import-preview h2 { margin: 0 0 2px; font-size: 17px; }
.import-preview p { margin: 0; max-width: 60ch; color: var(--text-dim); font-size: 14px; }
.import-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.import-form label { display: flex; align-items: center; gap: 8px; color: var(--text-dim); }
.import-form input {
  width: 220px;
  min-height: 40px;
  padding: 0 10px;
  color: var(--text);
  background: var(--panel-raised);
  border: 0;
  border-radius: 10px;
}
.import-actions { display: flex; gap: 8px; }
body.is-previewing #team-button,
body.is-previewing #edit-button,
body.is-previewing #share-button,
body.is-previewing .drag-hint { display: none; }
body.is-previewing .setup-button { pointer-events: none; }
body.is-previewing .setup-button i { display: none; }
@media (min-width: 1100px) {
  body.is-previewing .app { grid-template-columns: minmax(0, 1fr); }
  body.is-previewing .settings { display: none; }
}

/* ---- Rotation controls ---- */

.coaching {
  display: grid;
  gap: 10px;
  margin: 4px 0 14px;
}
.rotation-selector, .status-strip, #phone-zone-row { display: none; }

.rotation-selector {
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 3px;
  background: var(--panel);
  border-radius: 12px;
}
.rotation-button {
  position: relative;
  min-height: 42px;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-radius: 9px;
  font-weight: 500;
}
.rotation-button[aria-current="true"] { color: var(--text); background: var(--panel-raised); }
.rotation-button .flag {
  position: absolute;
  top: 5px;
  right: calc(50% - 22px);
  color: var(--bad);
  font-size: 9px;
}

.passer-bar { display: grid; gap: 8px; }
.passer-bar-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.passer-bar-header strong { font-size: 15px; font-weight: 600; }
.passer-row { display: flex; justify-content: space-between; gap: 4px; }
@media (min-width: 760px) {
  .passer-row { justify-content: flex-start; gap: 14px; }
}
.tone-plain { color: var(--text-dim); }
.tone-caution { color: var(--accent); }
.tone-problem { color: var(--bad); }
.note { display: flex; gap: 6px; margin: 0; font-size: 13px; }
.note i { font-size: 11px; line-height: 18px; }

.status-strip { align-items: center; justify-content: space-between; gap: 8px; min-height: 0; }
.status-strip:empty { display: none !important; }
.setter-label { font-size: 14px; }
.overlap-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: none;
  border: 0;
  font-size: 13px;
  font-weight: 600;
}
.overlap-link.here { color: var(--bad); }
.overlap-link.elsewhere { color: var(--accent); }

@media (max-width: 759px) {
  .rotation-selector { display: grid; }
  .status-strip { display: flex; padding: 0 4px; }
  #phone-zone-row { display: flex; }
}

/* ---- Passer chips ---- */

.passer-chip {
  position: relative;
  display: inline-grid;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  --chip: 44px;
}
.passer-chip .chip-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--chip);
  height: var(--chip);
  border-radius: 50%;
}
.passer-chip[aria-pressed="true"] .chip-ring { box-shadow: inset 0 0 0 2px var(--court-line); }
@media (prefers-color-scheme: light) {
  .passer-chip[aria-pressed="true"] .chip-ring { box-shadow: inset 0 0 0 2px var(--court-line), 0 0 0 1px var(--border); }
}
.passer-chip .chip-disc {
  display: grid;
  place-content: center;
  width: calc(var(--chip) - 7px);
  height: calc(var(--chip) - 7px);
  color: var(--text-dim);
  background: var(--panel-raised);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--border);
  font-family: var(--rounded);
  font-weight: 600;
  line-height: 1;
  text-align: center;
}
.passer-chip[aria-pressed="true"] .chip-disc {
  color: #fff;
  background: var(--role);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.chip-name { display: block; font-size: calc(var(--chip) * 0.30); text-transform: uppercase; white-space: nowrap; }
.chip-name.number { font-size: calc(var(--chip) * 0.36); }
.chip-role { display: block; margin-top: 1px; font-size: calc(var(--chip) * 0.18); }
.passer-chip .chip-caption {
  max-width: 64px;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.passer-chip:disabled { opacity: 0.55; }

.count-control .segment { min-height: 30px; font-variant-numeric: tabular-nums; }
.passer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 12px 10px;
  margin: 14px 0 10px;
}
.receiving-summary { display: flex; gap: 6px; margin: 0; font-size: 13px; }

/* ---- Roster ---- */

.roster { padding: 0 0 0 12px; }
.roster-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--border);
}
.roster-row:last-child { border-bottom: 0; }
.role-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--role);
  border-radius: 50%;
  font-family: var(--rounded);
  font-size: 13px;
  font-weight: 700;
}
.roster-fields { display: grid; gap: 6px; min-width: 0; }
.name-field { display: flex; align-items: center; gap: 8px; }
.roster-row input {
  width: 100%;
  min-width: 0;
  padding: 2px 0;
  background: none;
  border: 0;
  outline: none;
}
.roster-row input[data-field="name"] { text-transform: uppercase; font-size: 15px; }
.roster-row input::placeholder { color: var(--text-dim); opacity: 0.7; text-transform: none; }
.name-count { flex: none; color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.number-field { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.number-field span { color: var(--text-dim); }
.roster-preview {
  display: grid;
  justify-items: center;
  width: 70px;
  padding: 3px 6px;
  color: var(--text-dim);
  background: var(--panel-raised);
  border-radius: 999px;
  font-family: var(--rounded);
  font-weight: 600;
  line-height: 1.15;
}
.roster-preview .preview-name { max-width: 100%; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.roster-preview .preview-role { font-size: 9px; }

.image-button { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 3px 0; border: 0; background: none; color: var(--accent-blue); text-align: left; font-size: 14px; }
.image-button img { width: 32px; height: 32px; flex: none; border-radius: 50%; object-fit: cover; }
#team-logo-button img { border-radius: 6px; object-fit: contain; background: var(--panel-raised); }
.watermark-controls { padding: 10px 14px; }
.opacity-label { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0 6px; font-size: 14px; }
.opacity-label output { color: var(--text-dim); font-variant-numeric: tabular-nums; }
#watermark-opacity, #photo-zoom { width: 100%; min-height: 32px; accent-color: var(--accent-blue); }
.photo-viewport { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; background: #000; touch-action: none; cursor: grab; }
.photo-viewport:active { cursor: grabbing; }
.photo-viewport img { position: absolute; max-width: none; pointer-events: none; user-select: none; }
.photo-mask { position: absolute; inset: 0; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 150px #0009; pointer-events: none; }
.photo-editor #photo-reset { min-height: 44px; margin-top: 8px; }
@media (max-height: 700px) { .photo-viewport { max-width: 260px; margin-inline: auto; } }

/* ---- Legend ---- */

.legend { display: grid; gap: 10px; margin: 0; padding: 12px; list-style: none; }
.legend li { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.legend .swatch { width: 16px; height: 16px; margin: 0 7px; border-radius: 50%; background: var(--role); }
.legend svg { width: 30px; height: 30px; flex: none; }

.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 22px 4px 0;
  font-size: 13px;
}
.site-links a { color: var(--text-dim); text-decoration: none; }
.site-links a:hover { color: var(--text); }

/* ---- Courts ---- */

.courts {
  container-type: inline-size;
  max-width: 1500px;
}
.courts-inner {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@container (min-width: 900px) {
  .courts-inner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.court-card {
  display: grid;
  gap: 8px;
  padding: 10px 10px 10px;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.court-card.is-active { box-shadow: inset 0 0 0 2px var(--accent-blue); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
}
.card-title {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
}
.card-title strong { font-size: 16px; font-weight: 600; }
.court-card.is-active .card-title strong { color: var(--accent-blue); }
.card-meta { color: var(--text-dim); font-size: 12px; }
.card-meta.problem { color: var(--bad); }
.card-flag {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--bad);
  background: none;
  border: 0;
  border-radius: 50%;
}
.card-flag:hover { background: var(--panel-raised); }
.card-zone { display: flex; justify-content: flex-end; padding: 0 2px; }
.court-view-button { color: var(--accent-blue); background: var(--panel-raised); border-radius: 12px; min-height: 44px; }
#phone-zone-row { justify-content: flex-end; }

.court-frame { position: relative; }
.court-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* Players draw their own focus ring; a box outline doesn't fit a disc. */
.court-svg .player { outline: none; }
.court-svg.is-interactive .player { cursor: grab; }
.court-svg.is-interactive .player:active { cursor: grabbing; }
/* Reserve a gesture before Safari decides between dragging and scrolling. */
.court-svg.is-draggable .player-hit { touch-action: none; }
.court-svg .player,
.court-svg .player-label,
.court-svg .player-position {
  transition: transform 0.38s cubic-bezier(0.25, 0.9, 0.3, 1);
}
.court-svg .player.is-held,
.court-svg .player-label.is-held,
.court-svg .player-position.is-held { transition: none; }

.drag-hint { margin: 12px 4px 0; color: var(--text-dim); font-size: 13px; }

.native-app-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin: 20px 4px 0;
  padding: 10px 12px;
  color: var(--accent-blue);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
}
.native-app-link img { flex: none; border-radius: 22.37%; }
.native-app-link strong { display: block; font-size: 15px; font-weight: 600; }
.native-app-link span span { display: block; margin-top: 2px; color: var(--text-dim); font-size: 12px; }
.native-app-link:hover { background: var(--panel-raised); }

/* Phones: one rotation at a time, swiped like pages. */
@media (max-width: 759px) {
  .main { padding: 0 16px 32px; }
  .toolbar { margin: 0 -16px; padding: 6px 16px; gap: 4px; }
  .setup-button { flex: 1; gap: 4px; padding: 4px 0; }
  .setup-text { padding-left: 0; }
  .setup-name { font-size: 15px; }
  .tool-button { padding: 0 10px; }
  #team-button { width: 40px; justify-content: center; padding: 0; }
  #team-button .button-label { display: none; }
  .courts { max-width: none; margin: 0 -16px; }
  .courts-inner {
    display: flex !important;
    gap: 0 !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .courts-inner::-webkit-scrollbar { display: none; }
  .court-card {
    flex: 0 0 100%;
    padding: 0 16px;
    background: none;
    box-shadow: none !important;
    scroll-snap-align: center;
    scroll-snap-stop: always;
  }
  .card-head, .card-zone { display: none !important; }
  .settings { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  .court-svg .player, .court-svg .player-label, .court-svg .player-position, .settings, .switch, .switch::after { transition: none; }
}

/* ---- Menus, notices, dialogs ---- */

.menu {
  position: fixed;
  z-index: 70;
  min-width: 230px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 6px;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 0.5px var(--border);
}
.menu-section { padding: 6px 10px 2px; color: var(--text-dim); font-size: 12px; font-weight: 600; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 8px;
  text-align: left;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--panel-raised); outline: none; }
.menu-item i { width: 18px; color: var(--text-dim); text-align: center; }
.menu-item.destructive, .menu-item.destructive i { color: var(--bad); }
.menu-item:disabled { opacity: 0.4; }
.menu-item .check { margin-left: auto; color: var(--accent-blue); }
.menu-item .item-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-divider { height: 1px; margin: 5px 6px; background: var(--border); }

.notices {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  width: min(460px, calc(100vw - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 4px 6px 4px 14px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow), 0 0 0 0.5px var(--border);
  font-size: 14px;
  pointer-events: auto;
  animation: notice-in 0.22s ease-out;
}
.notice > span { flex: 1; }
.notice i { color: var(--text-dim); }
.notice .text-button { font-weight: 600; }
@keyframes notice-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .notice { animation: none; } }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  top: 70px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  color: var(--background);
  background: var(--text);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

dialog {
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 0;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.36); }
dialog h2 { margin: 0; font-size: 17px; }
dialog p { margin: 8px 0 0; color: var(--text-dim); font-size: 14px; line-height: 1.4; }

dialog.alert { width: min(360px, calc(100vw - 32px)); border-radius: 16px; }
dialog.alert form { padding: 20px; }
.alert-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

dialog.sheet { width: min(460px, calc(100vw - 24px)); border-radius: 18px; }
dialog.sheet form { padding: 0 20px 22px; }
.sheet-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin: 0 -8px 8px;
}
.sheet-header :first-child { justify-self: start; }
.sheet-header :last-child { justify-self: end; }
.field-label { display: block; margin: 16px 0 6px 4px; color: var(--text-dim); font-size: 13px; font-weight: 600; }
.field {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 12px;
  background: var(--panel-raised);
  border: 0;
  border-radius: 10px;
}
.field-label + .field { margin-top: 0; }
.field-error { color: var(--bad) !important; }

.qr-code {
  display: grid;
  place-items: center;
  margin: 16px auto 0;
  padding: 12px;
  width: max-content;
  background: #fff;
  border-radius: 12px;
}
.qr-code canvas, .qr-code img { display: block; width: 208px; height: 208px; }

.recovery {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--background);
}
.recovery-panel { max-width: 420px; text-align: center; }
.recovery-panel > i { color: var(--text-dim); font-size: 38px; }
.recovery-panel h2 { margin: 14px 0 6px; font-size: 21px; }
.recovery-panel p { margin: 0; color: var(--text-dim); }
.recovery-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
