:root{--bg:#f8fafc;--card:#fff;--ink:#172033;--ink-soft:#475569;--muted:#64748b;--border:#e2e8f0;--primary:#2563eb;--primary-dark:#1d4ed8;--accent:#b7791f;--brown:#92400e;--gold:#d97706;--success:#059669;--danger:#dc2626;--radius:12px;--shadow:0 1px 3px rgba(15,23,42,.06),0 1px 2px rgba(15,23,42,.04);--shadow-md:0 8px 22px rgba(15,23,42,.08);--hero:linear-gradient(135deg,#fff7ed 0%,#eff6ff 50%,#fefce8 100%)}
*{box-sizing:border-box}
html,body{margin:0;padding:0;overflow-x:hidden}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--ink);line-height:1.6;font-size:16px}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}
.site-header{background:#fff;border-bottom:1px solid var(--border);position:sticky;top:0;z-index:100}
.nav-wrap{max-width:1200px;margin:0 auto;padding:14px 20px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px}
.brand{font-weight:700;font-size:20px;color:var(--ink);display:flex;align-items:center;gap:8px}
.brand .diamond{color:var(--accent)}
.nav-toggle{display:none;background:#fff;border:1px solid var(--border);padding:6px 10px;border-radius:6px;cursor:pointer;font-size:18px}
.nav-menu{display:flex;list-style:none;margin:0;padding:0;gap:6px}
.nav-menu>li{position:relative}
.nav-menu>li>a,.nav-menu>li>span{padding:8px 14px;display:block;color:var(--ink);font-weight:500;cursor:pointer;border-radius:6px}
.nav-menu>li>a:hover,.nav-menu>li>span:hover{background:#f1f5f9;text-decoration:none}
.dropdown{display:none;position:absolute;top:100%;left:0;background:#fff;border:1px solid var(--border);border-radius:8px;box-shadow:var(--shadow-md);min-width:240px;padding:8px;z-index:101}
.nav-menu>li:hover .dropdown{display:block}
.dropdown li{list-style:none}
.dropdown a{display:block;padding:8px 12px;color:var(--ink-soft);border-radius:6px;font-size:14px}
.dropdown a:hover{background:#f8fafc;color:var(--primary);text-decoration:none}
header .nav-menu>li:first-child .dropdown{min-width:420px;grid-template-columns:1fr 1fr}
header .nav-menu>li:first-child:hover .dropdown{display:grid;column-gap:6px}
header .nav-menu>li:last-child .dropdown{left:auto;right:0}
.container-narrow{max-width:980px;margin:0 auto;padding:24px 20px 60px}
.crumbs{max-width:1200px;margin:0 auto;padding:10px 20px;font-size:13px;color:var(--muted)}
.breadcrumb{font-size:13px;color:var(--muted);margin-bottom:18px}
.breadcrumb a,.crumbs a{color:var(--muted)}
h1{font-size:32px;margin:0 0 10px;letter-spacing:-.02em}
h2{font-size:22px;margin:32px 0 12px;padding-left:12px;border-left:3px solid var(--accent)}
h3{font-size:18px;margin:18px 0 10px}
.hist-hero{background:var(--hero);border-bottom:1px solid var(--border)}
.hist-hero-inner{max-width:1200px;margin:0 auto;padding:50px 20px 40px;text-align:center}
.hist-hero h1{font-size:2.35rem;margin:0 0 12px;background:linear-gradient(90deg,#92400e,#2563eb,#d97706);-webkit-background-clip:text;background-clip:text;color:transparent}
.hist-hero p{font-size:1.1rem;color:var(--ink-soft);max-width:820px;margin:0 auto 20px}
.badges{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.badge{background:#fff;border:1px solid var(--border);color:var(--brown);padding:5px 12px;border-radius:999px;font-size:12px;font-weight:700;box-shadow:var(--shadow)}
.hist-search{max-width:720px;margin:24px auto 0}
.hist-search input{width:100%;padding:14px 18px;border:1px solid var(--border);border-radius:999px;font-size:15px;background:#fff;box-shadow:var(--shadow)}
.cat-block{max-width:1200px;margin:40px auto 0;padding:0 20px}
.cat-head{display:flex;align-items:center;gap:14px;margin-bottom:14px}
.cat-icon,.tool .ico{width:44px;height:44px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:800;background:#fff7ed;color:#92400e;border:1px solid #fed7aa}
.cat-head h2{margin:0;padding:0;border:none;font-size:1.4rem}
.cat-sub{color:var(--muted);margin:2px 0 0}
.tool-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px}
.tool{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);display:block;color:inherit;text-decoration:none;transition:.15s}
.tool:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);border-color:#fdba74;text-decoration:none}
.tool .ico{width:32px;height:32px;margin-bottom:8px}
.tool h3{font-size:1rem;margin:0 0 4px;color:var(--primary)}
.tool p{font-size:.88rem;color:var(--muted);margin:0}
.content-block,.tool-card{background:#fff;border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);padding:24px;margin:24px auto}
.content-block{max-width:1200px}
.tool-tagline{color:var(--muted);margin:-4px 0 18px}
.field{margin-bottom:14px}
.field label{display:block;font-weight:700;font-size:14px;margin-bottom:6px}
.field-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px}
input,select,textarea{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:8px;font-size:15px;font-family:inherit;background:#fff;color:var(--ink)}
textarea{min-height:110px;resize:vertical;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.14)}
.btn-row{display:flex;flex-wrap:wrap;gap:10px;margin:16px 0}
.btn{padding:10px 16px;border-radius:8px;border:1px solid transparent;font-weight:700;cursor:pointer;background:#fff;font-family:inherit}
.btn-primary{background:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-dark)}
.btn-secondary{border-color:var(--border);color:var(--ink-soft)}
.btn-secondary:hover{background:#f8fafc}
.result-card{background:#f0f9ff;border:1px solid #bae6fd;border-radius:var(--radius);padding:18px;margin-top:16px}
.result-row{display:flex;justify-content:space-between;gap:12px;padding:8px 0;border-bottom:1px dashed #cbd5e1;flex-wrap:wrap}
.result-row:last-child{border-bottom:none}
.lbl{font-weight:700;color:var(--ink-soft)}
.val{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;text-align:right}
.warn-box{background:#fef2f2;border:1px solid #fecaca;color:#991b1b;border-radius:8px;padding:12px;margin:12px 0}
.info-box{background:#fff7ed;border:1px solid #fed7aa;color:#7c2d12;border-radius:8px;padding:12px 14px;margin:12px 0}
.timeline{display:grid;gap:12px;margin:16px 0}
.timeline-card{background:#fff;border:1px solid var(--border);border-left:5px solid var(--accent);border-radius:10px;padding:14px;box-shadow:var(--shadow)}
.timeline-card strong{color:var(--brown)}
.horizontal-timeline{display:flex;gap:12px;overflow-x:auto;padding:16px 4px}
.horizontal-timeline .timeline-card{min-width:240px}
.vertical-line{position:relative;padding-left:24px}
.vertical-line:before{content:"";position:absolute;left:8px;top:0;bottom:0;width:3px;background:#fed7aa}
.data-table{width:100%;border-collapse:collapse;margin:12px 0;font-size:13px}
.data-table th,.data-table td{border:1px solid var(--border);padding:8px 10px;text-align:left}
.data-table th{background:#f8fafc;color:var(--ink-soft)}
.table-wrap{overflow:auto;border:1px solid var(--border);border-radius:8px}
.flashcard{min-height:190px;border:1px solid var(--border);border-radius:14px;background:linear-gradient(135deg,#fff7ed,#eff6ff);display:flex;align-items:center;justify-content:center;text-align:center;font-size:26px;font-weight:800;padding:22px;cursor:pointer;transition:transform .25s}
.flashcard.flipped{transform:rotateY(8deg);background:linear-gradient(135deg,#eff6ff,#fefce8)}
.quiz-option{display:block;width:100%;text-align:left;margin:8px 0;padding:10px 12px;border:1px solid var(--border);border-radius:8px;background:#fff;cursor:pointer}
.quiz-option.correct{border-color:#16a34a;background:#dcfce7}
.quiz-option.wrong{border-color:#dc2626;background:#fee2e2}
.progress{height:10px;background:#e2e8f0;border-radius:999px;overflow:hidden}
.progress span{display:block;height:100%;background:var(--primary)}
.svg-wrap,.map-box{background:#fff;border:1px solid var(--border);border-radius:10px;padding:12px;margin:14px 0;overflow:auto}
.svg-wrap svg,.map-box svg{max-width:100%;height:auto}
.tree-node{fill:#fff7ed;stroke:#d97706;stroke-width:2}
/* ---- Family Tree / Dynasty Tree Builder ---- */
.tree-builder{display:flex;flex-direction:column;gap:14px}
.tree-controls{background:#f8fafc;border:1px solid var(--border);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:10px}
.tree-controls #treeDesc{margin:6px 0 0;color:#475569}
.tree-form{grid-template-columns:repeat(auto-fit,minmax(200px,1fr))!important}
.btn-mini{padding:4px 10px;font-size:12px}
.tree-out{background:#ffffff;border:1px solid var(--border);border-radius:12px;padding:8px;overflow-x:auto}
.tree-wrap{margin:0!important;border:none;padding:0;background:transparent}
.tree-svg{display:block;min-width:100%}
.tree-edge{fill:none;stroke:#94a3b8;stroke-width:1.6}
.tree-rect{fill:#fef3c7;stroke:#92400e;stroke-width:1.4;transition:fill .15s ease,stroke .15s ease}
.tree-name{font:700 13px Arial,sans-serif;fill:#0f172a}
.tree-title{font:600 11px Arial,sans-serif;fill:#475569}
.tree-reign{font:700 10px Arial,sans-serif;fill:#92400e}
.tree-node-g{cursor:pointer}
.tree-node-g:hover .tree-rect{fill:#fde68a;stroke:#1d4ed8}
.tree-node-g.is-match .tree-rect{fill:#bfdbfe;stroke:#1d4ed8;stroke-width:2.4}
.tree-node-g.is-dim{opacity:.32}
.tree-node-g.is-editing .tree-rect{fill:#bbf7d0;stroke:#166534;stroke-width:2.4}
.tree-list{margin-top:0}
.tree-list .table-wrap{overflow-x:auto;border:1px solid var(--border);border-radius:10px;background:#fff}
.tree-list table{width:100%;border-collapse:collapse;min-width:680px}
.tree-list th,.tree-list td{padding:8px 10px;border-bottom:1px solid #e2e8f0;text-align:left;vertical-align:top;font-size:13px}
.tree-list thead th{background:#eff6ff;color:#1e3a8a;font-weight:700;font-size:12px;letter-spacing:.04em;text-transform:uppercase}
.tree-list tr.is-editing{background:#ecfdf5}
/* ---- Comparison Table Generator ---- */
.cmp-builder{display:flex;flex-direction:column;gap:14px}
.cmp-controls{background:#f8fafc;border:1px solid var(--border);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:10px}
.cmp-controls #cmpDesc{margin:6px 0 0;color:#475569}
.cmp-out{overflow-x:auto}
.cmp-table-wrap{border:1px solid var(--border);border-radius:12px;background:#fff;overflow-x:auto}
.cmp-table{width:100%;border-collapse:separate;border-spacing:0;min-width:760px}
.cmp-table th,.cmp-table td{padding:7px 9px;border-bottom:1px solid #e2e8f0;border-right:1px solid #e2e8f0;text-align:left;vertical-align:top;font-size:13.5px}
.cmp-table th{background:#eff6ff;color:#1e3a8a;font-weight:700;font-size:12.5px;letter-spacing:.04em;text-transform:uppercase;border-bottom:2px solid #1d4ed8}
.cmp-table th:last-child,.cmp-table td:last-child{border-right:none}
.cmp-table .cmp-th-field{width:170px}
.cmp-table .cmp-th-act{width:130px;text-align:right}
.cmp-table tbody tr:nth-child(even){background:#f8fafc}
.cmp-table tbody tr:hover{background:#fef3c7}
.cmp-cell,.cmp-col-input{width:100%;border:1px solid transparent;background:transparent;padding:6px 8px;border-radius:6px;font-family:inherit;font-size:13.5px;color:#0f172a}
.cmp-cell:focus,.cmp-col-input:focus{outline:none;border-color:#1d4ed8;background:#fff;box-shadow:0 0 0 2px rgba(29,78,216,.18)}
.cmp-col-input{font-weight:700;color:#1e3a8a;text-transform:none;letter-spacing:0}
.cmp-cell.cmp-field{font-weight:700;color:#92400e}
.cmp-act{white-space:nowrap;text-align:right}
.cmp-act .btn-mini{padding:3px 8px;font-size:12px;line-height:1}
/* ---- Historical Unit / Currency Converter ---- */
.conv-builder{display:flex;flex-direction:column;gap:14px}
.conv-builder #convCatDesc{margin:6px 0 0;color:#475569}
.conv-row{grid-template-columns:120px 1fr 1fr!important}
.conv-out{margin-top:0}
.conv-result{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:14px 16px}
.conv-result-main{font-size:18px;color:#0f172a;line-height:1.5}
.conv-result-main strong{color:#1d4ed8;font-size:22px}
.conv-result-sub{margin-top:6px;color:#64748b;font-size:13px}
.conv-notes{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:10px}
.conv-note-card{background:#f8fafc;border:1px solid var(--border);border-radius:10px;padding:10px 12px}
.conv-note-card h4{margin:0 0 4px;color:#1e3a8a;font-size:14px}
.conv-note-card p{margin:2px 0;font-size:13px;color:#334155}
.conv-table{margin-top:6px}
.conv-table-title{font-size:14px;color:#1e3a8a;margin:0 0 6px}
.conv-list{width:100%;border-collapse:collapse;min-width:520px}
.conv-list th,.conv-list td{padding:6px 9px;border-bottom:1px solid #e2e8f0;text-align:left;font-size:13px}
.conv-list thead th{background:#eff6ff;color:#1e3a8a;font-weight:700;font-size:12px;text-transform:uppercase;letter-spacing:.04em}
.conv-list tbody tr:hover{background:#fef3c7}
.conv-disclaimer{margin-top:8px;color:#64748b}
/* ---- Dynasty / Ruler Sequence Drills ---- */
.seq-builder{display:flex;flex-direction:column;gap:14px}
.seq-controls{background:#f8fafc;border:1px solid var(--border);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:10px}
.seq-controls #seqDesc{margin:6px 0 0;color:#475569}
.seq-hint{margin:0;color:#475569}
.seq-score{margin-top:0}
.seq-score-card{background:#eff6ff;border:1px solid #bfdbfe;border-radius:12px;padding:12px 14px;display:flex;align-items:center;gap:14px;color:#1e3a8a}
.seq-score-card.is-perfect{background:#ecfdf5;border-color:#10b981;color:#065f46}
.seq-score-card.is-revealed{background:#fef3c7;border-color:#f59e0b;color:#92400e;justify-content:flex-start}
.seq-score-num{font-size:28px;font-weight:800;letter-spacing:0.5px}
.seq-score-text{font-size:14px;line-height:1.4}
.seq-list{display:flex;flex-direction:column;gap:6px;background:#fff;border:1px solid var(--border);border-radius:12px;padding:10px}
.seq-row{display:flex;align-items:center;gap:10px;background:#f8fafc;border:1px solid var(--border);border-radius:10px;padding:8px 10px;transition:background .15s ease,border-color .15s ease}
.seq-row.is-right{background:#ecfdf5;border-color:#10b981}
.seq-row.is-right .seq-pos{background:#10b981;color:#fff}
.seq-row.is-wrong{background:#fef2f2;border-color:#ef4444}
.seq-row.is-wrong .seq-pos{background:#ef4444;color:#fff}
.seq-row.is-revealed{background:#fefce8;border-color:#facc15}
.seq-row.is-revealed .seq-pos{background:#ca8a04;color:#fff}
.seq-pos{flex:0 0 36px;height:36px;border-radius:50%;background:#1d4ed8;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:14px}
.seq-info{flex:1 1 auto;min-width:0}
.seq-label{font-weight:700;color:#0f172a;font-size:14px}
.seq-meta{color:#64748b;font-size:12.5px;margin-top:2px}
.seq-actions{flex:0 0 auto;display:flex;gap:4px}
.seq-actions .btn-mini{padding:4px 9px;font-size:13px;line-height:1;min-width:32px}
.seq-actions .btn-mini[disabled]{opacity:.4;cursor:not-allowed}
/* ---- Timeline Generator presets ---- */
.tl-builder{display:flex;flex-direction:column;gap:14px}
.tl-controls{background:#f8fafc;border:1px solid var(--border);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:10px}
.tl-controls #tlDesc{margin:6px 0 0;color:#475569}
.tl-add-form{background:#fff;border:1px solid var(--border);border-radius:10px;padding:8px 12px}
.tl-add-form summary{cursor:pointer;font-weight:600;color:#1e3a8a}
/* ---- Century / Decade / Year Converter ---- */
.cv-builder{display:flex;flex-direction:column;gap:14px}
.cv-card{background:#ffffff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:14px}
.cv-card h3{margin:0 0 8px;font-size:15px;color:#1e3a8a}
.cv-famous-hit{margin:0;padding:10px 12px;background:#fef3c7;border:1px solid #fde68a;border-radius:8px;color:#7c2d12;font-weight:600}
/* ---- Historical Age Calculator ---- */
.age-builder{display:flex;flex-direction:column;gap:12px}
.age-fallback{background:#f8fafc;border:1px solid var(--border);border-radius:10px;padding:8px 12px}
.age-fallback summary{cursor:pointer;font-weight:600;color:#1e3a8a}
.map-box{background:linear-gradient(180deg,#f8fbff,#eef6ff);border-color:#bfdbfe}
.map-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:10px}
.map-title-row h3{margin:0;color:#1e3a8a}
.map-title-row span{max-width:420px;color:#475569;font-size:13px;text-align:right}
.history-map{width:100%;min-width:620px;max-height:620px;display:block}
.map-outline{fill:#f8fafc;stroke:#1e3a8a;stroke-width:3;opacity:.9}
.map-land{stroke:#1e3a8a;stroke-width:1.6;opacity:.82}
.map-region{stroke:#1e3a8a;stroke-width:2;cursor:pointer;transition:filter .15s ease,opacity .15s ease,stroke-width .15s ease;outline:none}
.map-region:hover,.map-region:focus{filter:brightness(1.04) saturate(1.15);stroke:#92400e;stroke-width:4;opacity:.95}
.map-region.correct{stroke:#15803d!important;stroke-width:5;filter:drop-shadow(0 0 6px rgba(22,163,74,.45))}
.map-region.wrong{stroke:#dc2626!important;stroke-width:5;filter:drop-shadow(0 0 6px rgba(220,38,38,.45))}
.map-labels text{font-size:13px;font-weight:800;fill:#0f172a;text-anchor:middle;paint-order:stroke;stroke:#fff;stroke-width:4;stroke-linejoin:round;pointer-events:none}
.map-cities circle{fill:#111827;stroke:#fff;stroke-width:2}
.map-cities text{font-size:12px;font-weight:800;fill:#111827;paint-order:stroke;stroke:#fff;stroke-width:4;stroke-linejoin:round}
.map-graticule path{fill:none;stroke:#bfdbfe;stroke-width:1;stroke-dasharray:5 7}
.map-overlay{fill:#f97316;stroke:#9a3412;stroke-width:2.5;fill-opacity:.42;stroke-opacity:.9}
.empire-cities circle{fill:#7c2d12}
.map-legend{display:flex;align-items:center;gap:8px;font-size:13px;color:#475569;margin-top:8px}
.legend-swatch{display:inline-block;width:24px;height:12px;border-radius:999px;background:#f97316;border:1px solid #9a3412;opacity:.58}
.event-pin path{fill:#dc2626;stroke:#fff;stroke-width:3;filter:drop-shadow(0 2px 3px rgba(15,23,42,.3))}
.event-pin circle{fill:#fff;stroke:#dc2626;stroke-width:2}
.event-pin text{font-size:14px;font-weight:900;fill:#991b1b;paint-order:stroke;stroke:#fff;stroke-width:5;stroke-linejoin:round}
.map-note{font-size:13px;color:#475569;margin-top:8px}
.compact-hero{margin-bottom:22px}
.history-map-tool{padding:18px}
.hm-shell{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(320px,.75fr);gap:18px;align-items:start}
.hm-shell:has(>.hm-side-list:not([hidden])){grid-template-columns:220px minmax(0,1.05fr) minmax(300px,.75fr)}
.hm-side-list{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:12px;position:sticky;top:84px;max-height:calc(100vh - 100px);overflow:auto;display:flex;flex-direction:column;gap:10px}
.hm-side-list-title{font-size:15px;color:#1e3a8a;margin:0}
.hm-side-list-items{display:flex;flex-direction:column;gap:6px}
.hm-side-item{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;background:#f8fafc;border:1px solid var(--border);border-radius:8px;padding:8px 10px;cursor:pointer;transition:background .15s ease,border-color .15s ease,transform .05s ease}
.hm-side-item:hover{background:#eff6ff;border-color:#93c5fd}
.hm-side-item:active{transform:translateY(1px)}
.hm-side-item.is-active{background:#1d4ed8;border-color:#1d4ed8;color:#fff}
.hm-side-item.is-active .hm-side-item-period{color:#dbeafe}
.hm-side-item-name{font-weight:700;font-size:13px;color:inherit}
.hm-side-item-period{font-size:11px;color:#64748b}
.hm-map-inner [id^="country-"]{cursor:default}
.hm-map-inner [id^="country-"].hm-empire-country-active{fill:#fde68a!important;stroke:#92400e!important;stroke-width:0.9!important;filter:drop-shadow(0 0 4px rgba(146,64,14,.45));cursor:pointer}
.hm-map-inner #hmCountryLabelsContainer{pointer-events:none}
.hm-map-inner #hmCountryLabelsContainer .hm-country-label-on{opacity:0.96}
.hm-controls{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:12px}
.hm-controls .field{margin:0}
.search-results{display:none;position:absolute;z-index:20;background:#fff;border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow);margin-top:6px;max-height:280px;overflow:auto;width:min(420px,100%)}
.field{position:relative}
.search-results button{display:block;width:100%;text-align:left;background:#fff;border:0;border-bottom:1px solid var(--border);padding:10px 12px;cursor:pointer}
.search-results button:hover,.search-results button:focus{background:#eff6ff}
.search-results strong{display:block;color:#1e3a8a}
.search-results span{display:block;color:#64748b;font-size:12px;margin-top:2px}
.hm-filter-row{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 14px}
.hm-chip{border:1px solid var(--border);background:#fff;border-radius:999px;padding:8px 12px;color:#334155;font-size:13px;font-weight:700;cursor:pointer}
.hm-chip.active{background:#1d4ed8;color:#fff;border-color:#1d4ed8}
.hm-map-card,.hm-panel{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:14px}
.hm-map-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.hm-map-toolbar h2{font-size:18px;margin:0;color:#1e3a8a}
.hm-zoom{display:flex;gap:6px}
.hm-zoom button{min-width:38px;border:1px solid var(--border);border-radius:8px;background:#f8fafc;padding:8px 10px;cursor:pointer;font-weight:800}
.hm-map-stage{position:relative;overflow:auto;border:1px solid #bfdbfe;border-radius:10px;background:linear-gradient(180deg,#f8fbff,#eef6ff);min-height:360px}
.hm-map-inner{width:100%;min-width:680px;transform-origin:0 0;transition:transform .18s ease}
.hm-map-inner svg{display:block;width:100%;height:auto}
.hm-map-inner [id]{cursor:pointer;transition:filter .15s ease,opacity .15s ease,stroke-width .15s ease}
.hm-map-inner [id]:hover,.hm-map-inner [id]:focus{filter:brightness(1.06) saturate(1.15);outline:none}
.hm-map-inner .hm-selected{stroke:#1d4ed8!important;stroke-width:5!important;filter:drop-shadow(0 0 8px rgba(29,78,216,.45))}
.hm-map-inner .hm-muted{opacity:.24}
.hm-map-inner g[id$="-label"]{transition:filter .15s ease,opacity .15s ease}
.hm-map-inner g[id$="-label"]>text{stroke:none!important;stroke-width:0!important}
.hm-map-inner g[id$="-label"]:hover>rect{fill:#fef3c7!important;fill-opacity:1!important}
.hm-map-inner g[id$="-label"].hm-selected>rect{fill:#dbeafe!important;fill-opacity:1!important;stroke:#1d4ed8!important;stroke-width:2!important;filter:drop-shadow(0 0 6px rgba(29,78,216,.45))}
.hm-map-inner g[id$="-label"].hm-selected{filter:none!important}
/* ----------- Single-map page layout ----------- */
.sm-controls{margin-bottom:14px}
.sm-controls .field{margin:0;position:relative}
.sm-shell{display:grid;grid-template-columns:240px minmax(0,1fr);gap:18px;align-items:start;margin-bottom:18px}
.sm-side{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:12px;position:sticky;top:84px;max-height:calc(100vh - 110px);overflow:auto;display:flex;flex-direction:column;gap:10px}
.sm-side-title{font-size:14px;color:#1e3a8a;margin:0}
.sm-side-items{display:flex;flex-direction:column;gap:6px}
.sm-side-item{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;background:#f8fafc;border:1px solid var(--border);border-radius:8px;padding:8px 10px;cursor:pointer;transition:background .15s ease,border-color .15s ease,transform .05s ease;color:#0f172a}
.sm-side-item:hover{background:#eff6ff;border-color:#93c5fd}
.sm-side-item:active{transform:translateY(1px)}
.sm-side-item.is-active{background:#1d4ed8;border-color:#1d4ed8;color:#fff}
.sm-side-item.is-active .sm-side-meta{color:#dbeafe}
.sm-side-name{font-weight:700;font-size:13px;color:inherit}
.sm-side-meta{font-size:11px;color:#64748b}
.sm-map-card{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:14px}
.sm-map-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.sm-map-toolbar h2{font-size:18px;margin:0;color:#1e3a8a}
.sm-zoom{display:flex;gap:6px}
.sm-zoom button{min-width:38px;border:1px solid var(--border);border-radius:8px;background:#f8fafc;padding:8px 10px;cursor:pointer;font-weight:800}
.sm-map-stage{position:relative;overflow:auto;border:1px solid #bfdbfe;border-radius:10px;background:linear-gradient(180deg,#f8fbff,#eef6ff);min-height:380px}
.sm-map-inner{width:100%;min-width:680px;transform-origin:0 0;transition:transform .18s ease}
.sm-map-inner svg{display:block;width:100%;height:auto}
.sm-map-inner [id]{cursor:pointer;transition:filter .15s ease,opacity .15s ease,stroke-width .15s ease}
.sm-map-inner [id]:hover,.sm-map-inner [id]:focus{filter:brightness(1.06) saturate(1.15);outline:none}
.sm-map-inner .hm-selected{fill:#fde68a!important;stroke:#1d4ed8!important;stroke-width:3!important;filter:drop-shadow(0 0 8px rgba(29,78,216,.55))}
.sm-map-inner [id^="country-"]{cursor:default}
.sm-map-inner [id^="country-"].hm-empire-country-active{fill:#fde68a!important;stroke:#92400e!important;stroke-width:0.9!important;filter:drop-shadow(0 0 4px rgba(146,64,14,.45));cursor:pointer}
/* Dynamic labels render as text only with a white halo so they never hide
   the country fill underneath. */
.sm-map-inner #hmDynamicLabels text{paint-order:stroke;stroke-linejoin:round}
/* When in single-map mode every baked-in label inside the SVG is hidden so
   only #hmDynamicLabels (filled by JS for the current selection) is visible. */
.sm-map-inner.sm-mode svg text{display:none}
.sm-map-inner.sm-mode svg g[id$="-label"]{display:none}
.sm-map-inner.sm-mode svg #hmCountryLabelsContainer{display:none}
.sm-map-inner.sm-mode svg #hmDynamicLabels text{display:inline!important}
/* Civilisation overlays become translucent when selected so the highlighted
   member countries underneath stay visible (otherwise the union shape covers
   them with one big opaque fill). */
.sm-map-inner.sm-mode .hm-civ-region{fill-opacity:0.42}
.sm-map-inner.sm-mode .hm-civ-region.hm-selected{fill-opacity:0.05!important;stroke:#1d4ed8!important;stroke-width:2.4!important;filter:none!important}
.sm-quick{margin:18px 0}
.sm-quick-card{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:18px}
.sm-quick-card .sm-type{display:inline-block;background:#eff6ff;color:#1d4ed8;font-size:12px;padding:3px 8px;border-radius:999px;font-weight:700;margin-bottom:6px}
.sm-quick-card h2{font-size:24px;color:#1e3a8a;margin:0 0 6px}
.sm-quick-card .sm-lead{color:#334155;font-size:15px;margin:0 0 12px;line-height:1.5}
.sm-quick-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;margin:0 0 12px}
.sm-quick-grid div{background:#f8fafc;border:1px solid var(--border);border-radius:8px;padding:8px 10px}
.sm-quick-grid dt{font-size:11px;color:#64748b;letter-spacing:.04em;text-transform:uppercase;margin-bottom:2px}
.sm-quick-grid dd{margin:0;font-weight:700;color:#0f172a;font-size:14px}
.sm-quick-section{margin:12px 0 6px}
.sm-quick-section h4{margin:0 0 8px;font-size:13px;color:#1e3a8a;letter-spacing:.04em;text-transform:uppercase}
.sm-chips{display:flex;flex-wrap:wrap;gap:6px}
.sm-chip{display:inline-block;border-radius:999px;padding:4px 10px;font-size:12.5px;font-weight:600}
.sm-quick-capitals .sm-chip{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
.sm-quick-countries .sm-chip{background:#eff6ff;color:#1d4ed8;border:1px solid #bfdbfe}
.sm-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:6px}
.sm-full{margin-bottom:24px}
@media(max-width:980px){.sm-shell{grid-template-columns:1fr}.sm-side{position:static;max-height:280px}}
.hm-tooltip{position:absolute;pointer-events:none;background:#111827;color:#fff;border-radius:8px;padding:6px 9px;font-size:13px;box-shadow:var(--shadow);z-index:5;transform:translate(10px,10px);display:none}
.hm-legend{display:flex;flex-wrap:wrap;gap:10px;margin-top:10px;color:#475569;font-size:13px}
.hm-legend span{display:inline-flex;align-items:center;gap:6px}
.hm-dot{width:12px;height:12px;border-radius:999px;background:#1d4ed8;display:inline-block}
.hm-dot.gold{background:#f59e0b}
.hm-dot.green{background:#16a34a}
.hm-panel{position:sticky;top:84px;max-height:calc(100vh - 100px);overflow:auto}
.hm-panel h2{margin:0 0 6px;font-size:22px;color:#1e3a8a}
.hm-lead{margin:0 0 4px;color:#334155;line-height:1.55}
.hm-details{margin-top:18px}
.hm-details-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px}
.hm-d-card{background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:14px;border-top:0;margin-top:0!important}
.hm-d-card h3{margin:0 0 10px;font-size:15px;color:#1e3a8a;letter-spacing:.2px;border-bottom:1px solid var(--border);padding-bottom:7px}
.hm-d-wide{grid-column:1 / -1}
@media(min-width:900px){.hm-d-wide{grid-column:span 2}}
@media(min-width:1200px){.hm-d-wide{grid-column:span 3}}
.hm-type{display:inline-block;border:1px solid #bfdbfe;background:#eff6ff;color:#1d4ed8;border-radius:999px;padding:4px 10px;font-size:12px;font-weight:800;margin-bottom:10px}
.hm-section{border-top:1px solid var(--border);padding-top:12px;margin-top:12px}
.hm-section h3{margin:0 0 8px;font-size:16px;color:#334155}
.hm-list{display:flex;flex-wrap:wrap;gap:7px;margin:0;padding:0;list-style:none}
.hm-list li,.hm-fact{background:#f8fafc;border:1px solid var(--border);border-radius:999px;padding:6px 10px;font-size:13px}
.hm-facts{display:flex;flex-wrap:wrap;gap:8px}
.hm-fact{background:#fff7ed;border-color:#fed7aa;color:#7c2d12;font-weight:700}
.hm-timeline{display:grid;gap:8px}
.hm-time{border-left:4px solid #d97706;background:#fffbeb;border-radius:8px;padding:9px 10px}
.hm-time strong{display:block;color:#92400e}
.hm-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.hm-actions .btn{padding:9px 12px}
.hm-mcq{border:1px solid var(--border);border-radius:10px;padding:12px;background:#f8fafc;margin-top:8px}
.hm-mcq button{display:block;width:100%;text-align:left;margin:7px 0;border:1px solid var(--border);background:#fff;border-radius:8px;padding:9px 10px;cursor:pointer}
.hm-mcq button.correct{border-color:#16a34a;background:#dcfce7}
.hm-mcq button.wrong{border-color:#dc2626;background:#fee2e2}
.hm-empty{background:#f8fafc;border:1px dashed #cbd5e1;border-radius:10px;padding:18px;color:#475569}
.pills{display:flex;flex-wrap:wrap;gap:8px}
.pills a{display:inline-block;background:#f8fafc;border:1px solid var(--border);border-radius:999px;padding:6px 13px;color:var(--ink);font-size:13px}
.site-footer{background:#0f172a;color:#cbd5e1;margin-top:60px;padding:40px 20px 20px}
.footer-grid{max-width:1200px;margin:0 auto;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:30px}
.footer-col h4{color:#fff;margin:0 0 12px}
.footer-col ul{list-style:none;padding:0;margin:0}
.footer-col li{margin:6px 0}
.footer-col a{color:#cbd5e1;font-size:14px}
.footer-bottom{max-width:1200px;margin:30px auto 0;padding-top:20px;border-top:1px solid #1e293b;text-align:center;color:#94a3b8}
.footer-grid .footer-col:nth-child(2) ul{display:grid;grid-template-columns:1fr 1fr;column-gap:14px}
details{background:#fff;border:1px solid var(--border);border-radius:8px;padding:14px 16px;margin:8px 0}
summary{font-weight:700;cursor:pointer}
.hidden{display:none!important}
.small{font-size:13px;color:var(--muted)}
@media(max-width:820px){.nav-toggle{display:block}
.nav-menu{display:none;flex-direction:column;width:100%;background:#fff;border-top:1px solid var(--border);padding:10px 0;margin-top:14px}
.nav-menu.open{display:flex}
.dropdown{position:static;display:none;box-shadow:none;border:none;padding-left:16px}
.nav-menu>li.open .dropdown{display:block}
header .nav-menu>li:first-child .dropdown{min-width:0;grid-template-columns:1fr}
.footer-grid .footer-col:nth-child(2) ul{grid-template-columns:1fr}
.hm-shell{grid-template-columns:1fr}
.hm-shell:has(>.hm-side-list:not([hidden])){grid-template-columns:1fr}
.hm-side-list{position:static;max-height:280px}
.hm-panel{position:static}
.hm-controls{grid-template-columns:1fr}
.hm-map-stage{min-height:280px}
}
@media(max-width:700px){.history-map{min-width:760px}
.map-title-row{display:block}
.map-title-row span{text-align:left;display:block;margin-top:4px}
}
@media(max-width:640px){.hist-hero h1{font-size:1.75rem}
h1{font-size:24px}
.tool-grid{grid-template-columns:1fr}
.tool-card{padding:16px}
.result-row .val{text-align:left}
}
@media print{.site-header,.site-footer,.btn-row,.hist-search,.pills{display:none!important}
body{background:#fff}
.tool-card,.result-card,.timeline-card{box-shadow:none}
}
