/*
 * MicsRO theme - components.
 *
 * The vocabulary every page is built from, generalised from the approved
 * mockups (Main.dc.html, A_Board.dc.html):
 *
 *   .win / .bar / .x       a client window: title bar with a close box
 *   .btn / .btn-primary    client buttons
 *   .tab / .tabs           tab strip (also the header nav)
 *   .meter                 HP / SP / EXP bar
 *   .row                   dotted key/value row
 *   .chat                  dark chat box with coloured lines
 *   .warp                  warp list (a list of links with a value)
 *   .tbl                   the one table style, with .tbl-wrap for overflow
 *   .field / .input        form controls
 *   .badge                 inline label, with state variants
 *   .rank                  1st / 2nd / 3rd medals
 *   .avatar                job avatar (Template::jobAvatarHtml)
 *   .stat                  big number + small label
 *   .empty / .alert        empty and error states
 *
 * Old class names are aliased to these in compat.css.
 */

/* ---- window ------------------------------------------------------------ */

.win {
	background: var(--win);
	border: 1px solid var(--line);
	border-radius: var(--radius-win);
	box-shadow: var(--shadow-win);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.bar {
	min-height: 26px;
	padding: 0 8px 0 10px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: linear-gradient(180deg, var(--t1), var(--t2));
	border-bottom: 1px solid var(--line);
	font-family: var(--font-px);
	font-size: 14px;
	line-height: 1;
	color: var(--ink);
	flex-shrink: 0;
}
.bar-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.x {
	width: 14px;
	height: 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius-xs);
	background: var(--win);
	font-size: 10px;
	line-height: 12px;
	text-align: center;
	color: var(--muted);
	flex-shrink: 0;
	text-decoration: none;
}
.win-body {
	padding: 16px 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	min-width: 0;
}
.win-body-flush { padding: 0; gap: 0; }
.win-body-tight { padding: 10px 20px 14px; gap: 0; }
/* a folding window (<details class="win win-fold">): the title bar is the
   <summary>, its close box reads + / - for closed / open. Stock's list pages
   keep their search form hidden until asked for; this is that, in the
   window's own chrome, with no script needed. */
.win-fold > summary { list-style: none; cursor: pointer; user-select: none; }
.win-fold > summary::-webkit-details-marker { display: none; }
.win-fold > summary .x::before { content: "+"; }
.win-fold[open] > summary .x::before { content: "\2212"; }
.win-fold > summary:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }
.win-fold > summary:hover .x { color: var(--ink); }
/* a stock view can hold an eight-column table: scroll it inside its window
   rather than clip it or widen the page */
.win-body-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- buttons ----------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 18px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: linear-gradient(180deg, var(--btn1), var(--btn2));
	color: var(--ink);
	font: 500 15px/1 var(--font-body);
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
}
.btn:hover {
	text-decoration: none;
	background: linear-gradient(180deg, var(--btn2), var(--btn2));
}
.btn:active {
	background: var(--btn2);
	transform: translateY(1px);
}
.btn-primary {
	background: var(--accent);
	color: var(--accent-ink);
	border-color: var(--accent);
}
.btn-primary:hover {
	background: var(--accent);
	color: var(--accent-ink);
	filter: brightness(1.08);
}
.btn-sm {
	min-height: 34px;
	padding: 0 12px;
	font-size: 14px;
}
.btn-danger {
	color: var(--danger);
	border-color: var(--danger);
}
.btn:disabled, .btn[aria-disabled="true"] {
	opacity: 0.55;
	cursor: default;
}
.btn-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

/* ---- tabs and nav ------------------------------------------------------ */

.tabs {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
}
.tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	font: 400 14px/1.4 var(--font-body);
	cursor: pointer;
	border: 1px solid var(--line);
	border-bottom: 0;
	border-radius: var(--radius) var(--radius) 0 0;
	background: linear-gradient(180deg, var(--btn1), var(--btn2));
	color: var(--muted);
	text-decoration: none;
	white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.on, .tab[aria-current] {
	background: var(--win);
	color: var(--ink);
	font-weight: 700;
	position: relative;
	top: 1px;
}
.tab-panel {
	border: 1px solid var(--line);
	border-radius: 0 var(--radius) var(--radius) var(--radius);
	padding: 4px 8px 8px;
	background: var(--win);
}

