/* ============================================================
   TABA Rulebook — styles.css
   Edit only for visual/design changes.
   ============================================================ */

:root {
  --navy:       #0d2240;
  --navy-mid:   #163462;
  --red:        #c0392b;
  --gold:       #f0b427;
  --gold-light: #f5c84a;
  --cream:      #fdf9f2;
  --parch:      #f5efe0;
  --rule-bg:    #fff8ee;
  --rule-bdr:   #e8d5a3;
  --diff-bdr:   #e67e22;
  --add-bdr:    #27ae60;
  --rem-bdr:    #c0392b;
  --text:       #1a1a2e;
  --muted:      #5a6075;
  --sidebar-w:  290px;

  /* Division accent — overridden per division by renderer */
  --division-color: var(--navy);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── App container ── */
#app { width: 100%; }

/* ── Loading ── */
#loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh;
  font-family: 'Source Serif 4', serif; color: var(--muted);
}
.load-icon { font-size: 3rem; display: block; margin-bottom: 1rem;
  animation: spin 2s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Landing page ── */
.landing {
  min-height: 100vh; background: var(--navy);
  display: flex; flex-direction: column; align-items: center;
  padding: 4rem 1.5rem;
}
.landing-logo { font-size: 4rem; margin-bottom: 1rem; }
.landing h1 {
  font-family: 'Playfair Display', serif; color: #fff;
  font-size: 2rem; font-weight: 900; text-align: center;
  margin-bottom: .4rem;
}
.landing-sub {
  font-family: 'DM Mono', monospace; font-size: .7rem;
  color: var(--gold); letter-spacing: .15em; text-transform: uppercase;
  text-align: center; margin-bottom: 3rem;
}
.division-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; max-width: 900px; width: 100%;
}
.division-card {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 1.5rem 1.25rem; cursor: pointer;
  text-decoration: none; display: block; transition: background .15s, transform .15s;
}
.division-card:hover {
  background: rgba(255,255,255,.12); transform: translateY(-2px);
}
.division-card .dc-badge {
  font-family: 'DM Mono', monospace; font-size: .62rem; font-weight: 500;
  background: var(--division-color, var(--gold)); color: #fff;
  padding: .15rem .5rem; border-radius: 3px; letter-spacing: .06em;
  display: inline-block; margin-bottom: .65rem;
}
.division-card .dc-name {
  font-family: 'Playfair Display', serif; color: #fff;
  font-size: 1.2rem; font-weight: 700; display: block; margin-bottom: .35rem;
}
.division-card .dc-desc {
  font-family: 'Source Serif 4', serif; color: rgba(255,255,255,.55);
  font-size: .82rem; line-height: 1.5;
}
.landing-footer {
  margin-top: 3rem; font-family: 'DM Mono', monospace; font-size: .65rem;
  color: rgba(255,255,255,.3); text-align: center; letter-spacing: .05em;
}
.landing-group { width: 100%; max-width: 900px; margin-bottom: 2rem; }
.landing-group-label {
  font-family: 'DM Mono', monospace; font-size: .65rem; font-weight: 500;
  letter-spacing: .15em; text-transform: uppercase;
  color: var(--gold); margin-bottom: .75rem;
  padding-bottom: .4rem; border-bottom: 1px solid rgba(255,255,255,.1);
}

/* BC Minor rule cross-links inside content */
a.bcm-link {
  color: var(--division-color);
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 2px; cursor: pointer;
  font-weight: 500; transition: opacity .15s;
}
a.bcm-link:hover { opacity: .75; }

/* ── Rulebook layout ── */
/* Classic fixed-sidebar layout — far more reliable than flexbox for this pattern */
body.rulebook-mode {
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--cream); color: var(--text);
  min-height: 100vh; font-size: 15px; line-height: 1.7;
}

/* ── Sidebar — fixed position, full height ── */
#sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  overflow-y: auto;
  display: flex; flex-direction: column;
  z-index: 100;
  scrollbar-width: thin; scrollbar-color: var(--navy-mid) var(--navy);
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: var(--navy); }
#sidebar::-webkit-scrollbar-thumb { background: var(--navy-mid); }

