/* ===========================================================
   HACO Umpires Hub — Stylesheet
   Responsive across mobile (<768px), tablet (768-1199px),
   and desktop (≥1200px). Accessibility-first.
   =========================================================== */

:root {
  --indigo: #29265B;
  --indigo-deep: #1B1842;
  --gold: #F6AF33;
  --gold-deep: #8B5A00;
  --gold-soft: #FFF4DD;
  --bg: #FAFAF5;
  --surface: #FFFFFF;
  --text: #141414;
  --text-muted: #555555;
  --border: #C8C3B5;
  --danger: #B0322F;
  --success: #2C5F2D;
  --scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --sidenav-width: 260px;
  --content-max: 880px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { font-size: calc(17px * var(--scale)); -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ===========================================================
   APP LAYOUT
   =========================================================== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-areas: "main";
  grid-template-columns: 1fr;
}

.main {
  grid-area: main;
  min-width: 0;
  padding-bottom: calc(96px + var(--safe-bottom));
  padding-top: var(--safe-top);
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* ===========================================================
   SIDE NAV — desktop only
   =========================================================== */
.sidenav {
  display: none;
}

@media (min-width: 1024px) {
  .app {
    grid-template-areas: "sidenav main";
    grid-template-columns: var(--sidenav-width) 1fr;
  }

  .sidenav {
    grid-area: sidenav;
    display: flex;
    flex-direction: column;
    background: var(--indigo);
    color: white;
    padding: 24px 16px;
    height: 100vh;
    position: sticky;
    top: 0;
    border-right: 4px solid var(--gold);
  }

  .sidenav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding: 6px 8px;
    border-radius: 12px;
    cursor: pointer;
  }
  .sidenav-brand:hover { background: rgba(255,255,255,0.06); }
  .sidenav-brand .crest { background: var(--gold); color: var(--indigo); }
  .sidenav-brand .brand-name { color: white; font-size: 1.1rem; }
  .sidenav-brand .brand-sub { color: var(--gold); font-size: 0.78rem; opacity: 0.95; }

  .sidenav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
  }

  .sidenav-btn {
    background: transparent;
    border: 2px solid transparent;
    color: rgba(255,255,255,0.85);
    padding: 14px 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
    min-height: 56px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .sidenav-btn:hover { background: rgba(255,255,255,0.08); color: white; }
  .sidenav-btn.active {
    background: var(--gold);
    color: var(--indigo);
    border-color: var(--gold-deep);
  }
  .sidenav-icon {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    flex-shrink: 0;
  }
  .sidenav-icon svg { width: 22px; height: 22px; }

  .sidenav-footer {
    padding-top: 18px;
    border-top: 1.5px solid rgba(255,255,255,0.18);
    margin-top: 12px;
  }
  .sidenav-footer-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 8px;
    font-weight: 700;
  }

  /* Hide mobile chrome */
  .header { display: none !important; }
  .bottom-nav { display: none !important; }
  .main { padding-bottom: 32px; }
  .content { padding: 12px 32px 0; }
}

/* ===========================================================
   MOBILE HEADER
   =========================================================== */
.header {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border);
  gap: 10px;
  background: var(--bg);
  position: sticky;
  top: var(--safe-top);
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.crest {
  width: 44px; height: 44px;
  background: var(--indigo);
  color: var(--gold);
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; color: var(--indigo); line-height: 1.1; }
.brand-sub { font-size: 0.76rem; color: var(--text-muted); }

.font-toggle {
  display: flex;
  background: var(--surface);
  border: 2px solid var(--indigo);
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.font-toggle button {
  background: var(--surface);
  color: var(--indigo);
  border: none;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 10px;
  min-width: 38px;
  min-height: 40px;
  border-right: 2px solid var(--indigo);
}
.font-toggle button:last-child { border-right: none; }
.font-toggle button.active { background: var(--indigo); color: var(--gold); }
.font-toggle button:nth-child(1) { font-size: 0.85rem; }
.font-toggle button:nth-child(2) { font-size: 1rem; }
.font-toggle button:nth-child(3) { font-size: 1.2rem; }

@media (min-width: 1024px) {
  .sidenav .font-toggle {
    background: rgba(255,255,255,0.08);
    border-color: var(--gold);
  }
  .sidenav .font-toggle button {
    background: transparent;
    color: white;
    border-right-color: rgba(255,255,255,0.2);
  }
  .sidenav .font-toggle button.active { background: var(--gold); color: var(--indigo); }
}

/* ===========================================================
   WELCOME
   =========================================================== */
.welcome {
  margin: 18px 18px 0;
  padding: 18px 22px;
  background: var(--indigo);
  color: white;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}
.welcome::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.18;
}
.welcome h1 { font-size: 1.35rem; margin-bottom: 2px; position: relative; }
.welcome p { font-size: 0.9rem; opacity: 0.92; position: relative; }