.nav-tab {
	display: inline-flex;
	align-items: center;
	min-height: 34px;
	padding: 0 12px;
	font-size: 14px;
	color: var(--ink);
	text-decoration: none;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	white-space: nowrap;
}
.nav-tab:hover {
	text-decoration: none;
	border-color: var(--line-soft);
}
.nav-tab.on, .nav-tab[aria-current] {
	border-color: var(--line);
	background: linear-gradient(180deg, var(--btn1), var(--btn2));
}

/* sub menu (module actions) and page menu (actions for this page) */
.submenu, .pagemenu {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 6px;
	font-size: 14px;
}
.submenu a, .pagemenu a {
	display: inline-flex;
	align-items: center;
	min-height: 30px;
	padding: 0 10px;
	border: 1px solid var(--line-soft);
	border-radius: var(--radius-sm);
	color: var(--ink);
	text-decoration: none;
	background: var(--win);
}
.submenu a:hover, .pagemenu a:hover { border-color: var(--line); }
.submenu a.on { background: linear-gradient(180deg, var(--btn1), var(--btn2)); border-color: var(--line); font-weight: 700; }
.pagemenu-label { color: var(--muted); margin-right: 4px; }

/* ---- meters ------------------------------------------------------------ */

.meter {
	height: 8px;
	border-radius: 4px;
	background: var(--track);
	border: 1px solid var(--line);
	overflow: hidden;
}
.meter-lg { height: 10px; }
.meter > span {
	display: block;
	height: 100%;
	background: var(--hp);
}
.meter-hp > span { background: var(--hp); }
.meter-sp > span { background: var(--sp); }
.meter-exp > span { background: var(--exp); }
.meter-off > span { background: var(--danger); }
.meter-label {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	font-size: 13px;
}
.meter-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.is-up { color: var(--hp-ink); font-weight: 700; }
.is-down { color: var(--danger); font-weight: 700; }

/* ---- rows -------------------------------------------------------------- */

.row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	font-size: 14px;
	padding: 7px 0;
	border-bottom: 1px dotted var(--line);
}
.row:last-child { border-bottom: 0; }
.row .num { font-size: 15px; }
.row .num-lg { font-size: 18px; }
.row-hint { font-size: 12px; color: var(--muted); }

/* ---- chat -------------------------------------------------------------- */

.chat {
	background: var(--chat);
	color: var(--chat-ink);
	font-size: 13px;
	line-height: 1.7;
	padding: 12px 14px;
	flex-grow: 1;
	overflow-wrap: anywhere;
}
.chat-sys { color: #f5d64e; }
.chat-good { color: #8ee39b; }
.chat-say { color: #cfd6e6; }
.chat-warn { color: #ff9a8a; }

/* ---- warp list --------------------------------------------------------- */

.warp {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	font-size: 14px;
	color: var(--ink);
	text-decoration: none;
	border-bottom: 1px dotted var(--line);
}
.warp:last-child { border-bottom: 0; }
.warp:hover { background: var(--sel); text-decoration: none; }
.warp.on, .warp[aria-current] { background: var(--sel); font-weight: 700; }
/* the list sits flush in a window that clips overflow: keep the ring inside */
.warp:focus-visible { outline-offset: -2px; }
.warp .num { font-size: 14px; }

/* ---- table ------------------------------------------------------------- */

.tbl-wrap {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}
.tbl {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}
.tbl th {
	text-align: left;
	font-weight: 500;
	color: var(--muted);
	font-size: 12px;
	padding: 8px 12px;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}
.tbl th a { color: var(--muted); }
.tbl td {
	padding: 11px 12px;
	border-bottom: 1px dotted var(--line);
	vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--sel); }
.tbl .num-lg { font-size: 17px; }
.tbl-kv th {
	width: 32%;
	color: var(--muted);
	font-size: 14px;
	font-weight: 500;
	border-bottom: 1px dotted var(--line);
	padding: 11px 12px;
	vertical-align: top;
}
.tbl-kv tr:last-child th, .tbl-kv tr:last-child td { border-bottom: 0; }
.tbl-kv tbody tr:hover td { background: transparent; }

/* ---- forms ------------------------------------------------------------- */

.form {
	display: flex;
	flex-direction: column;
	gap: 12px;
	max-width: 560px;
}
.form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 12px 16px;
	align-items: start;
}
.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}
.field > label, .label {
	font-size: 13px;
	color: var(--muted);
}
.input, input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="search"], input[type="url"], input[type="tel"],
input[type="date"], select, textarea {
	width: 100%;
	max-width: 100%;
	min-height: 40px;
	padding: 0 10px;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--win);
	color: var(--ink);
	font: 15px var(--font-body);
}
textarea { min-height: 120px; padding: 8px 10px; line-height: 1.5; }
/* a control inside running text (the loginbox's preferred server) */
.input-inline { display: inline-block; width: auto; min-height: 30px; padding: 0 8px; font-size: 14px; vertical-align: middle; }
select { padding-right: 28px; }
input[type="checkbox"], input[type="radio"] {
	width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
	outline: 2px solid var(--pink);
	outline-offset: 1px;
	border-color: var(--pink);
}
input[type="submit"], button:not([class]), input[type="button"], button.btn-plain {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 0 18px;
	border: 1px solid var(--accent);
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--accent-ink);
	font: 500 15px/1 var(--font-body);
	cursor: pointer;
	width: auto;
}
.form-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding-top: 4px;
}
.help { font-size: 13px; color: var(--muted); }

