/* The viewer's page around the canvas (web/viewer.js). Dark, as the app's canvas. */
:root {
	color-scheme: dark;
	--bg: #1e1e1e;
	--panel: #242424;
	--line: #333;
	--field: #2c2c2c;
	--field-hover: #363636;
	--text: #e8e8e8;
	--muted: #9a9a9a;
	--accent: #E8876A;
	--accent-ink: #120C09;
	--sel: #0D99FF;
	--warn: #e0a85a;
	--error: #ef7a7a;
	--side: 240px;
	--bar: 48px;
	--top: calc(var(--bar) + env(safe-area-inset-top, 0px)); /* under the bar, past an iPhone's notch */
	font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }

#bar {
	position: fixed; inset: 0 0 auto 0; height: var(--top); padding-top: env(safe-area-inset-top) !important; z-index: 4;
	display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
	background: var(--bg); border-bottom: 1px solid var(--line);
}
.home { display: flex; flex: none; }
.mark { display: block; width: 30px; height: 30px; }
#title { min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
#themes { display: flex; gap: 6px; }

.btn, #bar select, #themes select {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px;
	background: var(--field); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover, #themes select:hover { background: var(--field-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; background: none; border: 0; border-radius: 7px; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--field); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.menu-wrap { position: relative; }
.menu, .popover {
	position: absolute; z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.menu { right: 0; top: 36px; min-width: 240px; padding: 6px; display: flex; flex-direction: column; }
.menu > * { display: block; padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.menu > *:hover, .menu > *:focus-visible { background: var(--field-hover); }

#side {
	position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); z-index: 3;
	display: flex; flex-direction: column; gap: 16px; padding: 14px 8px; overflow-y: auto;
	background: var(--panel); border-right: 1px solid var(--line);
}
#side h2 { margin: 0 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
#side ul { list-style: none; margin: 0; padding: 0; }
#side li button {
	display: block; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#side li button:hover { background: var(--field); }
#side li button[aria-current="true"] { background: rgba(13, 153, 255, .18); color: #fff; }
#side .private { margin: auto 8px 0; font-size: 12px; color: var(--muted); }

#stage { position: fixed; inset: var(--top) 0 0 0; }
body.with-side #stage { left: var(--side); }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; }
#canvas.dragging { cursor: grabbing; }

#notices { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.notice {
	pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: 720px; padding: 9px 10px 9px 14px;
	background: rgba(36, 36, 36, .96); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.notice.error { border-left-color: var(--error); }
.notice p { margin: 0; }
.notice small { color: var(--muted); }
.notice button { flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }

#info {
	position: absolute; left: 12px; bottom: 12px; z-index: 2; width: 248px; padding: 12px;
	background: rgba(36, 36, 36, .97); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.info-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.info-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#info-type { color: var(--muted); font-size: 12px; }
#info dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 10px; }
#info dl div { display: flex; gap: 8px; padding: 4px 8px; background: var(--field); border-radius: 6px; }
#info dt { color: var(--muted); }
#info dd { margin: 0; font-variant-numeric: tabular-nums; }
.info-actions { display: flex; gap: 6px; }

#zoombar {
	position: absolute; right: 12px; bottom: 12px; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 3px;
	background: rgba(36, 36, 36, .97); border: 1px solid var(--line); border-radius: 10px;
}
#zoom { min-width: 58px; height: 30px; border: 0; border-radius: 7px; background: none; cursor: pointer; font-variant-numeric: tabular-nums; }
#zoom:hover { background: var(--field); }

.card-wrap { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 20px; overflow-y: auto; background: var(--bg); }
.card { width: min(560px, 100%); padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.card h1 { margin: 0 0 10px; font-size: 22px; letter-spacing: -.01em; }
.card p { margin: 0 0 16px; color: #c9c9c9; line-height: 1.55; }
.card .private { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row.end { justify-content: flex-end; }
#url-form { margin-top: 12px; }
#url-input { flex: 1; min-width: 200px; height: 30px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
#message.error h1 { color: var(--error); }

#drop { position: absolute; inset: 8px; z-index: 5; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 12px; background: rgba(30, 30, 30, .75); pointer-events: none; font-size: 16px; font-weight: 600; }

.popover { right: 120px; top: 52px; width: 260px; padding: 14px; position: fixed; }
.popover h2 { margin: 0 0 10px; font-size: 14px; }
.popover fieldset { border: 0; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.popover legend { padding: 0; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.popover label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

@media (max-width: 720px) {
	:root { --side: 220px; }
	body.with-side #stage { left: 0; }
	#side { box-shadow: 8px 0 24px rgba(0, 0, 0, .4); }
	#themes-side #themes { flex-direction: column; padding: 0 8px; }
	#themes-side select { width: 100%; }
	#info { right: 12px; width: auto; bottom: 60px; padding: 10px; }
	.info-head { flex-direction: row; align-items: baseline; gap: 8px; margin-bottom: 8px; }
	#info dl { grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
	#info dl div { padding: 3px 6px; gap: 4px; font-size: 12px; }
	.popover { right: 8px; left: 8px; width: auto; }
	#export { display: none; }
}