@media (min-width: 1024px) {
  .welcome { margin: 6px 0 0; padding: 26px 32px; }
  .welcome h1 { font-size: 1.7rem; }
  .welcome p { font-size: 1rem; }
}

/* ===========================================================
   SECTIONS
   =========================================================== */
.section { padding: 22px 18px 0; }
.section:last-child { padding-bottom: 24px; }
.section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: '';
  width: 28px;
  height: 4px;
  background: var(--gold);
  border-radius: 2px;
  flex-shrink: 0;
}
.section-edit {
  margin-left: auto;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 1px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  min-height: 36px;
}
.section-edit:hover { border-color: var(--indigo); color: var(--indigo); }

@media (min-width: 1024px) {
  .section { padding: 28px 0 0; }
}

/* ===========================================================
   SHORTCUTS
   =========================================================== */
.links-row { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 768px) {
  .links-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (min-width: 1024px) {
  .links-row { grid-template-columns: 1fr 1fr 1fr; }
}

.link-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  min-height: 70px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.12s, transform 0.1s;
}
.link-btn:hover { border-color: var(--indigo); }
.link-btn:active { transform: scale(0.99); }
.link-btn.primary {
  background: var(--indigo);
  color: white;
  border-color: var(--indigo-deep);
}
.link-btn.primary:hover { border-color: var(--gold); }
.link-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--indigo);
  border: 2px solid var(--border);
}
.link-btn.primary .link-icon {
  background: var(--gold);
  color: var(--indigo);
  border-color: var(--gold-deep);
}
.link-text { flex: 1; min-width: 0; }
.link-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.link-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  word-break: break-all;
}
.link-btn.primary .link-meta { color: rgba(255,255,255,0.78); }
.link-arrow { color: var(--gold); font-size: 1.4rem; font-weight: 700; flex-shrink: 0; }
.link-btn:not(.primary) .link-arrow { color: var(--indigo); }
.link-ext {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(255,255,255,0.18);
  color: var(--gold);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  white-space: nowrap;
}
.link-btn:not(.primary) .link-ext {
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
}
.link-btn.add {
  background: transparent;
  border-style: dashed;
  border-color: var(--text-muted);
  justify-content: center;
  min-height: 56px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.92rem;
}
.link-btn.add:hover { border-color: var(--indigo); color: var(--indigo); }
.link-btn.add::before {
  content: '+';
  margin-right: 8px;
  font-size: 1.4rem;
  font-weight: 700;
}

/* ===========================================================
   NEWS
   =========================================================== */
.news-list { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 768px) {
  .news-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

.news-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-left-width: 6px;
  border-left-color: var(--gold-deep);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.1s;
}
.news-card:hover { border-color: var(--indigo); border-left-color: var(--gold-deep); }
.news-card.updated { border-left-color: var(--indigo); }
.news-card.updated:hover { border-color: var(--indigo); }
.news-card:active { transform: scale(0.99); }