/* ---- badges ------------------------------------------------------------ */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px 8px;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--win);
	color: var(--ink);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
	vertical-align: middle;
}
.badge-accent { color: var(--accent); border-color: var(--accent); background: var(--sp-bg); }
.badge-good, .badge-online { color: var(--hp-ink); border-color: var(--hp); background: var(--hp-bg); }
.badge-warn, .badge-mvp { color: var(--exp-ink); border-color: var(--exp); background: var(--exp-bg); }
.badge-bad, .badge-offline { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.badge-muted { color: var(--muted); border-color: var(--line-soft); }
.badge-num { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---- ranks ------------------------------------------------------------- */

.rank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	font-family: var(--font-body);
	font-weight: 700;
	font-size: 15px;
	line-height: 1;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.rank-1 { color: var(--gold-ink); }
.rank-2 { color: var(--silver-ink); }
.rank-3 { color: var(--bronze-ink); }
.rank-medal {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	font-family: var(--font-body);
	font-weight: 700;
	font-size: 14px;
	border: 1px solid var(--line);
	background: var(--win);
}
.rank-medal.rank-1 { background: var(--gold); color: #24304a; border-color: var(--gold); }
.rank-medal.rank-2 { background: var(--silver); color: #ffffff; border-color: var(--silver); }
.rank-medal.rank-3 { background: var(--bronze); color: #ffffff; border-color: var(--bronze); }
:root[data-theme="dark"] .rank-medal.rank-2,
:root[data-theme="dark"] .rank-medal.rank-3 { color: #101829; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .rank-medal.rank-2,
	:root:not([data-theme="light"]) .rank-medal.rank-3 { color: #101829; }
}

/* ---- job avatar (Template::jobAvatarHtml) ------------------------------- */

.avatar {
	--job-rgb: 52, 88, 159;
	width: 38px;
	height: 38px;
	border-radius: var(--radius-sm);
	background: linear-gradient(145deg, rgba(var(--job-rgb), 0.28), rgba(var(--job-rgb), 0.08));
	border: 1px solid var(--line);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: relative;
	flex-shrink: 0;
	overflow: hidden;
	vertical-align: middle;
}
.avatar-letter {
	font-family: var(--font-px);
	font-weight: 600;
	font-size: 16px;
	color: rgb(var(--job-rgb));
	line-height: 1;
	user-select: none;
}
.avatar-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	position: absolute;
	inset: 0;
	opacity: 0;
	image-rendering: pixelated;
}
/* kept in layout (never display:none) so the browser fetches it; shown once
   it has loaded, and the letter takes over if it never does */
.avatar.has-img .avatar-img { opacity: 1; }
.avatar.has-img .avatar-letter { visibility: hidden; }
.avatar.no-img .avatar-img { visibility: hidden; }
.job-dot {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 2px;
	margin-right: 3px;
	vertical-align: middle;
	background: rgb(var(--job-rgb, 52, 88, 159));
}

/* ---- stats ------------------------------------------------------------- */

.stats {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 28px;
}
.stat { min-width: 0; }
.stat-num { font-family: var(--font-body); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 26px; line-height: 1.1; }
.stat-text { font-size: 12px; color: var(--muted); }
.stat-right { text-align: right; }

.grid-2 {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 24px;
}
.grid-3 {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 24px;
}
@media (max-width: 860px) {
	.grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

/* ---- states ------------------------------------------------------------ */

.empty {
	padding: 32px 20px;
	text-align: center;
	color: var(--muted);
}
.empty strong { color: var(--ink); display: block; margin-bottom: 4px; }

.alert {
	padding: 12px 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--sel);
	color: var(--ink);
	font-size: 14px;
}
.alert-good { border-color: var(--hp); background: var(--hp-bg); color: var(--hp-ink); }
.alert-bad { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.alert-info { border-color: var(--sp); background: var(--sp-bg); }

/* ---- pagination -------------------------------------------------------- */

.pages {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px;
	margin: 16px 0 0;
	font-size: 14px;
}
.pages a, .pages strong, .pages span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	min-height: 32px;
	padding: 0 8px;
	border: 1px solid var(--line-soft);
	border-radius: var(--radius-sm);
	color: var(--ink);
	text-decoration: none;
}
.pages a:hover { border-color: var(--line); }
.pages strong { background: linear-gradient(180deg, var(--btn1), var(--btn2)); border-color: var(--line); }

/* ---- theme toggle ------------------------------------------------------ */

.theme-toggle {
	width: 34px;
	min-width: 34px;
	padding: 0;
	font-size: 16px;
}
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle .ico-sun { display: none; }
	:root:not([data-theme="light"]) .theme-toggle .ico-moon { display: block; }
}

/* ---- page pieces (public pages) ---------------------------------------- */

/* two-column page: a narrow warp column and the main window (A_Board) */
.page-cols {
	display: grid;
	grid-template-columns: 320px minmax(0, 1fr);
	gap: 24px;
	align-items: start;
}
.page-cols > * { min-width: 0; }
@media (max-width: 900px) {
	.page-cols { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
.page-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 24px;
	flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 40px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
@media (max-width: 720px) { .page-head h1 { font-size: 30px; } }
.lead { font-size: 17px; line-height: 1.65; color: var(--muted); max-width: 60ch; }
.hero-title { font-size: 44px; line-height: 1.05; margin: 0; }
@media (max-width: 720px) { .hero-title { font-size: 32px; } }
.win-body-hero { padding: 40px 48px; gap: 20px; }
@media (max-width: 720px) { .win-body-hero { padding: 24px 20px; } }

/* floor strip (board page) */
.floors { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 6px; }
.floor { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12px; }
.floor.boss { border-color: var(--pink); }
.floor .muted { margin-left: 4px; }

/* inline stroke icon */
.ico { width: 18px; height: 18px; vertical-align: -3px; flex-shrink: 0; }
.ico-lg { width: 24px; height: 24px; }

/* toolbar: search, filters, toggles */
.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 16px;
}
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 100%; min-width: 0; }
/* controls may shrink below their intrinsic width (a select sized by its
   longest option would otherwise push past a narrow window) */
.toolbar .input { width: auto; min-width: 0; max-width: 100%; flex: 1 1 160px; }
.toolbar label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.toolbar label .input { flex: 1 1 120px; min-width: 0; }
.filter-btn {
	min-height: 34px; padding: 0 12px; font-size: 13px;
	border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
	background: var(--win); color: var(--muted); cursor: pointer; font-family: var(--font-body);
}
.filter-btn:hover { border-color: var(--line); color: var(--ink); }
.filter-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* respawn timers (Boss Tracker); Alive / Defeated are .badge-good / .badge-bad */
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--hp); box-shadow: 0 0 0 0 rgba(53, 164, 71, 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(53, 164, 71, 0); } 100% { box-shadow: 0 0 0 0 rgba(53, 164, 71, 0); } }
.boss-timer { font-size: 14px; white-space: nowrap; }
.timer-wait { color: var(--muted); }
.timer-wait strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.timer-window { color: var(--exp-ink); font-weight: 700; }
.timer-open { color: var(--hp-ink); font-weight: 700; }
.mapname { font-family: var(--font-code); font-size: 13px; }

/* sprite cell: a fixed box, the sprite scaled to fit (base.css sets img
   height:auto, so the box, not the img attributes, constrains it) */
.sprite { image-rendering: pixelated; vertical-align: middle; }
.icon-tile {
	display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; overflow: hidden;
	background: var(--sel); border: 1px solid var(--line); border-radius: var(--radius-sm);
	flex-shrink: 0;
}
.icon-tile .sprite, .icon-tile img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.icon-tile-sm { width: 32px; height: 32px; }
.icon-tile-lg { width: 72px; height: 72px; }
.icon-tile-xl { width: 96px; height: 96px; }
.tbl .who { flex-wrap: nowrap; }
.tbl .who a, .tbl .who strong { white-space: nowrap; }

/* headgear slots in the character ranking */
.slots { display: flex; gap: 6px; align-items: center; }
.slot {
	width: 30px; height: 30px; position: relative;
	display: inline-flex; align-items: center; justify-content: center;
	border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sel);
}
.slot img { max-width: 24px; max-height: 24px; image-rendering: pixelated; }
.slot-empty { border-style: dashed; background: transparent; color: var(--muted); font-size: 11px; }
.slot-refine {
	position: absolute; bottom: -1px; right: 1px; font-size: 10px; font-weight: 700;
	color: var(--exp-ink); background: var(--win); padding: 0 2px; border-radius: 2px; line-height: 1.2;
}

/* who: avatar + name */
.who { display: flex; align-items: center; gap: 10px; }
.who a, .who strong { font-weight: 700; color: var(--accent); }
.guild { display: inline-flex; align-items: center; gap: 6px; }
.guild img { max-width: 20px; max-height: 20px; }

/* attribute grid (monster page) */
.attrs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.attr { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-align: center; }
.attr .stat-text { display: block; }
.attr .stat-num { font-size: 20px; }

/* download cards */
.pack { display: flex; flex-direction: column; gap: 10px; }
.pack .btn { align-self: flex-start; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: step; }
.step { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.step h4 { margin: 0 0 6px; }
.step p { font-size: 14px; color: var(--muted); }
@media (max-width: 720px) { .steps { grid-template-columns: minmax(0, 1fr); } }

/* ---- wiki (modules/wiki) ----------------------------------------------- */
/* A docs layout: page nav | article | "On this page". header.php drops the
   server sidebar on wiki pages (.site-main-docs) so the three fit. */
.site-main-docs { grid-template-columns: minmax(0, 1fr); max-width: calc(1360px + 2 * var(--gutter)); }
.wiki-docs { display: grid; grid-template-columns: 240px minmax(0, 1fr) 200px; gap: 24px; align-items: start; }
.wiki-docs-home { grid-template-columns: 240px minmax(0, 1fr); }
.wiki-side, .wiki-toc { position: sticky; top: calc(var(--head-h) + 24px); max-height: calc(100vh - var(--head-h) - 40px); overflow-y: auto; }

/* page nav */
.wiki-nav-toggle { display: none; }
.wiki-nav { display: flex; flex-direction: column; gap: 14px; font-size: 14px; padding-bottom: 8px; }
.wiki-search .input { width: 100%; }
.wiki-nav ul { list-style: none; margin: 0; padding: 0; }
.wiki-nav-cat { margin: 0 0 4px; padding-left: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.wiki-nav a { display: block; padding: 5px 10px; border-left: 3px solid transparent; border-radius: 0 var(--radius-xs) var(--radius-xs) 0; color: var(--ink); text-decoration: none; line-height: 1.35; }
.wiki-nav a:hover { background: var(--sel); text-decoration: none; }
.wiki-nav a.on { background: var(--sel); border-left-color: var(--accent); font-weight: 700; }
.wiki-nav-home { font-weight: 700; }
.wiki-nav-empty { margin: 0; padding-left: 10px; color: var(--muted); }

/* article */
.wiki-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.wiki-crumbs a { color: inherit; }
.wiki-body > * { margin-top: 0; margin-bottom: 0; }
.wiki-body > p, .wiki-body > ul, .wiki-body > ol, .wiki-body > blockquote { max-width: 78ch; }
.wiki-title { font-size: 30px; }
.wiki-body h3 { margin-top: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.wiki-body h3, .wiki-body h4 { scroll-margin-top: calc(var(--head-h) + 24px); }
.wiki-anchor { margin-left: 8px; font-size: 0.8em; color: var(--muted); text-decoration: none; opacity: 0; }
.wiki-body h3:hover .wiki-anchor, .wiki-body h4:hover .wiki-anchor, .wiki-anchor:focus-visible { opacity: 1; }
.wiki-body ul, .wiki-body ol { padding-left: 1.4em; display: flex; flex-direction: column; gap: 4px; }
.wiki-body table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.wiki-body th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.wiki-body td { padding: 9px 12px; border-bottom: 1px dotted var(--line); vertical-align: top; }
.wiki-body tr:last-child td { border-bottom: 0; }
.wiki-body blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--line); background: var(--sel); border-radius: var(--radius-xs); }

/* previous / next */
.wiki-pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.wiki-pager a { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.wiki-pager a:hover { background: var(--sel); border-color: var(--line); text-decoration: none; }
.wiki-pager-next { grid-column: 2; text-align: right; }
.wiki-pager-dir { font-size: 12px; color: var(--muted); }
.wiki-pager-title { font-weight: 700; color: var(--accent); }

/* "On this page" */
.wiki-toc { font-size: 13px; }
.wiki-toc-head { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.wiki-toc ul, .wiki-toc-inline ul { list-style: none; margin: 0; padding: 0; }
.wiki-toc a { display: block; padding: 3px 0 3px 10px; border-left: 2px solid var(--line-soft); color: var(--muted); text-decoration: none; line-height: 1.35; }
.wiki-toc a:hover { color: var(--ink); text-decoration: none; }
.wiki-toc a.on { border-left-color: var(--accent); color: var(--accent); font-weight: 700; }
.wiki-toc .wiki-toc-l4 a, .wiki-toc-inline .wiki-toc-l4 { padding-left: 22px; }
.wiki-toc-inline { display: none; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius); font-size: 14px; }
.wiki-toc-inline summary { cursor: pointer; font-weight: 700; }
.wiki-toc-inline ul { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; padding-left: 0; }

/* index cards */
.wiki-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.wiki-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.wiki-card:hover { background: var(--sel); border-color: var(--line); text-decoration: none; }
.wiki-card-title { font-weight: 700; color: var(--accent); }
.wiki-card-summary { font-size: 13px; color: var(--muted); line-height: 1.45; }

@media (max-width: 1200px) {
	.wiki-docs { grid-template-columns: 220px minmax(0, 1fr); }
	.wiki-toc { display: none; }
	.wiki-toc-inline { display: block; }
}
@media (max-width: 900px) {
	.wiki-docs, .wiki-docs-home { grid-template-columns: minmax(0, 1fr); gap: 16px; }
	.wiki-side { position: static; max-height: none; overflow: visible; }
	.wiki-nav-fold { background: var(--win); border: 1px solid var(--line); border-radius: var(--radius-win); }
	.wiki-nav-toggle { display: flex; justify-content: space-between; padding: 10px 14px; cursor: pointer; font-weight: 700; list-style: none; }
	.wiki-nav-toggle::-webkit-details-marker { display: none; }
	.wiki-nav-toggle::after { content: "+"; color: var(--muted); }
	.wiki-nav-fold[open] > .wiki-nav-toggle::after { content: "\2212"; }
	.wiki-nav { padding: 0 14px 14px; }
	.wiki-title { font-size: 24px; }
	.wiki-pager { grid-template-columns: minmax(0, 1fr); }
	.wiki-pager-next { grid-column: 1; }
}

/* ---- account and character pages ------------------------------------- */

/* a narrow centred window for the sign-in / create / reset forms */
.win-auth { width: 100%; max-width: 520px; margin: 0 auto; }
.auth-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 8px 0 4px; }
.auth-head h1 { margin: 0; font-size: 30px; }
.auth-head p { margin: 0; color: var(--muted); max-width: 40ch; }
.mark { display: block; width: 45px; height: 50px; shape-rendering: crispEdges; }
.form-full { max-width: none; }
.btn-block { width: 100%; }
.field-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.field-row > .input { width: auto; flex: 1 1 120px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { flex-shrink: 0; }
.notes { margin: 0; padding: 0 0 0 18px; color: var(--muted); font-size: 13px; }
.notes li { margin: 2px 0; }
.security-code { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.security-code img { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.security-code .input { flex: 1 1 140px; }
.actions-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.tbl-kv td .btn-sm { margin-left: 8px; vertical-align: middle; }
.tbl-kv td form { display: flex; flex-direction: column; gap: 8px; max-width: 480px; }
.readonly { padding: 0 2px; color: var(--muted); }
.slots-lg .slot { width: 36px; height: 36px; }
.empty-inline { color: var(--muted); }

/* a table that stacks into cards on a phone: no columns hidden, every cell
   keeps its place. Cells carry data-col; the stack-label prefix shows only
   when stacked. */
.stack-label { display: none; }
@media (max-width: 720px) {
	.tbl-stack thead { display: none; }
	.tbl-stack, .tbl-stack tbody { display: block; }
	.tbl-stack tr {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		gap: 4px 12px;
		align-items: center;
		padding: 10px 4px;
		border-bottom: 1px dotted var(--line);
	}
	.tbl-stack tbody tr:last-child { border-bottom: 0; }
	.tbl-stack td { display: block; padding: 0; border: 0; min-width: 0; }
	.tbl-stack tbody tr:hover td { background: transparent; }
	.tbl-stack td[data-col="main"] { grid-column: 1 / -1; }
	.tbl-stack td[data-col="end"] { text-align: right; white-space: nowrap; }
	.tbl-stack td:empty { display: none; }
	.stack-label { display: inline; color: var(--muted); font-size: 12px; }
	/* a log row (many short cells): every cell on its own line, label first */
	.tbl-stack.tbl-list td { grid-column: 1 / -1; text-align: left; }
	.tbl-stack.tbl-list td .stack-label { display: inline-block; min-width: 9em; }
	/* people tables (party, friends, who's online): name / job + base / guild + job level / status or map */
	.tbl-people td:nth-child(1) { grid-column: 1 / -1; grid-row: 1; }
	.tbl-people td:nth-child(2) { grid-column: 1; grid-row: 2; }
	.tbl-people td:nth-child(3) { grid-column: 2; grid-row: 2; justify-self: end; }
	.tbl-people td:nth-child(4) { grid-column: 2; grid-row: 3; justify-self: end; }
	.tbl-people td:nth-child(5) { grid-column: 1; grid-row: 3; }
	.tbl-people td:nth-child(6) { grid-column: 1 / -1; grid-row: 4; text-align: left; }
}

/* ---- shop, cart, donations --------------------------------------------- */

.shop-list { display: flex; flex-direction: column; }
.shop-row { display: flex; gap: 16px; align-items: flex-start; padding: 14px 0; border-bottom: 1px dotted var(--line); }
.shop-row:last-child { border-bottom: 0; }
.shop-row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.shop-row-body h3 { margin: 0; font-family: var(--font-body); font-size: 16px; font-weight: 700; }
.shop-row-info { font-size: 14px; color: var(--muted); }
.shop-row-info p { margin: 0; }
.shop-row-side { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }
.shop-row-links { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.cost { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px; }
.cost .muted { font-weight: 400; font-size: 13px; }
@media (max-width: 720px) {
	.shop-row { flex-wrap: wrap; }
	.shop-row-side { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
}
/* the credit balance box the shell shows on donate / purchase pages */
.credit-balance { justify-content: space-between; }
.credit-balance .balance-amount { font-size: 18px; }

/* WoE hours: one dotted row per window */
.woe-window { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.woe-window .muted { font-size: 13px; }

/* small helpers */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex-grow: 1; min-width: 0; }
.ml { margin-left: auto; }
.mt { margin-top: 12px; }
.z { color: var(--exp-ink); font-weight: 700; }

/* ---- Staff pages (Step 3.4): form controls stock emits, and log launchers ---- */
/* Template::dateField()/dateTimeField() emit bare selects joined by "-" / ":"; keep them on one row. */
.date-field { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.date-field select { width: auto; min-width: 0; min-height: 36px; padding: 0 22px 0 6px; font-size: 14px; }
/* A date, time or amount cell never breaks mid-value; the wrap scrolls instead. */
.tbl td.num { white-space: nowrap; }
/* A multi-select is a list, not a 40px control. */
select[multiple] { height: auto; min-height: 0; padding: 6px 8px; }
select[multiple] option { padding: 3px 4px; }
.select-tools { display: flex; gap: 12px; margin-top: 6px; font-size: 13px; }
.select-tools button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.select-tools button:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
textarea.code { font-family: var(--font-code); font-size: 13px; min-height: 160px; white-space: pre; }
.raw-log { margin: 0; padding: 12px; max-height: 480px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); font: 12px/1.5 var(--font-code); color: var(--ink); white-space: pre-wrap; word-break: break-word; }
/* Log launchers (logdata/index, cplog/index): one link per log. */
.launch { display: flex; flex-direction: column; }
.launch a { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.launch a:last-child { border-bottom: 0; }
.launch a:hover strong, .launch a:focus-visible strong { color: var(--accent); text-decoration: underline; }
.launch a:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }
.launch strong { font-weight: 700; }
.launch span { color: var(--muted); font-size: 13px; text-align: right; }
@media (max-width: 600px) { .launch a { flex-direction: column; align-items: flex-start; gap: 2px; } .launch span { text-align: left; } }

/* ---- crawl fixes ------------------------------------------------------- */
/* 5. The paginator's "|" between page links is markup now; this theme draws
   the links as buttons and needs no separator. */
.pages .page-sep { display: none; }
/* 7. Setup steps: the number sits inside the card, not as a list marker. */
.steps { list-style: none; margin: 0; padding: 0; }
.step { position: relative; padding-left: 48px; }
.step::before {
	counter-increment: step; content: counter(step);
	position: absolute; left: 12px; top: 12px;
	width: 26px; height: 26px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: var(--accent); color: #fff;
	font: 700 13px/1 var(--font-body);
}
/* 8. Dungeon floor chips: five fit one row on a phone. */
.floors { grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)); }
.floor { padding: 8px 6px; text-align: center; }
@media (max-width: 480px) { .floor .muted { display: block; margin: 0; font-size: 11px; } }
/* 4. Ranking tables on a phone: rank + name on the first row, then every
   other column on its own labelled line. */
@media (max-width: 720px) {
	.tbl-rank tr { grid-template-columns: auto minmax(0, 1fr); }
	.tbl-rank td:nth-child(1) { grid-column: 1; grid-row: 1; }
	.tbl-rank td:nth-child(2) { grid-column: 2; grid-row: 1; }
	.tbl-rank td:nth-child(n+3) { grid-column: 1 / -1; text-align: left; }
	.tbl-rank .stack-label { display: inline-block; min-width: 6.5em; }
	.tbl-rank td .slots { vertical-align: middle; }
}

/* ---- signed-in crawl fixes --------------------------------------------- */
/* 3. dateTimeField() = dateField() + " @ " + hour:minute:second selects: one row. */
.date-time-field { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.date-time-field select { width: auto; min-width: 0; min-height: 36px; padding: 0 20px 0 6px; font-size: 14px; }
/* A date-time needs the whole form row; a half-width grid column wraps the time part. */
.form-grid .field:has(.date-time-field) { grid-column: 1 / -1; }
/* 2. Key/value tables: long values (an email, a badge and a date) wrap. */
.tbl-kv td, .tbl-kv td.num { white-space: normal; overflow-wrap: anywhere; }
.tbl-kv td .badge { white-space: normal; }
/* 6. The sidebar menu windows fold only on a phone; on a desktop they are plain windows. */
@media (min-width: 721px) {
	.side-fold > summary { pointer-events: none; }
	.side-fold > summary .x::before, .side-fold[open] > summary .x::before { content: "x"; }
}
@media (max-width: 720px) {
	.tbl-kv th { width: 38%; }
	/* 7. One label/value grid for every stacked card: label a fixed column,
	   regular weight and muted, value aligned beside it whatever it holds. */
	.tbl-stack .stack-label { font-weight: 400; color: var(--muted); }
	.tbl-stack.tbl-list td, .tbl-rank td:nth-child(n+3) { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; text-align: left; }
	.tbl-stack.tbl-list td .stack-label, .tbl-rank td .stack-label { flex: 0 0 7.5em; min-width: 0; }
	.tbl-stack.tbl-list td.right, .tbl-rank td.right { justify-content: flex-start; }
	.tbl-stack td .guild, .tbl-stack td .who { vertical-align: middle; }
	/* 4. Inventory cards: name row, a three-column labelled grid (amount /
	   identified / broken), then the cards. */
	.tbl-items tr { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; }
	.tbl-items td[data-col="main"] { grid-column: 1 / -1; }
	.tbl-items td { text-align: left; }
	.tbl-items td .stack-label { display: block; font-size: 11px; line-height: 1.2; margin-bottom: 2px; }
	.tbl-items td.cards-cell { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
	.tbl-items td.cards-cell .stack-label { display: inline; margin: 0; flex: 0 0 auto; }
}
