/* ==========================================================================
   app.css — Britannica CD 98 application surfaces
   ========================================================================== */

/* ================= DESKTOP ================= */
#desktop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 90% at 20% 0%, #0a9c94 0%, var(--teal) 55%, #00666b 100%);
  overflow: hidden;
}
#desktop-icons {
  position: absolute;
  top: 10px; left: 10px;
  width: 84px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.desk-icon {
  width: 80px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
}
.desk-icon .di-art {
  width: 34px; height: 34px;
  image-rendering: pixelated;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,.35));
}
.desk-icon span {
  color: #fff;
  font-size: 11px;
  text-align: center;
  text-shadow: 1px 1px 0 rgba(0,0,0,.8);
  line-height: 12px;
  max-width: 78px;
}
.desk-icon.selected .di-art { filter: drop-shadow(0 0 0 #000) brightness(.85); }
.desk-icon.selected span { background: var(--navy); outline: 1px dotted #fff; }

#taskbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 30px;
  background: var(--face);
  border-top: 1px solid var(--white);
  box-shadow: inset 0 1px 0 var(--face-light);
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 2px 3px;
  z-index: 200;
}
#start-button {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  min-width: 0;
  padding: 2px 8px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: var(--bevel-out);
}
#start-button b { font-weight: bold; }
.start-logo {
  color: #d22;
  font-size: 13px;
  transform: rotate(-14deg);
  display: inline-block;
}
.task-sep {
  width: 3px;
  border-left: 1px solid var(--shadow);
  border-right: 1px solid var(--white);
  margin: 2px 1px;
}
#task-buttons { flex: 1; display: flex; gap: 3px; align-items: stretch; min-width: 0; }
.task-btn {
  flex: 0 1 180px;
  min-width: 40px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: var(--bevel-out);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-btn.active {
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--face-light);
  background-image: conic-gradient(from 90deg at 50% 50%, #fff 0 25%, #dfdfdf 0 50%, #fff 0 75%, #dfdfdf 0);
  background-size: 2px 2px;
  font-weight: bold;
}
#tray {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 6px;
  border-left: 1px solid var(--shadow);
  box-shadow: inset 1px 0 0 var(--white);
}
#drive-led {
  width: 10px; height: 10px;
  background: radial-gradient(circle at 35% 35%, #888, #222);
  border-radius: 2px;
  box-shadow: inset 0 0 2px #000;
}
#drive-led.active { background: radial-gradient(circle at 35% 35%, #ffe08a, #e2a400); animation: ledblink .5s steps(2) infinite; }
@keyframes ledblink { 50% { filter: brightness(.5); } }
#vol-icon { font-size: 12px; }
#taskbar-clock {
  min-width: 58px;
  text-align: center;
}

/* Start menu */
#start-menu {
  position: absolute;
  left: 3px; bottom: 31px;
  width: 210px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: var(--bevel-out), 2px 2px 0 rgba(0,0,0,.35);
  z-index: 250;
  display: flex;
}
#start-menu[hidden] { display: none; }
.sm-banner {
  width: 22px;
  background: linear-gradient(to top, var(--navy), var(--navy2));
  writing-mode: vertical-rl;
  rotate: 180deg;
  color: #fff;
  font-weight: bold;
  font-size: 15px;
  letter-spacing: 1px;
  text-align: left;
  padding: 8px 3px;
}
.sm-items { flex: 1; padding: 3px; }

/* ================= APP WINDOW ================= */
#app-window {
  position: fixed;
  inset: 0 0 30px 0;
  display: flex;
  flex-direction: column;
  background: var(--face);
  z-index: 100;
  min-width: 320px;
}
#app-window[hidden] { display: none; }
#app-window.restored {
  inset: auto;
  top: 4%; left: 6%; right: 6%; bottom: calc(30px + 4%);
  box-shadow: 4px 4px 0 rgba(0,0,0,.35), 0 0 0 1px var(--shadow);
}
.workarea {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--face);
}