.news-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 2px solid;
  white-space: nowrap;
}
.news-badge.new { background: var(--gold-soft); color: var(--gold-deep); border-color: var(--gold-deep); }
.news-badge.upd { background: #E8E7F0; color: var(--indigo); border-color: var(--indigo); }
.news-content { flex: 1; min-width: 0; }
.news-content h3 { font-size: 0.98rem; margin-bottom: 2px; line-height: 1.25; word-break: break-word; }
.news-content p { font-size: 0.78rem; color: var(--text-muted); }

/* ===========================================================
   TILES
   =========================================================== */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (min-width: 600px) { .tile-grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 1024px) { .tile-grid { grid-template-columns: 1fr 1fr 1fr; gap: 18px; } }
@media (min-width: 1280px) { .tile-grid { grid-template-columns: repeat(4, 1fr); } }

.tile {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px 16px;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  text-align: left;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.tile:hover {
  border-color: var(--indigo);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(41,38,91,0.12);
}
.tile:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.tile:active { transform: scale(0.98); }
.tile-icon {
  width: 58px; height: 58px;
  background: var(--indigo);
  color: var(--gold);
  border-radius: 14px;
  display: grid; place-items: center;
  margin-bottom: 14px;
}
.tile-icon svg { width: 30px; height: 30px; }
.tile-title { font-size: 1.05rem; font-weight: 700; line-height: 1.2; margin-bottom: 4px; }
.tile-meta { font-size: 0.76rem; color: var(--text-muted); line-height: 1.3; }
.tile-flag {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--gold);
  color: var(--gold-deep);
  border: 2px solid var(--gold-deep);
  border-radius: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 7px;
  text-transform: uppercase;
}
.tile-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tile-count::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* ===========================================================
   HELP BANNER (home)
   =========================================================== */
.help-banner {
  margin: 22px 18px 0;
  background: var(--indigo);
  color: white;
  border-radius: 20px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 3px solid var(--gold);
  flex-wrap: wrap;
}
@media (min-width: 1024px) { .help-banner { margin: 28px 0 0; padding: 22px; } }
.help-icon {
  width: 56px; height: 56px;
  background: var(--gold);
  color: var(--indigo);
  border-radius: 14px;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 1.8rem;
  font-weight: 700;
}
.help-content { flex: 1; min-width: 200px; }
.help-content h3 { font-size: 1.05rem; margin-bottom: 2px; }
.help-content p { font-size: 0.86rem; opacity: 0.92; line-height: 1.4; }
.help-cta {
  background: var(--gold);
  color: var(--indigo);
  font-weight: 700;
  border: none;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  min-height: 48px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===========================================================
   MOBILE BOTTOM NAV
   =========================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--surface);
  border-top: 2px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 0 calc(14px + var(--safe-bottom));
  z-index: 50;
}
.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  min-height: 64px;
}
.nav-btn.active { color: var(--indigo); }
.nav-icon {
  width: 38px; height: 38px;
  background: var(--bg);
  border-radius: 11px;
  display: grid; place-items: center;
  border: 2px solid var(--border);
  color: var(--text-muted);
}
.nav-btn.active .nav-icon {
  background: var(--indigo);
  color: var(--gold);
  border-color: var(--indigo);
}
.nav-icon svg { width: 20px; height: 20px; }

/* ===========================================================
   FILE LIST
   =========================================================== */
.page-title-bar {
  padding: 22px 18px 10px;
}
@media (min-width: 1024px) { .page-title-bar { padding: 8px 0 14px; } }
.page-title {
  font-size: 1.55rem;
  margin-bottom: 4px;
  margin-top: 14px;
  color: var(--indigo);
}
.page-title:first-child { margin-top: 0; }
.page-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
}
.header-back {
  background: var(--surface);
  border: 2px solid var(--indigo);
  color: var(--indigo);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 8px 14px 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.header-back::before { content: '‹'; font-size: 1.5rem; line-height: 1; }
.header-back:hover { background: var(--indigo); color: var(--gold); }

@media (min-width: 1024px) {
  .header-back { display: none; }
}

.file-list {
  padding: 8px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 1024px) { .file-list { padding: 8px 0 0; } }

.file-row {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  min-height: 72px;
  text-align: left;
  width: 100%;
  transition: border-color 0.12s, transform 0.1s;
}
.file-row:hover { border-color: var(--indigo); }
.file-row:active { transform: scale(0.99); }
.file-row.recent { border-left-width: 6px; border-left-color: var(--gold-deep); }
.file-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--indigo);
  color: var(--gold);
}
.file-icon.video { background: var(--gold-deep); color: white; }
.file-icon.doc { background: var(--success); color: white; }
.file-icon svg { width: 24px; height: 24px; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 0.97rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 4px;
  word-break: break-word;
}
.file-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.file-meta .dot { width: 3px; height: 3px; background: var(--text-muted); border-radius: 50%; flex-shrink: 0; }
.file-badge-mini {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1.5px solid;
}
.file-badge-mini.new { background: var(--gold-soft); color: var(--gold-deep); border-color: var(--gold-deep); }
.file-badge-mini.upd { background: #E8E7F0; color: var(--indigo); border-color: var(--indigo); }
.file-arrow { color: var(--text-muted); font-size: 1.4rem; flex-shrink: 0; font-weight: 700; }

.file-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
}

/* ===========================================================
   SEARCH
   =========================================================== */
.search-bar {
  padding: 0 18px 14px;
}
@media (min-width: 1024px) { .search-bar { padding: 0 0 14px; } }

