/* Napkin — pale chrome around a canvas that does the real work.

   The sheet is paper, so the chrome is a slightly darker warm grey that sits
   behind it rather than beside it. The structure on the canvas is drawn in
   neutrals; blue, red and green are spent only on loads, suggestions and
   diagrams, and the chrome follows the same rule.

   --paper must stay in step with PAPER in render.js: the selected tab takes
   it as its own background so the canvas reads as that tab's panel. */

:root {
	color-scheme: light;
	--paper: #fafaf7;
	--ink: #2f3a45;
	--rule: #d8d5c9;
	--muted: #86847a;
	--accent: #00905a;
	--select: #1f7ae0;
	--danger: #d0271a;
	--panel: #eeece4;
	--field: #ffffff;
	--hover: #e2e0d6;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
	height: 100%;
	margin: 0;
}

body {
	display: flex;
	flex-direction: column;
	background: var(--paper);
	color: var(--ink);
	font: 400 14px/1.5 ui-sans-serif, system-ui, -apple-system, sans-serif;
	overflow: hidden;
}

/* ------------------------------------------------------------------- chrome --- */

.bar {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	/* The selected tab hangs 11px below the content box to cover the rule, so
	   nothing here may clip. */
	overflow: visible;
	background: var(--panel);
	border-bottom: 1px solid var(--rule);
}

.bar h1 {
	margin: 0;
	flex: 0 0 auto;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.group {
	display: flex;
	gap: 4px;
	flex: 0 0 auto;
}

.push { margin-left: auto; }

button {
	font: inherit;
	font-size: 13px;
	color: var(--ink);
	background: transparent;
	border: 1px solid var(--rule);
	border-radius: 4px;
	padding: 5px 9px;
	white-space: nowrap;
	cursor: pointer;
}

button u {
	text-decoration: none;
	color: var(--muted);
	margin-right: 3px;
}

button:hover { background: var(--hover); }

button.active {
	background: var(--ink);
	border-color: var(--ink);
	color: var(--paper);
}

button.active u { color: rgba(250, 250, 247, 0.6); }

/* ---------------------------------------------------------- diagram tabs --- */

/* The five views are tabs, not a button group: the selected one loses its
   bottom border and takes the sheet's own background, so the canvas below
   reads as that tab's panel rather than as a separate thing. */

.tabs-bar {
	display: flex;
	gap: 2px;
	flex: 0 0 auto;
	align-self: stretch;
	align-items: flex-end;
	/* Down over the bar's own padding and its bottom rule. */
	margin-bottom: -11px;
}

.tabs-bar button {
	border-color: transparent;
	border-radius: 5px 5px 0 0;
	padding: 6px 11px 8px;
	color: var(--muted);
}

/* The shortcut trails the label in its own small box, rather than underlining
   a letter in the middle of the word: it has to be findable, not shouted. */
.tabs-bar u {
	display: inline-block;
	margin: 0 0 0 7px;
	padding: 0 3px;
	border: 1px solid var(--rule);
	border-radius: 3px;
	font-size: 9.5px;
	line-height: 1.5;
	vertical-align: 1px;
	color: var(--muted);
	text-decoration: none;
}

.tabs-bar button:hover {
	background: var(--hover);
	color: var(--ink);
}

.tabs-bar button[aria-selected="true"] {
	color: var(--ink);
	background: var(--paper);
	border-color: var(--rule);
	border-bottom-color: var(--paper);
}

.tabs-bar button[aria-selected="true"] u {
	color: var(--muted);
	border-color: var(--muted);
}

.label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 13px;
	color: var(--muted);
}

/* --------------------------------------------------------------------- body --- */

main {
	flex: 1;
	display: flex;
	min-height: 0;
}

#sheet {
	flex: 1;
	display: block;
	/* No width: 100% — that would set the flex base to the full row and push
	   the panel off the edge. min-width: 0 lets the canvas shrink instead. */
	min-width: 0;
	height: 100%;
	cursor: crosshair;
	touch-action: none;
}

.panel {
	width: 264px;
	flex: 0 0 264px;
	padding: 16px;
	overflow-y: auto;
	background: var(--panel);
	border-left: 1px solid var(--rule);
}

.panel h2 {
	margin: 18px 0 6px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
}

.panel h2:first-child,
#properties:empty + #results h2:first-child { margin-top: 0; }

#properties:not(:empty) {
	padding-bottom: 14px;
	margin-bottom: 4px;
	border-bottom: 2px solid var(--rule);
}

.panel table {
	width: 100%;
	border-collapse: collapse;
}

.panel th,
.panel td {
	padding: 5px 0;
	text-align: left;
	vertical-align: baseline;
	border-bottom: 1px solid var(--rule);
	font-weight: 400;
}

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