/* ================= SIDEBAR ================= */
.sidebar {
  width: 300px;
  min-width: 220px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--face);
  border-right: 1px solid var(--shadow);
  min-height: 0;
}
#sash {
  width: 4px;
  cursor: ew-resize;
  background: var(--face);
  border-right: 1px solid var(--shadow);
  flex: none;
  touch-action: none;
}
.pane-title {
  font-weight: bold;
  padding: 3px 6px 2px;
  letter-spacing: .3px;
}
.search-row { display: flex; gap: 4px; padding: 2px 6px 4px; }
#search-input, #refine-input, #index-input {
  flex: 1;
  min-width: 40px;
  height: 21px;
  padding: 2px 6px;
  background: var(--white);
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--face-light);
  user-select: text;
  -webkit-user-select: text;
}
#search-go { min-height: 21px; padding: 1px 8px; }
.search-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 5px;
  color: #000;
}
.search-options label { display: flex; gap: 4px; align-items: center; }
#search-clear { min-height: 19px; padding: 1px 6px; }

#typedown-box {
  position: relative;
  z-index: 40;
  margin: 0 6px 4px;
  background: var(--white);
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  max-height: 132px;
  overflow-y: auto;
}
.td-row { padding: 2px 6px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-row:hover, .td-row.hl { background: var(--navy); color: #fff; }
.td-row .td-kind { float: right; opacity: .65; font-size: 10px; margin-left: 8px; }

.sidebar-tabs { display: flex; padding: 0 4px; gap: 2px; }
.stab {
  padding: 3px 8px 4px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--white) var(--shadow) var(--face) var(--white);
  box-shadow: inset 1px 1px 0 var(--face-light);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  position: relative;
  top: 1px;
}
.stab.active {
  top: 0;
  padding-bottom: 6px;
  background: var(--face);
  z-index: 2;
  font-weight: bold;
}
.sidebar-body {
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--shadow);
  box-shadow: inset 0 1px 0 var(--face-light);
  display: flex;
  flex-direction: column;
  background: var(--face);
}
.tab-panel { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab-panel.active { display: flex; }

.search-summary {
  padding: 4px 8px;
  background: var(--face);
  border-bottom: 1px solid var(--shadow);
  box-shadow: inset 0 1px 0 var(--face-light);
  font-size: 11px;
}
.search-summary b { color: var(--navy); }
#refine-bar { padding: 3px 6px; border-bottom: 1px solid var(--shadow); display: flex; }
#results-list { flex: 1; overflow-y: auto; background: var(--white); border: 1px solid; border-color: var(--shadow) var(--white) var(--white) var(--shadow); box-shadow: inset 1px 1px 0 var(--dark); margin: 0 6px 6px; }
.result-tier {
  padding: 3px 6px;
  background: #e4e4d8;
  border-bottom: 1px solid #a8a894;
  font-weight: bold;
  color: #40402c;
  position: sticky;
  top: 0;
}
.result-hit {
  display: block;
  padding: 4px 7px 5px;
  border-bottom: 1px dotted #c8c8c8;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
.result-hit:hover { background: #e8ecf8; }
.result-hit.sel { background: var(--navy); color: #fff; }
.result-hit.sel .rh-snip { color: #cdd8ff; }
.rh-title { font-weight: bold; }
.rh-title .rh-badge {
  font-weight: normal;
  font-size: 9px;
  border: 1px solid currentColor;
  padding: 0 3px;
  margin-left: 6px;
  vertical-align: 1px;
}
.rh-snip { display: block; font-size: 11px; color: #333; margin-top: 1px; }
.rh-snip mark { background: #ffe27a; color: inherit; padding: 0; }
.result-hit.sel .rh-snip mark { background: #ffd23c; color: #000; }
.hitcount { opacity: .75; font-size: 10px; }
.progressive-note {
  padding: 5px 8px;
  color: #444;
  font-style: italic;
}
.progressive-note::after {
  content: "▮";
  margin-left: 3px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.empty-note { padding: 10px 12px; color: #444; line-height: 1.5; }
.pane-hint { padding: 4px 8px; color: #333; border-bottom: 1px solid var(--shadow); }

/* Browse tree */
#browse-tree {
  flex: 1;
  overflow: auto;
  background: var(--white);
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark);
  margin: 0 6px 6px;
  padding: 4px 2px;
  font-size: 11.5px;
}
.tree-node { }
.tree-label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 4px;
  white-space: nowrap;
  cursor: default;
}
.tree-label:hover { background: #eef; }
.tree-caret {
  width: 11px; height: 11px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  font-size: 8px;
  color: #000;
}
.tree-caret.expandable { border-color: var(--shadow); background: var(--white); box-shadow: 1px 1px 0 var(--face-light); }
.tree-caret.open::before { content: "▾"; font-size: 8px; }
.tree-caret.closed::before { content: "▸"; font-size: 8px; }
.tree-children { margin-left: 17px; }
.tree-children.collapsed { display: none; }
.tree-article { color: var(--link); text-decoration: underline; }
.tree-article:hover { background: #eef; }
.tree-count { color: #777; }

/* Index */
#index-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 4px 6px 6px;
  padding: 0;
  background: var(--white);
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark);
}
#index-input { margin: 4px 6px 0; width: calc(100% - 12px); }
.idx-group {
  background: #e4e4d8;
  padding: 2px 8px;
  font-weight: bold;
  border-bottom: 1px solid #a8a894;
  position: sticky;
  top: 0;
}
.idx-entry { padding: 2px 10px 2px 18px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idx-entry:hover { background: #e8ecf8; }
.idx-entry .idx-sub { color: #777; font-style: italic; }
.idx-entry.sel { background: var(--navy); color: #fff; }

/* Favorites */
#fav-list { flex: 1; overflow-y: auto; list-style: none; margin: 4px 6px 6px; padding: 0; background: var(--white); border: 1px solid; border-color: var(--shadow) var(--white) var(--white) var(--shadow); box-shadow: inset 1px 1px 0 var(--dark); }
.fav-item { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-bottom: 1px dotted #ccc; }
.fav-item a { color: var(--link); text-decoration: underline; flex: 1; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-del { min-height: 17px; padding: 0 4px; min-width: 0; }

/* ================= MAIN PANE / VIEWS ================= */
.mainpane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #ece9d8;
  position: relative;
}
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

/* ---------- HOME ---------- */
#view-home { overflow-y: auto; padding: 0; background: #f5f1e2; }
.home-masthead {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px 14px;
  background:
    linear-gradient(180deg, rgba(0,0,64,.06), rgba(0,0,64,0)),
    repeating-linear-gradient(135deg, #f8f4e6 0 14px, #f1ecd8 14px 28px);
  border-bottom: 3px double #7a6a3a;
}
.home-masthead h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 3.4vw, 30px);
  letter-spacing: 1px;
  color: #1a1a4e;
  font-variant: small-caps;
}
.edition-line { margin: 3px 0 0; color: #6a5a2a; font-size: 12px; letter-spacing: .4px; }
.thistle-badge {
  width: 58px; height: 58px;
  flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Ccircle cx='30' cy='30' r='28' fill='%23000080'/%3E%3Ccircle cx='30' cy='30' r='25' fill='none' stroke='%23d4af37' stroke-width='1.5'/%3E%3Ctext x='30' y='41' text-anchor='middle' font-family='Georgia,serif' font-size='26' fill='%23d4af37'%3E%C3%A6%3C/text%3E%3C/svg%3E") center/contain no-repeat;
}
.home-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
  padding: 18px 24px 8px;
}
.rule-head {
  font-family: Georgia, serif;
  font-size: 15px;
  color: #1a1a4e;
  border-bottom: 2px solid #7a6a3a;
  padding-bottom: 2px;
  margin: 18px 0 10px;
  font-variant: small-caps;
  letter-spacing: .5px;
}
.rule-head:first-child { margin-top: 0; }
.aotd-date { color: #6a5a2a; font-style: italic; margin: -6px 0 10px; font-size: 12px; }
#aotd-card {
  border: 1px solid #b8ab7e;
  background: #fdfbf2;
  box-shadow: 3px 3px 0 rgba(122,106,58,.25);
}
.aotd-inner { padding: 14px 16px; }
.aotd-title {
  font-family: Georgia, serif;
  font-size: 19px;
  margin: 0 0 2px;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}
.aotd-pron { color: #777; font-size: 12px; margin: 0 0 8px; font-style: italic; }
.aotd-text { font-family: Georgia, serif; font-size: 13.5px; line-height: 1.55; margin: 0; }
.aotd-more { margin-top: 8px; font-size: 11px; }
.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.explore-cell {
  border: 1px solid #b8ab7e;
  background: #fdfbf2;
  padding: 9px 10px;
  cursor: pointer;
}
.explore-cell:hover { background: #f3eeda; box-shadow: 2px 2px 0 rgba(122,106,58,.3); }
.explore-cell b { display: block; font-family: Georgia, serif; font-size: 13px; color: #1a1a4e; }
.explore-cell span { font-size: 11px; color: #665; }
.home-col-side h2 { margin-top: 0; }
.home-col-side h2 + *, .disc-notes p { font-size: 12px; }
.disc-notes {
  border: 1px solid #b8ab7e;
  background: #fdfbf2;
  padding: 10px 12px;
  font-size: 12px !important;
  line-height: 1.5;
  font-family: Georgia, serif;
}
.disc-notes p { margin: 0 0 6px; }
.disc-notes i { color: #6a5a2a; }
.onthis-disc { margin: 0; padding-left: 18px; line-height: 1.7; font-size: 12px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.home-actions button { min-height: 26px; }
.home-footer {
  margin-top: 18px;
  padding: 10px 24px 16px;
  border-top: 1px solid #cfc49a;
  color: #665c3a;
  font-style: italic;
  font-family: Georgia, serif;
  font-size: 12px;
}

/* ---------- READER ---------- */
#view-reader { background: #fbf8ee; }
.reader-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px clamp(16px, 5vw, 64px) 48px;
  font-family: Georgia, "Times New Roman", serif;
  user-select: text;
  -webkit-user-select: text;
}
.art-header { border-bottom: 3px double #7a6a3a; padding-bottom: 10px; margin-bottom: 14px; }
.art-kicker {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-family: Tahoma, sans-serif;
  font-size: 10px;
  color: #6a5a2a;
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.art-kicker .div-tag { border: 1px solid #a89868; padding: 0 5px; background: #f1ecd8; }
.art-title {
  font-size: clamp(24px, 4vw, 34px);
  margin: 0;
  color: #14143c;
  font-weight: normal;
  line-height: 1.12;
}
.art-pron { color: #777; margin: 4px 0 0; font-style: italic; font-size: 13px; }
.art-byline { font-size: 11px; color: #887; margin-top: 6px; font-family: Tahoma, sans-serif; }

.art-factbox {
  float: right;
  width: min(300px, 46%);
  margin: 4px 0 14px 22px;
  border: 1px solid #a89868;
  background: #f1ecd8;
  box-shadow: 3px 3px 0 rgba(122,106,58,.22);
  font-family: Tahoma, sans-serif;
  font-size: 11px;
}
.factbox-head {
  background: #1a1a4e;
  color: #f1ecd8;
  padding: 4px 9px;
  font-weight: bold;
  letter-spacing: .6px;
  font-size: 10.5px;
  text-transform: uppercase;
}
.factbox-body { padding: 7px 9px; }
.fact-row { display: flex; gap: 8px; padding: 2px 0; border-bottom: 1px dotted #c9bd92; }
.fact-row:last-child { border-bottom: none; }
.fact-k { flex: 0 0 38%; color: #55492a; }
.fact-v { flex: 1; font-weight: bold; color: #111; }

.art-section h2 {
  font-size: 19px;
  color: #1a1a4e;
  margin: 26px 0 8px;
  border-bottom: 1px solid #c9bd92;
  padding-bottom: 2px;
  scroll-margin-top: 8px;
}
.art-section h3 { font-size: 15px; color: #33336e; margin: 18px 0 6px; }
.reader-scroll p { line-height: 1.62; font-size: 14.5px; margin: 0 0 12px; text-align: justify; hyphens: auto; }
.reader-scroll .lead-para::first-letter {
  initial-letter: unset;
  font-size: 1em;
}
.xref {
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}
.xref:hover { background: #dfe6ff; }
.xref.sup { text-decoration: none; border-bottom: 1px dashed var(--link); }
mark.searchmark { background: #ffe27a; }

figure.art-fig {
  margin: 16px 0 18px;
  clear: both;
  max-width: 520px;
}
figure.art-fig.floatright { float: right; margin: 4px 0 12px 20px; max-width: 340px; }
figure.art-fig .fig-frame {
  border: 1px solid #8a7a4a;
  background: #fff;
  padding: 6px;
  box-shadow: 3px 3px 0 rgba(122,106,58,.25);
}
figure.art-fig svg { display: block; width: 100%; height: auto; background: #fff; }
figure.art-fig figcaption {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  color: #55492a;
  padding: 5px 2px 0;
  line-height: 1.45;
}
figure.art-fig figcaption b { color: #1a1a4e; }

.related-block {
  clear: both;
  margin-top: 30px;
  border: 1px solid #a89868;
  background: #f1ecd8;
  padding: 10px 14px;
  font-family: Tahoma, sans-serif;
  font-size: 12px;
}
.related-block h4 { margin: 0 0 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: #1a1a4e; }
.related-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.related-links a { color: var(--link); text-decoration: underline; cursor: pointer; }

.citation-line {
  clear: both;
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px solid #c9bd92;
  font-family: Tahoma, sans-serif;
  font-size: 10.5px;
  color: #666;
}
.article-toolbar-inline {
  float: right;
  margin: 2px 0 8px 12px;
  display: flex;
  gap: 4px;
}
.ati-btn { min-height: 20px; min-width: 0; padding: 1px 7px; }

/* ---------- ATLAS ---------- */
#view-atlas { background: #dce6ea; }
.atlas-toolbar, .timeline-toolbar, .gallery-toolbar, .media-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--face);
  border-bottom: 1px solid var(--shadow);
  box-shadow: inset 0 1px 0 var(--face-light);
  flex-wrap: wrap;
}
.flex-spacer { flex: 1; }
.atlas-crumb { font-weight: bold; color: var(--navy); min-width: 70px; }
.atlas-toggle { display: flex; gap: 4px; align-items: center; }
.atlas-stage {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #b8d4de;
  display: grid;
  place-items: center;
}
#atlas-svg { width: 100%; height: 100%; display: block; }
#atlas-svg text { font-family: Tahoma, sans-serif; pointer-events: none; }
#atlas-svg .country { cursor: pointer; }
#atlas-svg .country:hover { fill-opacity: .85; stroke: #b3261e; stroke-width: 1.6; }
#atlas-svg .country.has-article { }
#atlas-svg .graticule { stroke: rgba(255,255,255,.55); stroke-width: .6; fill: none; pointer-events: none; }
.atlas-readout {
  position: absolute;
  top: 6px; left: 8px;
  background: rgba(240,240,224,.92);
  border: 1px solid #808080;
  padding: 2px 8px;
  font-size: 11px;
  font-family: Tahoma, sans-serif;
}
.atlas-scalebar {
  position: absolute;
  bottom: 8px; left: 8px;
  font-size: 10px;
  font-family: Tahoma, sans-serif;
  color: #123;
}
.atlas-scalebar i {
  display: block;
  height: 5px;
  width: 120px;
  border: 1px solid #123;
  border-top: none;
  background: repeating-linear-gradient(90deg, #123 0 20px, transparent 20px 40px);
  margin-bottom: 2px;
}
.compass {
  position: absolute;
  bottom: 10px; right: 12px;
  width: 42px; height: 42px;
  border: 1.5px solid #123;
  border-radius: 50%;
  background: rgba(240,240,224,.85);
  display: grid;
  place-items: center;
}
.compass b { position: absolute; top: 1px; font-size: 10px; font-family: Georgia, serif; }
.compass i {
  color: #b3261e;
  font-size: 17px;
  transform: translateY(-3px);
  font-style: normal;
}
.atlas-tip {
  position: absolute;
  background: #ffffe1;
  border: 1px solid #000;
  padding: 3px 8px;
  font-size: 11px;
  font-family: Tahoma, sans-serif;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
  box-shadow: 1px 1px 2px rgba(0,0,0,.3);
}
.atlas-tip b { color: #00008b; }
.atlas-footer {
  padding: 4px 8px;
  background: var(--face);
  border-top: 1px solid var(--shadow);
  font-size: 11px;
}
.atlas-region-list a { color: var(--link); text-decoration: underline; cursor: pointer; margin-right: 10px; white-space: nowrap; display: inline-block; }

/* ---------- TIMELINE ---------- */
#view-timeline { background: #efe8d8; }
.timeline-band-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.timeline-ruler {
  display: flex;
  background: #1a1a4e;
  color: #f1ecd8;
  font-size: 10px;
  overflow-x: hidden;
  flex: none;
  user-select: none;
}
.timeline-ruler .ruler-tick { flex: 1; text-align: center; padding: 3px 0; border-right: 1px solid rgba(255,255,255,.2); white-space: nowrap; overflow: hidden; }
.timeline-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; }
.timeline-canvas {
  display: flex;
  height: 100%;
  min-height: 130px;
  position: relative;
}
.tl-col {
  flex: 1 0 auto;
  width: 118px;
  border-right: 1px solid #cbbfa0;
  padding: 6px 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}
.tl-col.current { background: rgba(178,38,30,.07); }
.tl-year {
  text-align: center;
  font-family: Georgia, serif;
  font-weight: bold;
  color: #1a1a4e;
  font-size: 13px;
  border-bottom: 1px solid #cbbfa0;
  padding-bottom: 2px;
  margin-bottom: 2px;
  flex: none;
  cursor: pointer;
}
.tl-event {
  font-size: 11px;
  line-height: 1.35;
  background: #fdfbf2;
  border: 1px solid #b8ab7e;
  border-left: 4px solid #1a1a4e;
  padding: 4px 6px;
  cursor: pointer;
}
.tl-event.birth { border-left-color: #2e7d32; }
.tl-event.death { border-left-color: #6a1b9a; }
.tl-event:hover { background: #f3eeda; box-shadow: 2px 2px 0 rgba(122,106,58,.3); }
.tl-event.sel { outline: 2px solid #b3261e; }
.tl-event b { color: #1a1a4e; }
.timeline-detail {
  flex: none;
  height: 148px;
  border-top: 2px solid #7a6a3a;
  background: #fdfbf2;
  overflow-y: auto;
  padding: 10px 18px;
  font-family: Georgia, serif;
  font-size: 13px;
  line-height: 1.5;
}
.td-placeholder { color: #887; font-style: italic; }
.td-head { font-size: 15px; color: #1a1a4e; margin: 0 0 4px; }
.td-head .td-year { color: #b3261e; }
.timeline-detail a.xref { font-family: Tahoma, sans-serif; font-size: 11.5px; }
.tl-era-label { font-family: Tahoma, sans-serif; font-size: 10px; color: #6a5a2a; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 2px; }

/* ---------- GALLERY ---------- */
#view-gallery { overflow-y: auto; background: #e7e2d2; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  padding: 14px;
}
.gal-card {
  border: 1px solid #8a7a4a;
  background: #fdfbf2;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(122,106,58,.22);
}
.gal-card:hover { outline: 2px solid #b3261e; }
.gal-thumb {
  aspect-ratio: 4 / 3;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid #b8ab7e;
}
.gal-thumb svg { width: 100%; height: 100%; display: block; }
.gal-cap { padding: 6px 8px 8px; font-family: Tahoma, sans-serif; font-size: 11px; }
.gal-cap b { display: block; color: #1a1a4e; margin-bottom: 1px; }
.gal-cap span { color: #665c3a; }
.gallery-count { font-size: 11px; }

/* ---------- MEDIA VIEWER ---------- */
.media-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #4c4a42;
  padding: 12px;
  overflow: hidden;
}
.media-art-holder {
  background: #fff;
  border: 6px solid #d9d2ba;
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
  width: min(100%, 720px);
  max-height: 100%;
  display: grid;
  place-items: center;
}
.media-art-holder svg { max-width: 100%; max-height: 56vh; width: auto; height: auto; display: block; }
.media-caption-pane { background: #fdfbf2; border-top: 2px solid #7a6a3a; padding: 8px 18px 14px; overflow-y: auto; flex: none; max-height: 170px; }
.media-caption-pane h3 { margin: 0 0 4px; font-family: Georgia, serif; color: #1a1a4e; font-size: 17px; }
.media-caption-pane p { margin: 0 0 6px; font-family: Georgia, serif; font-size: 13px; line-height: 1.5; }
.media-credit { font-size: 11px !important; color: #887 !important; font-family: Tahoma, sans-serif !important; }
.media-related { font-family: Tahoma, sans-serif !important; font-size: 11.5px !important; }
.media-count { font-size: 11px; color: #333; }

/* ---------- NOT FOUND ---------- */
#view-notfound { align-items: center; justify-content: center; background: #fbf8ee; }
.nf-box {
  max-width: 430px;
  border: 1px solid #a89868;
  background: #f1ecd8;
  box-shadow: 4px 4px 0 rgba(122,106,58,.25);
  padding: 22px 26px;
  text-align: center;
  font-family: Tahoma, sans-serif;
}
.nf-icon { font-size: 34px; color: #b8860b; }
.nf-box h2 { font-family: Georgia, serif; color: #1a1a4e; margin: 8px 0 8px; }
.nf-suggestions { font-size: 12px; line-height: 1.6; }
.nf-suggestions a { color: var(--link); cursor: pointer; text-decoration: underline; }

/* ================= SPLASH ================= */
#splash {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  background: rgba(0, 32, 32, .35);
}
#splash[hidden] { display: none; }
.splash-frame {
  width: min(520px, 92vw);
  border: 2px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: var(--bevel-out), 6px 6px 0 rgba(0,0,0,.4);
  background: #fdfbf2;
}
.splash-top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 30px 34px 22px;
  background:
    radial-gradient(140% 120% at 85% -10%, #2a2aa8 0%, #000080 55%, #00004a 100%);
}
.splash-thistle {
  width: 74px; height: 74px;
  flex: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(212,175,55,.16) 0 46%, transparent 47%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Ccircle cx='30' cy='30' r='29' fill='%23000080'/%3E%3Ccircle cx='30' cy='30' r='26' fill='none' stroke='%23d4af37' stroke-width='1.4'/%3E%3Ctext x='30' y='41' text-anchor='middle' font-family='Georgia,serif' font-size='27' fill='%23d4af37'%3E%C3%A6%3C/text%3E%3C/svg%3E") center/contain no-repeat;
}
.splash-brand {
  color: #d4af37;
  font-family: Georgia, serif;
  letter-spacing: 2.5px;
  font-size: 13px;
  font-variant: small-caps;
}
.splash-product {
  color: #fff;
  font-family: Georgia, serif;
  font-size: 44px;
  line-height: 1;
  margin: 4px 0 2px;
  letter-spacing: 1px;
}
.splash-sub { color: #aab4e8; font-size: 11.5px; letter-spacing: .4px; }
.splash-progress-area { padding: 18px 34px 8px; }
.splash-status {
  margin-top: 8px;
  font-size: 11.5px;
  color: #222;
  min-height: 15px;
  font-family: Tahoma, sans-serif;
}
.splash-status::after { content: ""; }
.splash-fineprint {
  padding: 10px 34px 16px;
  font-size: 9.5px;
  color: #77705a;
  line-height: 1.5;
  border-top: 1px solid #d8cf9e;
  font-family: Tahoma, sans-serif;
}

/* ================= CD TRAY ANIMATION ================= */
#cd-tray-overlay {
  position: fixed;
  inset: 0;
  z-index: 255;
  display: grid;
  place-items: center;
  background: rgba(0, 24, 24, .55);
}
#cd-tray-overlay[hidden] { display: none; }
.cd-drive-slot {
  width: 190px;
  height: 54px;
  background: linear-gradient(#d8d8d8, #a8a8a8);
  border: 2px solid;
  border-color: #eee #555 #555 #eee;
  border-radius: 4px;
  position: relative;
  box-shadow: 0 6px 18px rgba(0,0,0,.5), inset 0 2px 3px rgba(255,255,255,.6);
}
.cd-tray {
  position: absolute;
  left: 12px; right: 12px; top: 12px;
  height: 30px;
  background: linear-gradient(#bbb, #909090);
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
  transition: transform .9s cubic-bezier(.6,0,.4,1);
}
.cd-disc {
  position: absolute;
  left: 50%; top: 50%;
  width: 96px; height: 96px;
  margin: -48px 0 0 -48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #f8f8ff 0 12px, #c8c8e8 13px, transparent 14px),
    radial-gradient(circle at 50% 50%, transparent 0 44px, rgba(255,255,255,.5) 45px 46px, transparent 47px),
    conic-gradient(from 0deg, #cfe0f8, #e8c8f8, #c8f8e0, #f8e8c8, #cfe0f8);
  box-shadow: 0 0 0 2px #999, 0 4px 14px rgba(0,0,0,.45);
  animation: cdspin 2.4s linear infinite;
  animation-play-state: paused;
}
@keyframes cdspin { to { transform: rotate(360deg); } }
.cd-caption {
  margin-top: 84px;
  color: #e8e8d8;
  font-family: Tahoma, sans-serif;
  font-size: 12px;
  letter-spacing: .4px;
  text-align: center;
  text-shadow: 1px 1px 2px #000;
}

/* ================= PRINT PREVIEW ================= */
#print-preview .dialog-frame { width: min(640px, 94vw); }
.print-pages {
  height: 300px;
  overflow-y: auto;
  background: #808080;
  padding: 14px;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  margin: 0 14px;
}
.print-page {
  background: #fff;
  width: 380px;
  min-height: 480px;
  margin: 0 auto 16px;
  padding: 34px 38px;
  box-shadow: 2px 2px 6px rgba(0,0,0,.5);
  font-family: Georgia, serif;
  font-size: 11px;
  line-height: 1.5;
  position: relative;
}
.print-page .pp-head, .print-page .pp-foot {
  font-family: Tahoma, sans-serif;
  font-size: 8.5px;
  color: #555;
  display: flex;
  justify-content: space-between;
}
.print-page .pp-foot { position: absolute; bottom: 14px; left: 38px; right: 38px; }
.print-page h1 { font-size: 17px; margin: 4px 0 8px; }
.print-page p { margin: 0 0 8px; text-align: justify; }
.print-preview-options { display: flex; gap: 16px; padding: 10px 14px; flex-wrap: wrap; }
.print-preview-options label { display: flex; align-items: center; gap: 5px; }

/* ================= RESPONSIVE / NARROW VIEWPORTS ================= */
@media (max-width: 760px) {
  .home-columns { grid-template-columns: 1fr; }
  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    z-index: 30;
    width: min(86vw, 320px) !important;
    box-shadow: 4px 0 12px rgba(0,0,0,.35);
    transform: translateX(-102%);
    transition: transform .18s ease-out;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .workarea { position: relative; }
  #sash { display: none; }
  .tool-btn span { display: none; }
  .tool-btn { min-width: 34px; height: 38px; }
  #addressbar { display: none; }
  .toolbar-address { display: none !important; }
  #sidebar-toggle-btn { display: inline-flex !important; }
  .reader-scroll { padding: 16px 14px 40px; }
  .art-factbox { float: none; width: 100%; margin: 0 0 14px; }
  figure.art-fig.floatright { float: none; margin: 12px 0; max-width: 100%; }
  .timeline-detail { height: 190px; }
  .tl-col { width: 104px; }
  .gal-grid, .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
  .media-stage { padding: 8px; }
}
#sidebar-toggle-btn { display: none; }

@media (min-width: 761px) {
  body.sidebar-open .sidebar { transform: none; }
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Print of the page itself is not intended; the in-app print dialog handles it */
@media print { body > * { display: none !important; } }