.search-input-wrap {
  background: var(--surface);
  border: 2px solid var(--indigo);
  border-radius: 14px;
  display: flex;
  align-items: center;
  padding: 4px 4px 4px 16px;
}
.search-input-wrap:focus-within {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.search-input-wrap svg {
  width: 22px; height: 22px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  padding: 14px 12px;
  min-height: 50px;
  color: var(--text);
  min-width: 0;
}
.search-clear {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-right: 4px;
  min-height: 38px;
}
.search-results-summary {
  padding: 0 18px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
@media (min-width: 1024px) { .search-results-summary { padding: 0 0 12px; } }

/* ===========================================================
   LIBRARY (grouped)
   =========================================================== */
.library-group {
  padding: 18px 18px 0;
}
@media (min-width: 1024px) { .library-group { padding: 18px 0 0; } }

.library-group h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.library-group h2 .count {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 1.2px;
  font-weight: 700;
}

/* ===========================================================
   HELP PAGE
   =========================================================== */
.help-content-block {
  padding: 22px 18px 0;
}
@media (min-width: 1024px) { .help-content-block { padding: 14px 0 0; } }

.help-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.help-card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: var(--indigo);
}
.help-card p { font-size: 0.92rem; color: var(--text); margin-bottom: 6px; line-height: 1.55; }
.help-card .help-line {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1.5px solid var(--border);
  flex-wrap: wrap;
}
.help-cta-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  min-height: 48px;
}
.help-cta-button.primary {
  background: var(--indigo);
  color: var(--gold);
}
.help-cta-button.secondary {
  background: var(--surface);
  color: var(--indigo);
  border: 2px solid var(--indigo);
}

/* ===========================================================
   MODALS
   =========================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-backdrop.active { display: flex; animation: fade-in 0.18s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: 24px 24px 0 0;
  padding: 22px 22px calc(22px + var(--safe-bottom));
  max-height: 86vh;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; max-height: 90vh; padding: 28px; }
}

.modal h2 { font-size: 1.25rem; margin-bottom: 6px; color: var(--indigo); }
.modal-help {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.modal label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  color: var(--text);
}
.modal input[type="text"], .modal input[type="url"] {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  margin-bottom: 14px;
  background: var(--bg);
  min-height: 48px;
}
.modal input:focus { border-color: var(--indigo); outline: none; }

.shortcut-edit-list { margin-bottom: 4px; }
.shortcut-edit-row {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.shortcut-edit-row.locked { opacity: 0.85; background: var(--gold-soft); }
.shortcut-edit-row .shortcut-info { flex: 1; min-width: 0; }
.shortcut-edit-row .shortcut-info .name { font-weight: 700; font-size: 0.95rem; }
.shortcut-edit-row .shortcut-info .url { font-size: 0.74rem; color: var(--text-muted); word-break: break-all; }
.shortcut-remove {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
}
.shortcut-remove:hover { background: var(--danger); color: white; }
.shortcut-locked-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--gold);
  color: var(--gold-deep);
  border: 1.5px solid var(--gold-deep);
  white-space: nowrap;
}

.btn-add-row {
  width: 100%;
  background: transparent;
  border: 2px dashed var(--text-muted);
  color: var(--text-muted);
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 18px;
  min-height: 48px;
}
.btn-add-row:hover { border-color: var(--indigo); color: var(--indigo); }

.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 52px;
}
.btn-primary { background: var(--indigo); color: var(--gold); }
.btn-primary:hover { background: var(--indigo-deep); }
.btn-secondary { background: var(--surface); color: var(--indigo); border: 2px solid var(--indigo); }
.btn-secondary:hover { background: var(--indigo); color: white; }

/* ===========================================================
   SCREEN ROUTING
   =========================================================== */
.screen { display: none; }
.screen.active { display: block; }

/* ===========================================================
   FOCUS STATES
   =========================================================== */