.sb-brand {
  padding: 1.3rem 1.2rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sb-brand .sb-logo { font-size: 1.5rem; display: block; margin-bottom: .25rem; }
.sb-brand h1 {
  font-family: 'Playfair Display', serif; color: #fff;
  font-size: .95rem; font-weight: 700; line-height: 1.3;
}
.sb-division-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--division-color); color: #fff;
  font-family: 'DM Mono', monospace; font-size: .62rem; font-weight: 500;
  padding: .15rem .5rem; border-radius: 3px; margin-top: .4rem;
  letter-spacing: .05em; cursor: pointer; text-decoration: none;
}
.sb-division-badge:hover { opacity: .85; }

#sidebar nav { padding: .4rem 0 2rem; flex: 1; }
.nav-group-label {
  font-family: 'DM Mono', monospace; font-size: .56rem; letter-spacing: .15em;
  text-transform: uppercase; color: var(--gold); padding: .8rem 1.2rem .25rem;
  font-weight: 500;
}

/* nav items */
.nav-item { position: relative; }
.nav-item.has-override::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--gold);
}
.nav-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none; cursor: pointer;
  padding: .24rem 1rem .24rem 1.2rem;
  color: rgba(255,255,255,.62); font-size: .74rem;
  font-family: 'Source Serif 4', Georgia, serif;
  text-align: left; transition: color .15s, background .15s;
  line-height: 1.4;
}
.nav-trigger:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.n-open .nav-trigger { color: var(--gold-light); }
.nav-trigger .chev {
  font-size: .5rem; opacity: .45; transition: transform .2s;
  flex-shrink: 0; margin-left: .25rem;
}
.nav-item.n-open .chev { transform: rotate(90deg); }
.nav-trigger .override-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); flex-shrink: 0; margin-left: .3rem;
}

.nav-sub { display: none; padding-bottom: .1rem; }
.nav-item.n-open .nav-sub { display: block; }
.nav-sub a {
  display: block; padding: .18rem 1rem .18rem 2rem;
  color: rgba(255,255,255,.4); text-decoration: none; font-size: .68rem;
  transition: color .12s;
}
.nav-sub a:hover { color: rgba(255,255,255,.75); }
.nav-sub a.has-override { color: rgba(255,210,80,.55); }
.nav-sub a.has-override:hover { color: rgba(255,210,80,.85); }

