/*
 * Ultralight web tier - hand-written, no framework, no generated CSS.
 * Budget is 20KB gzipped (05 §S4); this sits far under it.
 *
 * Layout is flexbox + normal document flow ONLY. CSS Grid appears exactly once,
 * inside @supports, as a Tier-A enhancement - using it as the primary layout
 * collapses on the KaiOS 2.5 reference device.
 *
 * No web fonts and no icon fonts: zero bytes downloaded for typography, glyphs are
 * Unicode. No animations - Tier C strips them and they cost paint time on Tier B.
 */

:root {
	--accent: #4f46e5;
	--bg: #ffffff;
	--bg-alt: #fafafa;
	--ink: #111111;
	--muted: #666666;
	--line: #e5e5e5;
	--btn-ink: #ffffff;
	--ok: #10b981;
	--warn: #f59e0b;
	--err: #ef4444;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 16px;
	line-height: 1.45;
}

a {
	color: var(--accent);
	text-decoration: none;
}

/*
 * Focus styling is not cosmetic here. KaiOS and other feature phones navigate with a
 * D-pad, so the focus ring IS the cursor - without it the page is unusable by keypad.
 */
a:focus,
button:focus,
input:focus,
[tabindex]:focus {
	outline: 3px solid var(--accent);
	outline-offset: 1px;
}

/* header */
.bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	background: var(--bg);
}

.brand {
	font-weight: 700;
	font-size: 18px;
	color: var(--ink);
}

.bar-links a {
	font-size: 20px;
	margin-left: 14px;
}

main {
	padding: 12px;
}

h1 {
	font-size: 20px;
	margin: 0 0 12px;
}

h2 {
	font-size: 15px;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--muted);
	margin: 18px 0 8px;
}

/* lists */
ul.list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.row {
	border-bottom: 1px solid var(--line);
}

.row a {
	display: flex;
	flex-direction: column;
	padding: 11px 4px;
	color: var(--ink);
}

.row-title {
	font-weight: 600;
}

.row-meta {
	color: var(--muted);
	font-size: 13px;
}

/* ads */
.ad {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 14px 0;
	padding: 10px;
	background: var(--bg-alt);
	border: 1px solid var(--line);
}

.ad img {
	max-width: 100%;
	height: auto;
	display: block;
}

.ad-remove {
	font-size: 12px;
	margin-top: 6px;
	color: var(--muted);
	text-decoration: underline;
}

/* player */
.player {
	margin: 14px 0;
}

.player audio {
	width: 100%;
}

.track-title {
	font-size: 20px;
	font-weight: 700;
	margin: 0;
}

.track-artist {
	color: var(--muted);
	margin: 2px 0 0;
}

/* buttons and forms */
.btn {
	display: inline-block;
	padding: 12px 18px;
	border: 1px solid var(--accent);
	color: var(--accent);
	background: var(--bg);
	font-size: 16px;
	font-family: inherit;
	cursor: pointer;
	text-align: center;
}

.btn.solid {
	background: var(--accent);
	color: var(--btn-ink);
}

.btn.block {
	display: block;
	width: 100%;
	margin-top: 10px;
}

input[type="text"],
input[type="search"],
input[type="tel"] {
	width: 100%;
	padding: 11px;
	border: 1px solid var(--line);
	font-size: 16px;
	font-family: inherit;
	background: var(--bg);
	color: var(--ink);
}

fieldset {
	border: 1px solid var(--line);
	margin: 0 0 14px;
	padding: 10px 12px;
}

legend {
	color: var(--muted);
	font-size: 13px;
	padding: 0 4px;
}

label.opt {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 2px;
	border-bottom: 1px solid var(--line);
}

label.opt:last-child {
	border-bottom: 0;
}

/* pagination */
.pager {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 14px;
	padding-top: 10px;
	border-top: 1px solid var(--line);
}

.pager .muted {
	color: var(--muted);
	font-size: 14px;
}

/* key/value rows on account */
.kv {
	display: flex;
	justify-content: space-between;
	padding: 11px 2px;
	border-bottom: 1px solid var(--line);
}

.kv span:first-child {
	color: var(--muted);
}

/* status */
.note {
	padding: 12px;
	background: var(--bg-alt);
	border-left: 3px solid var(--accent);
	margin: 0 0 14px;
}

.note.good {
	border-left-color: var(--ok);
}

.note.bad {
	border-left-color: var(--err);
}

.big-ok {
	font-size: 40px;
	color: var(--ok);
	text-align: center;
	margin: 10px 0;
}

.muted {
	color: var(--muted);
}

.center {
	text-align: center;
}

/*
 * Bottom tabs sit in NORMAL DOCUMENT FLOW, not position:fixed.
 *
 * Fixed positioning is a trap on this floor: Opera Mini (Tier C) renders a server-side
 * snapshot where a fixed bar can strand itself mid-page, and Gecko 48 on KaiOS handles
 * it inconsistently. Flow layout costs nothing and renders identically everywhere,
 * which is the whole reason the spec names flexbox + normal flow as the primitive.
 */
.tabs {
	display: flex;
	background: var(--bg);
	border-top: 1px solid var(--line);
	margin-top: 8px;
}

.tabs a {
	flex: 1 1 0;
	text-align: center;
	padding: 12px 2px;
	font-size: 13px;
	color: var(--muted);
	border-right: 1px solid var(--line);
}

.tabs a:last-child {
	border-right: 0;
}

/*
 * Tier-A only enhancement. Everything above already lays out correctly without it;
 * this just gives roomier screens two columns. Never make this the primary layout.
 */
@supports (display: grid) {
	@media (min-width: 480px) {
		.shelf-grid {
			display: grid;
			grid-template-columns: 1fr 1fr;
			column-gap: 16px;
		}
	}
}