button:focus-visible, a:focus-visible, .tile:focus-visible, input:focus-visible, [role="button"]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ===========================================================
   LOGIN OVERLAY
   =========================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--indigo-deep) 100%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  overflow-y: auto;
}
.login-overlay[hidden] { display: none; }
.login-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 36px 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  border-top: 6px solid var(--gold);
}
.login-crest {
  background: var(--indigo);
  color: var(--gold);
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.6rem;
  margin: 0 auto 16px;
}
.login-card h1 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--indigo);
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}
#login-form label {
  display: block;
  font-weight: 700;
  margin: 14px 0 6px;
  font-size: 0.95rem;
  color: var(--text);
}
#login-form input {
  width: 100%;
  padding: 14px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.05rem;
  min-height: 52px;
}
#login-form input:focus {
  border-color: var(--indigo);
  outline: none;
}
.btn-full {
  width: 100%;
  margin-top: 20px;
  min-height: 56px;
  font-size: 1.05rem;
}
.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #FEE;
  border: 2px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  font-size: 0.95rem;
}
.login-foot {
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ===========================================================
   ACCOUNT CARD (in Help screen)
   =========================================================== */
.account-card .account-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.account-card .account-row strong {
  font-size: 1.05rem;
  color: var(--indigo);
}
.account-card .account-row .meta {
  color: var(--text-muted);
  font-size: 0.92rem;
}
.account-card .account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.account-card .account-actions .btn {
  flex: 1 1 140px;
}
.account-badge {
  display: inline-block;
  background: var(--gold-soft);
  color: var(--gold-deep);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: middle;
}

/* ===========================================================
   ADMIN SCREEN
   =========================================================== */
.admin-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin: 0 0 20px;
  overflow-x: auto;
  padding: 0 4px;
}
.admin-tab {
  background: transparent;
  border: 0;
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  font-size: 0.98rem;
  min-height: 44px;
}
.admin-tab.active {
  color: var(--indigo);
  border-bottom-color: var(--gold);
}
.admin-tab:hover { color: var(--indigo); }
.admin-pane { display: none; }
.admin-pane.active { display: block; }
.admin-pane-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.admin-pane-meta {
  color: var(--text-muted);
  font-size: 0.92rem;
}
.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 540px;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table th {
  background: var(--gold-soft);
  font-weight: 700;
  color: var(--indigo);
  position: sticky;
  top: 0;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: rgba(246, 175, 51, 0.08); }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .muted { color: var(--text-muted); font-size: 0.88rem; }
.admin-table .row-action {
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
}
.admin-table .row-action:hover { background: var(--danger); color: white; }
.admin-table .row-action[disabled] { opacity: 0.4; cursor: not-allowed; }
.admin-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
}
.admin-loading {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
}
.modal-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #FEE;
  border: 2px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  font-size: 0.92rem;
}

.admin-settings-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.admin-settings-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px;
}
.admin-settings-field label {
  display: block;
  font-weight: 700;
  color: var(--indigo);
  margin-bottom: 4px;
  font-size: 0.95rem;
}
.admin-settings-field .desc {
  color: var(--text-muted);
  font-size: 0.86rem;
  margin-bottom: 8px;
}
.admin-settings-field input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
}
.admin-settings-field input:focus {
  border-color: var(--indigo);
  outline: none;
}
.admin-settings-field .meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.admin-settings-note {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #E8F5E9;
  border: 2px solid var(--success);
  color: var(--success);
  border-radius: 8px;
  font-size: 0.92rem;
}

.admin-maintenance {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
}
.admin-maintenance h3 {
  color: var(--indigo);
  margin-bottom: 6px;
  font-size: 1.05rem;
}

/* ===========================================================
   SIDENAV ACCOUNT (desktop)
   =========================================================== */
.sidenav-account {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.sidenav-account.has-user { display: flex; }
.sidenav-account .name {
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  word-break: break-word;
}
.sidenav-account .email {
  color: rgba(255,255,255,0.65);
  font-size: 0.78rem;
  word-break: break-word;
}
.sidenav-account .actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.sidenav-account button {
  background: transparent;
  border: 0;
  color: var(--gold);
  text-align: left;
  padding: 6px 0;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
}
.sidenav-account button:hover { text-decoration: underline; }
.sidenav-account .badge {
  display: inline-block;
  background: var(--gold);
  color: var(--indigo);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 700;
}

/* ===========================================================
   HEADER ACCOUNT (mobile)
   =========================================================== */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-account {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--gold-soft);
  border: 1.5px solid var(--gold);
  color: var(--indigo);
  border-radius: 999px;
  padding: 6px 10px 6px 6px;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  font-size: 0.85rem;
}
.header-account.has-user { display: inline-flex; }
.header-account-initials {
  background: var(--indigo);
  color: var(--gold);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.header-account-label { display: none; }
@media (min-width: 480px) {
  .header-account-label { display: inline; }
}
@media (min-width: 1024px) {
  .header-account { display: none !important; }
}

/* ===========================================================
   REDUCED MOTION
   =========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