/* plain nav links (no sub-items) */
.nav-plain a {
  display: block; padding: .24rem 1.2rem;
  color: rgba(255,255,255,.62); text-decoration: none; font-size: .74rem;
  transition: color .15s; border-left: 2px solid transparent;
}
.nav-plain a:hover { color: #fff; }
.nav-plain a.has-override { border-left-color: var(--gold); color: rgba(255,210,80,.7); }
/* ── Active nav link ── */
nav a.nav-active { color: var(--gold-light) !important; font-weight: 600; }

/* ── Search ── */
.search-wrap {
  padding: .6rem .9rem .4rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.search-box {
  display: flex; align-items: center; gap: .4rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 5px; padding: .35rem .6rem;
  transition: border-color .15s;
}
.search-box:focus-within {
  border-color: var(--gold); background: rgba(255,255,255,.12);
}
.search-icon { color: rgba(255,255,255,.4); font-size: 1.1rem; flex-shrink:0; line-height:1; }
.search-box input {
  flex: 1; background: none; border: none; outline: none;
  color: #fff; font-family: 'Source Serif 4', serif; font-size: .8rem;
  placeholder-color: rgba(255,255,255,.35);
}
.search-box input::placeholder { color: rgba(255,255,255,.35); }
.search-clear {
  display: none; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.4); font-size: .75rem; padding: 0;
  width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%;
  transition: color .15s, background .15s;
}
.search-clear:hover { color: #fff; background: rgba(255,255,255,.15); }

.search-results {
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  margin: .3rem -.9rem 0;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
.search-count {
  font-family: 'DM Mono', monospace; font-size: .58rem; letter-spacing: .1em;
  color: rgba(255,255,255,.3); text-transform: uppercase;
  padding: .5rem .9rem .25rem;
}
.search-result {
  display: flex; align-items: baseline; gap: .5rem;
  padding: .45rem .9rem; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.05);
  transition: background .1s;
}
.search-result:hover, .search-result.sr-selected {
  background: rgba(255,255,255,.08);
}
.sr-type {
  font-family: 'DM Mono', monospace; font-size: .55rem; font-weight: 500;
  padding: .08rem .35rem; border-radius: 2px; flex-shrink: 0;
  letter-spacing: .04em; text-transform: uppercase;
}
.sr-type-rule    { background: rgba(255,255,255,.15); color: rgba(255,255,255,.7); }
.sr-type-section { background: rgba(255,255,255,.08); color: rgba(255,255,255,.5); }
.sr-type-taba    { background: var(--division-color); color: #fff; }
.sr-type-differs { background: var(--diff-bdr); color: #fff; }
.sr-title {
  color: rgba(255,255,255,.75); font-size: .74rem; line-height: 1.3; flex: 1;
}
.sr-title mark {
  background: rgba(212,160,23,.35); color: var(--gold-light);
  border-radius: 2px; padding: 0 .1rem;
}
.search-empty {
  padding: .8rem .9rem; color: rgba(255,255,255,.4); font-size: .78rem;
}

/* TABA nav group */
.taba-group-label { color: var(--gold) !important; }
.taba-nav-group {
  background: rgba(255,255,255,.04);
  border-left: 3px solid var(--division-color);
  margin: 0 0 .25rem 0;
  padding: .3rem 0;
}
.taba-nav-link {
  display: block; padding: .22rem 1rem .22rem 1.4rem;
  color: rgba(255,210,80,.7); text-decoration: none; font-size: .72rem;
  transition: color .12s;
}
.taba-nav-link:hover { color: var(--gold-light); }

/* ── Main content — offset by sidebar width ── */
#main {
  margin-left: var(--sidebar-w);
  min-width: 0;
  padding: 0 2.5rem 4rem;
  max-width: calc(880px + var(--sidebar-w));
}

/* ── Cover ── */
.cover {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #1a4a8a 100%);
  margin: 0 -2.5rem 3rem; padding: 3.5rem 2.5rem 2.5rem;
  position: relative; overflow: hidden;
}
.cover::before {
  content: "⚾"; position: absolute; font-size: 18rem;
  opacity: .04; right: -2rem; top: -3rem; line-height: 1;
}
.cover-eyebrow {
  font-family: 'DM Mono', monospace; font-size: .66rem;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold); margin-bottom: .75rem;
}
.cover h1 {
  font-family: 'Playfair Display', serif; color: #fff;
  font-size: 2.2rem; font-weight: 900; line-height: 1.15;
  margin-bottom: .5rem;
}
.cover-sub { color: rgba(255,255,255,.55); font-size: .92rem; margin-bottom: 1.2rem; }
.cover-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.cover-pill {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8); font-family: 'DM Mono', monospace; font-size: .62rem;
  padding: .2rem .6rem; border-radius: 20px; letter-spacing: .04em;
}
.cover-pill.division {
  background: var(--division-color); border-color: transparent; color: #fff;
}

/* ── Section dividers ── */
.part-divider {
  background: var(--navy); margin: 3rem -2.5rem 2.5rem;
  padding: 1rem 2.5rem; display: flex; align-items: center; gap: 1rem;
}
.part-divider h2 {
  font-family: 'Playfair Display', serif; color: #fff;
  font-size: 1.1rem; font-weight: 700;
}
.part-badge {
  background: var(--gold); color: var(--navy); font-family: 'DM Mono', monospace;
  font-size: .62rem; font-weight: 500; padding: .18rem .55rem;
  border-radius: 2px; letter-spacing: .06em;
}

/* ── Rule sections (collapsible) ── */
.rule-section { margin-bottom: 1.1rem; border: 1px solid var(--rule-bdr); border-radius: 6px; overflow: hidden; }
.rule-section.has-override { border-color: rgba(212,160,23,.5); }

.rule-toggle {
  width: 100%; background: var(--parch); border: none; cursor: pointer;
  padding: .75rem 1rem; display: flex; align-items: center; gap: .6rem;
  text-align: left; transition: background .15s;
}
.rule-toggle:hover { background: #ede7d3; }
.rule-section.r-open .rule-toggle { background: #e8e0cc; }

.rule-num {
  font-family: 'DM Mono', monospace; font-size: .65rem; font-weight: 500;
  color: var(--muted); background: #fff; border: 1px solid var(--rule-bdr);
  padding: .12rem .42rem; border-radius: 3px; white-space: nowrap; flex-shrink: 0;
}
.rule-title {
  font-family: 'Playfair Display', serif; font-size: .98rem;
  font-weight: 700; color: var(--navy); flex: 1;
}
.rule-override-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
  flex-shrink: 0;
}
.rule-override-flag {
  font-family: 'DM Mono', monospace; font-size: .58rem; font-weight: 500;
  background: var(--division-color); color: #fff;
  padding: .1rem .45rem; border-radius: 3px; letter-spacing: .04em;
  flex-shrink: 0; margin-left: auto; margin-right: .4rem;
}
.rule-chev {
  font-size: .65rem; color: var(--muted); transition: transform .25s; flex-shrink: 0;
}
.rule-section.r-open .rule-chev { transform: rotate(90deg); }

.rule-body {
  display: none; padding: .9rem 1.1rem 1.1rem;
  border-top: 1px solid var(--rule-bdr);
}
.rule-section.r-open .rule-body { display: block; }

/* ── Sub-rules ── */
.sub-rule { margin-bottom: .95rem; padding-left: .8rem; border-left: 3px solid var(--rule-bdr); }
.sub-rule:last-child { margin-bottom: 0; }
/* Sub-rules with a TABA override get a prominent amber highlight */
.sub-rule.has-override {
  border-left: 4px solid var(--division-color);
  background: #f0f7f5;
  border-radius: 0 4px 4px 0;
  padding: .65rem .9rem .65rem .9rem;
  margin-left: -.1rem;
}
.sub-rule-title {
  font-family: 'DM Mono', monospace; font-size: .72rem; font-weight: 500;
  color: var(--navy-mid); margin-bottom: .25rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: .35rem;
}
/* Tag shown inline in the sub-rule title when TABA differs */
.sub-rule-override-tag {
  font-family: 'DM Mono', monospace; font-size: .58rem; font-weight: 500;
  background: var(--division-color); color: #fff;
  padding: .1rem .4rem; border-radius: 3px; letter-spacing: .04em;
}
.sub-rule-content { }

/* ── Division override panel ── */
.division-panel {
  border: 2px solid var(--division-color);
  border-radius: 6px; margin: .7rem 0; overflow: hidden;
}
.division-panel-header {
  background: var(--division-color); color: #fff;
  font-family: 'DM Mono', monospace; font-size: .68rem; font-weight: 500;
  padding: .5rem .9rem; letter-spacing: .06em;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.division-panel-header:hover { filter: brightness(1.1); }
.division-panel-header .dp-label { display: flex; align-items: center; gap: .4rem; }
.division-panel-header .dp-chev { font-size: .5rem; transition: transform .2s; }
.division-panel.dp-open .dp-chev { transform: rotate(90deg); }
.division-panel-body { display: none; }
.division-panel.dp-open .division-panel-body { display: block; }

/* differs: side-by-side */
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; }
.diff-col { padding: .65rem .85rem; font-size: .87rem; }
.diff-col:first-child { background: #fff9e8; border-right: 1px solid var(--division-color); }
.diff-col:last-child { background: #e8f9e8; }
.diff-col-label {
  font-family: 'DM Mono', monospace; font-size: .56rem; font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase; margin-bottom: .3rem;
}
.diff-col:first-child .diff-col-label { color: #8a6000; }
.diff-col:last-child .diff-col-label { color: #1a6b1a; }

/* adds: green */
.panel-adds { background: #f0fff4; padding: .7rem .9rem; font-size: .88rem; }
/* removes: red */
.panel-removes { background: #fff4f4; padding: .7rem .9rem; font-size: .88rem; }

/* TABA-only additions (whole rules) */
.taba-rule-section {
  margin-bottom: 1.1rem;
  border: 2px solid var(--division-color);
  border-radius: 6px; overflow: hidden;
}
.taba-rule-toggle {
  width: 100%; background: var(--division-color); border: none; cursor: pointer;
  padding: .75rem 1rem; display: flex; align-items: center; gap: .6rem;
  text-align: left;
}
.taba-rule-num {
  font-family: 'DM Mono', monospace; font-size: .65rem; font-weight: 500;
  color: rgba(255,255,255,.7); background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  padding: .12rem .42rem; border-radius: 3px; white-space: nowrap; flex-shrink: 0;
}
.taba-rule-title {
  font-family: 'Playfair Display', serif; font-size: .98rem;
  font-weight: 700; color: #fff; flex: 1;
}
.taba-rule-chev {
  font-size: .65rem; color: rgba(255,255,255,.6);
  transition: transform .25s; flex-shrink: 0;
}
.taba-rule-section.r-open .taba-rule-chev { transform: rotate(90deg); }
.taba-rule-body {
  display: none; padding: .9rem 1.1rem 1.1rem;
  border-top: 2px solid var(--division-color);
  background: #fff;
}
.taba-rule-section.r-open .taba-rule-body { display: block; }
.taba-rule-section.r-open .taba-rule-chev { transform: none; }

/* ── Common content elements ── */
p { margin-bottom: .5rem; font-size: .91rem; }
p:last-child { margin-bottom: 0; }

.callout {
  border-left: 4px solid var(--gold); background: var(--rule-bg);
  padding: .72rem .9rem; margin: .55rem 0;
  border-radius: 0 4px 4px 0; font-size: .89rem;
}
.callout.red   { border-color: var(--red);  background: #fff4f4; }
.callout.blue  { border-color: #2980b9;     background: #e8f4ff; }
.callout.navy  { border-color: var(--navy); background: #f0f2f8; }
.callout.green { border-color: #27ae60; background: #f0fff4; }
.callout p { margin-bottom: .3rem; } .callout p:last-child { margin-bottom: 0; }

.badge-interlock { background: #e8f4e8; color: #1a6b1a; border: 1px solid #90d090; }

table { width: 100%; border-collapse: collapse; font-size: .84rem; margin: .6rem 0; }
th {
  background: var(--navy); color: #fff; font-family: 'DM Mono', monospace;
  font-size: .65rem; font-weight: 500; padding: .42rem .65rem; text-align: left; letter-spacing: .05em;
}
td { padding: .38rem .65rem; border-bottom: 1px solid #e8e0d0; vertical-align: top; }
tr:nth-child(even) td { background: var(--parch); }
tr:last-child td { border-bottom: none; }
td.hi { font-weight: 600; color: var(--navy); }

ul.rl { list-style: none; }
ul.rl li { padding: .2rem 0 .2rem .95rem; position: relative; font-size: .89rem; }
ul.rl li::before { content: "–"; position: absolute; left: 0; color: var(--gold); font-weight: 700; }

ol.al { list-style: none; counter-reset: al; padding-left: 0; }
ol.al > li { counter-increment: al; padding-left: 1.6rem; margin-bottom: .25rem; font-size: .89rem; position: relative; }
ol.al > li::before { content: counter(al,upper-alpha)"."; position: absolute; left: 0; font-family: 'DM Mono', monospace; font-size: .68rem; color: var(--navy-mid); font-weight: 500; top: .14rem; }

ol.nl { list-style: none; counter-reset: nl; padding-left: 0; }
ol.nl > li { counter-increment: nl; padding-left: 1.6rem; margin-bottom: .25rem; font-size: .89rem; position: relative; }
ol.nl > li::before { content: counter(nl)"."; position: absolute; left: 0; font-family: 'DM Mono', monospace; font-size: .68rem; color: var(--muted); font-weight: 500; top: .14rem; }

.note {
  font-size: .78rem; color: var(--muted); font-style: italic;
  border-top: 1px dashed var(--rule-bdr); padding-top: .4rem; margin-top: .4rem;
}
.na { font-size: .8rem; color: #999; font-style: italic; }
.repealed {
  color: var(--muted); font-style: italic; font-size: .83rem;
  padding: .38rem .7rem; background: #f5f5f5;
  border-left: 3px solid #ccc; border-radius: 0 3px 3px 0;
}
.sb-badge {
  display: inline-block; font-family: 'DM Mono', monospace; font-size: .56rem;
  letter-spacing: .05em; padding: .08rem .35rem; border-radius: 2px;
  vertical-align: middle; margin-left: .2rem; font-weight: 500;
}
.badge-taba { background: #dceeff; color: #1a4a8a; border: 1px solid #a8cbf0; }
.badge-bcm  { background: #ffe8e8; color: #8b0000; border: 1px solid #f0a0a0; }

.amendment-attr {
  font-size: .72rem; color: var(--muted); margin-top: .75rem;
  padding-top: .5rem; border-top: 1px dashed var(--rule-bdr); line-height: 1.4;
}
.amendment-attr a { color: var(--gold); text-decoration: none; }
.amendment-attr a:hover { text-decoration: underline; }

/* ── Footer ── */
.attr-bar {
  background: #0d1a2e; margin: 3rem -2.5rem 0;
  padding: 1rem 2.5rem; border-top: 2px solid var(--gold);
  color: rgba(255,255,255,.5); font-size: .72rem; line-height: 1.6;
}
.attr-bar a { color: var(--gold); text-decoration: none; }
.attr-bar strong { color: rgba(255,255,255,.85); }
.attr-lock {
  background: var(--gold); color: var(--navy); padding: .08rem .45rem;
  border-radius: 2px; font-family: 'DM Mono', monospace;
  font-size: .6rem; font-weight: 500;
}
footer {
  background: var(--navy); margin: 0 -2.5rem -4rem;
  padding: 1.1rem 2.5rem; color: rgba(255,255,255,.4);
  font-size: .7rem; text-align: center; line-height: 1.7;
}
footer a { color: var(--gold); text-decoration: none; }

/* ════════════════════════════════════════════════════════════
   Admin mode
   ════════════════════════════════════════════════════════════ */

/* Admin banner */
#admin-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  height: 38px;
  background: #1a2a1a; color: #7dbb7d;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; font-size: .78rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.admin-banner-left  { display: flex; align-items: center; gap: .5rem; }
.admin-banner-right { display: flex; align-items: center; gap: .75rem; }
.admin-banner-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4caf50; box-shadow: 0 0 6px #4caf50; flex-shrink: 0;
}
.admin-banner-sep { margin: 0 .15rem; opacity: .5; }
.admin-banner-link {
  color: #9fd89f; text-decoration: none; font-size: .75rem;
  border: 1px solid rgba(159,216,159,.3); border-radius: 3px;
  padding: .15rem .5rem;
}
.admin-banner-link:hover { background: rgba(159,216,159,.1); }
.admin-banner-logout {
  background: rgba(255,100,100,.15); color: #ff9999;
  border: 1px solid rgba(255,100,100,.3); border-radius: 3px;
  padding: .15rem .6rem; font-size: .75rem; cursor: pointer;
}
.admin-banner-logout:hover { background: rgba(255,100,100,.25); }
body.admin-mode { padding-top: 38px; }

/* Admin login modal */
#admin-modal {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center;
}
.admin-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.admin-modal-box {
  position: relative; z-index: 1;
  background: #fff; border-radius: 12px;
  padding: 2rem 1.75rem; width: 320px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
  text-align: center;
}
.admin-modal-close {
  position: absolute; top: .75rem; right: .75rem;
  background: none; border: none; font-size: 1.1rem; color: #999; cursor: pointer;
}
.admin-modal-close:hover { color: #333; }
.admin-modal-icon { font-size: 2.2rem; margin-bottom: .75rem; }
.admin-modal-box h2 { font-size: 1.15rem; margin-bottom: .35rem; }
.admin-modal-box p  { font-size: .82rem; color: #666; margin-bottom: 1.25rem; line-height: 1.5; }
.admin-modal-box input[type="password"] {
  width: 100%; border: 1px solid #c9d0df; border-radius: 6px;
  padding: .55rem .75rem; font-size: .9rem; margin-bottom: .65rem; background: #fafbfd;
}
.admin-modal-box input[type="password"]:focus {
  outline: none; border-color: #2c3e50; box-shadow: 0 0 0 3px rgba(44,62,80,.1);
}
.admin-modal-box button[type="submit"] {
  width: 100%; background: #2c3e50; color: #fff; border: none;
  border-radius: 6px; padding: .6rem; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.admin-modal-box button[type="submit"]:hover:not(:disabled) { background: #3d5166; }
.admin-modal-box button[type="submit"]:disabled { opacity: .55; cursor: default; }
.admin-modal-err { color: #c0392b; font-size: .8rem; margin-top: .6rem; font-weight: 600; }

/* Admin landing card */
.admin-landing-card { cursor: pointer; border: none; text-align: left; font-family: inherit; }

/* Edit button (pencil) */
.edit-btn {
  display: inline-flex; align-items: center; gap: .25rem;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.2); border-radius: 4px;
  padding: .2rem .55rem; font-size: .7rem; font-weight: 600;
  color: #2c3e50; cursor: pointer; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.edit-btn:hover { background: #fff; border-color: #2c3e50; }
.dp-edit-btn { margin-left: auto; margin-right: .5rem; }

/* TABA rule header row (toggle button + edit button) */
.taba-rule-header { display: flex; align-items: stretch; }
.taba-rule-header .taba-rule-toggle { flex: 1; }
.taba-rule-header .edit-btn { align-self: center; margin: .4rem .5rem .4rem 0; }

/* Edit drawer */
#edit-drawer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 490;
  background: #fff; border-top: 3px solid #2c3e50;
  max-height: 65vh; overflow-y: auto;
  box-shadow: 0 -6px 24px rgba(0,0,0,.18);
}
.edit-drawer-header {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  background: #2c3e50; color: #fff; padding: .6rem 1rem;
}
.edit-drawer-title-row { display: flex; align-items: baseline; gap: .5rem; font-size: .85rem; }
.edit-drawer-label { opacity: .6; font-size: .75rem; }
.edit-drawer-close {
  background: none; border: none; color: rgba(255,255,255,.7); font-size: 1rem; cursor: pointer;
}
.edit-drawer-close:hover { color: #fff; }
.edit-drawer-body { padding: 1rem 1.25rem 1.5rem; }
.edit-field { margin-bottom: 1rem; }
.edit-field label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: #555; margin-bottom: .3rem;
}
.edit-field input, .edit-field textarea {
  width: 100%; border: 1px solid #c9d0df; border-radius: 5px;
  padding: .45rem .6rem; font-family: 'DM Mono', monospace;
  font-size: .8rem; color: #1a1a2e; background: #fafbfd; resize: vertical;
}
.edit-field input:focus, .edit-field textarea:focus {
  outline: none; border-color: #2c3e50; box-shadow: 0 0 0 3px rgba(44,62,80,.08);
}
.edit-drawer-actions {
  display: flex; align-items: center; gap: .75rem;
  padding-top: .75rem; border-top: 1px solid #eee; flex-wrap: wrap;
}
.edit-save-btn {
  background: #27ae60; color: #fff; border: none; border-radius: 5px;
  padding: .5rem 1.25rem; font-weight: 700; font-size: .85rem; cursor: pointer;
}
.edit-save-btn:hover { background: #219a52; }
.edit-revert-btn {
  background: #fff; color: #c0392b;
  border: 1px solid rgba(192,57,43,.4); border-radius: 5px;
  padding: .5rem 1rem; font-size: .85rem; cursor: pointer;
}
.edit-revert-btn:hover { background: #fff4f4; }
.edit-status-msg { font-size: .8rem; color: #555; }

/* ── Visual / Code mode toggle ── */
.editor-mode-bar {
  display: inline-flex; gap: 3px; margin-left: .6rem; vertical-align: middle;
}
.mode-btn {
  background: #f0f2f8; border: 1px solid #c9d0df; border-radius: 4px;
  padding: 1px 9px; font-size: 11px; cursor: pointer; color: #555;
  font-family: inherit; font-weight: 500; transition: background .12s;
}
.mode-btn.active { background: #2c3e50; color: #fff; border-color: #2c3e50; }
.editor-loading { color: #888; font-size: .8rem; padding: .75rem 0; }
/* Visual (contenteditable) editor */
.ve-toolbar { display: flex; gap: 4px; align-items: center; padding: 5px 7px; background: #f6f7fb; border: 1px solid #c9d0df; border-radius: 5px 5px 0 0; flex-wrap: wrap; }
.ve-btn { background: #fff; border: 1px solid #c9d0df; border-radius: 3px; padding: 2px 8px; font-size: .78rem; cursor: pointer; color: #333; font-family: inherit; }
.ve-btn:hover { background: #e8ecf5; }
.ve-btn-warn { color: #a05a00; border-color: #e0b060; background: #fffbf0; }
.ve-btn-warn:hover { background: #fff3d0; }
.ve-content {
  min-height: 200px; max-height: 420px; overflow-y: auto;
  border: 1px solid #c9d0df; border-top: none; border-radius: 0 0 5px 5px;
  padding: .7rem .9rem; background: #fff; font-size: .88rem; line-height: 1.65;
  outline: none;
}
.ve-content:focus { border-color: #2980b9; box-shadow: 0 0 0 2px rgba(41,128,185,.12); }

/* ── Content editor toolbar ── */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px;
}
.editor-toolbar .tb-btn {
  background: #f0f2f8; border: 1px solid #c9d0df; border-radius: 4px;
  padding: 2px 9px; font-size: 11px; cursor: pointer; color: #1a1a2e;
  font-family: inherit; line-height: 1.7; transition: background .12s;
  white-space: nowrap;
}
.editor-toolbar .tb-btn:hover { background: #dde1eb; border-color: #aab0c4; }
.editor-toolbar .tb-sep {
  display: inline-block; width: 1px; background: #c9d0df;
  margin: 2px 2px; align-self: stretch;
}
.editor-preview-label {
  font-size: 10px; font-weight: 700; color: #888;
  text-transform: uppercase; letter-spacing: .08em;
  margin-top: 8px; margin-bottom: 4px;
}
.editor-preview-live {
  border: 1px solid #c9d0df; border-radius: 5px;
  padding: 10px 14px; background: #fafbfd;
  font-size: 13px; line-height: 1.65;
  min-height: 48px; max-height: 280px; overflow-y: auto;
}

/* ── Responsive ── */
@media print {
  #sidebar { display: none; }
  #main { margin-left: 0; padding: 0; max-width: 100%; }
  .rule-body, .taba-rule-body { display: block !important; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar { display: none; }
  #main { margin-left: 0; padding: 0 1rem 3rem; }
  .cover { margin: 0 -1rem 2rem; padding: 2.5rem 1rem 2rem; }
  .part-divider { margin: 2rem -1rem 1.5rem; padding: 1rem; }
  .diff-grid { grid-template-columns: 1fr; }
  .diff-col:first-child { border-right: none; border-bottom: 1px solid var(--division-color); }
}