.panel td {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.panel span {
	display: block;
	font-size: 11px;
	color: var(--muted);
}

.panel .empty {
	margin: 10px 0 0;
	font-size: 12px;
	color: var(--muted);
}

/* Said once, at the foot of the form, when a diagram tab is holding the
   loading still. */
.panel .note {
	margin: 12px 0 0;
	padding: 8px 10px;
	background: var(--field);
	border-left: 3px solid var(--rule);
	font-size: 12px;
	color: var(--muted);
}

.form select:disabled,
.form input:disabled,
.panel button:disabled {
	opacity: 0.5;
	cursor: default;
}

.panel button:disabled:hover { background: none; color: var(--ink); }


.panel .warn {
	margin: 0;
	padding: 10px 12px;
	background: #fbe6e2;
	border-left: 3px solid var(--danger);
	color: #9d2417;
	font-size: 13px;
}

/* ------------------------------------------------------------------- hints --- */

.hintbar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 8px 16px;
	background: var(--panel);
	border-top: 1px solid var(--rule);
	font-size: 12.5px;
	color: var(--muted);
	min-height: 38px;
}

.hintbar p {
	margin: 0;
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.keys summary {
	cursor: pointer;
	list-style: none;
	color: var(--ink);
}

.keys summary::-webkit-details-marker { display: none; }

.keys[open] summary { color: var(--accent); }

.keys dl {
	position: absolute;
	right: 16px;
	bottom: 44px;
	width: min(30rem, calc(100vw - 32px));
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 6px 14px;
	margin: 0;
	padding: 14px 16px;
	background: var(--panel);
	border: 1px solid var(--rule);
	border-radius: 6px;
	box-shadow: 0 8px 28px rgba(60, 50, 30, 0.22);
}

.keys dt {
	color: var(--ink);
	white-space: nowrap;
}

.keys dd { margin: 0; }

@media (max-width: 800px) {
	.panel {
		position: absolute;
		right: 0;
		top: 52px;
		bottom: 38px;
		width: 220px;
		flex-basis: 220px;
		opacity: 0.96;
	}
}


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

.form {
	display: grid;
	gap: 8px;
	margin-bottom: 4px;
}

.form label {
	display: grid;
	grid-template-columns: minmax(3.6rem, auto) minmax(0, 1fr) auto;
	align-items: center;
	gap: 8px;
	font-size: 12.5px;
	color: var(--muted);
}

.form label > span { min-width: 0; }

.form em {
	font-style: normal;
	font-size: 11px;
	color: var(--muted);
	min-width: 3.2rem;
}

.form select,
.form input {
	font: inherit;
	font-size: 12.5px;
	color: var(--ink);
	background: var(--field);
	border: 1px solid var(--rule);
	border-radius: 3px;
	padding: 3px 5px;
	min-width: 0;
	width: 100%;
}

.form input { text-align: right; font-variant-numeric: tabular-nums; }

.form select:focus,
.form input:focus {
	outline: 2px solid var(--select);
	outline-offset: -1px;
}

/* Selects (shape, material, section) get a wider control column. */
.form label.wide { grid-template-columns: minmax(3.6rem, auto) minmax(0, 1fr); }

/* ------------------------------------------------------------- the menu --- */

.menu {
	position: fixed;
	z-index: 50;
	min-width: 12rem;
	max-height: 70vh;
	overflow-y: auto;
	padding: 6px;
	background: var(--panel);
	border: 1px solid var(--rule);
	border-radius: 6px;
	box-shadow: 0 10px 30px rgba(60, 50, 30, 0.26);
}

.menu-title {
	margin: 2px 6px 6px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.menu button {
	display: block;
	width: 100%;
	text-align: left;
	border: none;
	border-radius: 4px;
	padding: 6px 8px;
	font-size: 13px;
}

.menu button span {
	display: block;
	font-size: 11px;
	color: var(--muted);
}

.menu button.active {
	background: var(--ink);
	color: var(--paper);
}

.menu button.active span { color: rgba(250, 250, 247, 0.7); }

/* ------------------------------------------------- selection tabs & lists --- */

.tabs {
	display: flex;
	gap: 4px;
	margin: 0 0 10px;
}

.tabs button {
	flex: 1;
	font-size: 12px;
	padding: 4px 6px;
}

.loadrow {
	display: flex;
	align-items: center;
	gap: 6px;
	border-bottom: 1px solid var(--rule);
}

.loadrow .link {
	flex: 1;
	border: none;
	background: none;
	text-align: left;
	padding: 6px 2px;
	font-size: 12.5px;
	color: var(--ink);
}

.loadrow .link:hover { background: var(--hover); }

.loadrow .drop {
	flex: 0 0 auto;
	color: var(--muted);
	padding: 6px 8px;
}

.loadrow .drop:hover { color: var(--danger); background: none; }

/* Six little boxes: three releases at each end of the member. */
.releases th {
	font-size: 11px;
	color: var(--muted);
	font-weight: 400;
}

.releases td {
	text-align: center;
	padding: 4px 0;
}

.releases input {
	margin: 0;
	accent-color: var(--select);
}

.wide-button {
	display: block;
	width: 100%;
	margin-top: 10px;
	padding: 6px 8px;
	font-size: 12.5px;
}

/* Length fields hold things like 12'-6", so they are text, not spinners. */
.form input[type="text"] { text-align: right; }
