:root {
	color-scheme: light;
	font: 15px/1.5 system-ui, sans-serif;
	color: #24282c;
	background: #404850;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: #404850;
	height: 100vh;
	height: 100dvh;
	display: flex;
	flex-direction: column;
}

header {
	position: relative;
	overflow: hidden;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 14px 24px;
	gap: 24px;
	flex-wrap: wrap;
	flex: none;
	border-bottom: 1px solid #252c32;
	color: white;
	background:linear-gradient(#273442, #000);
}
#brand-wave { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.app-header > :not(#brand-wave) { position:relative; z-index:1; }

h1 {
	font-size: 32px;
	letter-spacing: -1.2px;
	margin: 0;
}

h1 span {
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0;
	margin-left: 12px;
	color: #d1d7dc;
}

header p {
	margin: 0;
	color: #686d71;
}

.status {
	font-size: 13px;
}

main {
	padding: 8px 8px;
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

nav {
	display: flex;
	gap: 18px;
	align-items: center;
	margin-left: auto;
	min-width: 0;
	flex-wrap: wrap;
}

nav label {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13px;
	min-width: 0;
}

select { min-width: 0; max-width: 100%; }
nav label:first-child { flex-shrink: 1; }
.brand { flex: none; }
.app-header .library-session { min-width:15rem; padding:7px 9px; border:1px solid #ffffff45; border-radius:6px; color:#f2f5f7; background:#202830cc; backdrop-filter:blur(3px); }
.app-header .library-session button { background:#fff; color:#24282c; }
.diagram-control { display:flex; align-items:center; gap:10px; min-width:0; font-size:13px; }
#diagram-picker { position:relative; min-width:0; width:24rem; max-width:100%; }
#diagram-picker > summary { display:flex; align-items:center; gap:10px; padding:8px 12px; border:1px solid #ccc; border-radius:5px; cursor:pointer; background:white; }
#diagram-picker > summary::after { content:'▾'; margin-left:auto; }
#diagram-picker > summary::marker { content:''; }
#diagram-picker > summary::-webkit-details-marker { display:none; }
#diagram-current { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#diagram-folders { position:absolute; z-index:10; top:calc(100% + 4px); left:0; width:100%; max-height:min(60vh, 30rem); overflow:auto; padding:8px; border:1px solid #ccc; border-radius:5px; background:white; box-shadow:0 5px 16px #0002; }
#diagram-folders details { margin-left:10px; }
#diagram-folders > details { margin-left:0; }
#diagram-folders summary { padding:6px; cursor:pointer; font-weight:600; }
#diagram-folders button { display:block; width:100%; text-align:left; padding:6px 10px; border:0; font-size:13px; }
#diagram-folders button:hover, #diagram-folders button[aria-current="true"] { background:#edf1f4; }
.source-caption { flex:1 1 auto; min-width:0; overflow:hidden; }
#source-path { display:block; width:100%; max-width:100%; color:#687076; font-size:11px; overflow:hidden; white-space:nowrap; text-overflow:clip; user-select:text; }

select,
button {
	padding: 8px 12px;
	border: 1px solid #ccc;
	border-radius: 5px;
	background: white;
	font: inherit;
}

button {
	cursor: pointer;
}

button:disabled {
	cursor: default;
	opacity: .4;
}
button[aria-pressed="true"] { background:#edf1f4; border-color:#9ba6ae; }

.workspace {
	display: grid;
	grid-template-columns: minmax(190px, var(--library-width, .48fr)) 6px minmax(280px, var(--source-width, .95fr)) 6px minmax(320px, 1.4fr);
	gap: 10px;
	flex: 1;
	min-height: 0;
}
.workspace.library-collapsed { grid-template-columns:34px minmax(280px, var(--source-width, .95fr)) 6px minmax(320px, 1.4fr); }
.workspace.svg-editing { grid-template-columns:minmax(190px,var(--library-width,.48fr)) 6px minmax(0,1fr); }
.workspace.library-collapsed.svg-editing { grid-template-columns:34px minmax(0,1fr); }
#pane-resizer,#library-resizer { align-self:stretch; min-height:0; border-radius:4px; cursor:col-resize; background:#252d34; outline:none; touch-action:none; }
#pane-resizer:hover,#pane-resizer:focus-visible,#pane-resizer[data-dragging="true"],#library-resizer:hover,#library-resizer:focus-visible,#library-resizer[data-dragging="true"] { background:#8da0ad; box-shadow:0 0 0 2px #ffffff55; }
.workspace.library-collapsed #library-resizer { display:none; }

section,
.library-pane {
	display: flex;
	flex-direction: column;
	min-height: 0;
	min-width: 0;
	border: 1px solid #d6d9db;
	border-radius: 7px;
	background: white;
	overflow: hidden;
}
.svg-editor-pane { grid-column:3/-1; }
.workspace.library-collapsed .svg-editor-pane { grid-column:2/-1; }
#svg-editor-frame { flex:1; width:100%; min-height:0; border:0; background:#252d34; }
#svg-source-path { display:block; width:100%; max-width:100%; color:#687076; font-size:11px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; user-select:text; }
.source-pane { container-type:inline-size; }
@container (max-width:410px) {
	.source-pane .pane-bar { flex-wrap:wrap; }
	.source-pane .source-caption { flex:1 0 100%; }
	.source-pane .pane-actions { width:100%; justify-content:flex-end; }
}

.library-pane { position:relative; }
.library-pane > .pane-bar { padding-inline:8px; }
.library-pane > .pane-bar .pane-actions { gap:4px; }
.library-pane > .pane-bar .pane-actions button { padding-inline:6px; font-size:12px; }
.library-pane[hidden] { display:none; }
#library-expand { background-color: #e0e8f0; opacity: 0.25; font-weight: bold; writing-mode:vertical-lr; padding:10px 5px; min-width:34px; }
.library-session { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:11px; }
.library-session button { padding:3px 7px; font-size:11px; }
.library-create { display:flex; gap:6px; padding:8px; border-bottom:1px solid #e1e3e5; }
.library-create button { flex:1; padding:5px 6px; font-size:12px; }
.library-tree { flex:1; min-height:0; overflow:auto; padding:7px 0; outline:2px solid transparent; outline-offset:-2px; }
.library-tree::-webkit-scrollbar:horizontal { height:0; }
.library-tree.external-drop { outline-color:#2a78a6; background:#edf7fc; }
.library-empty { margin:16px; color:#687076; font-size:12px; }
.library-row { --depth:0; display:flex; align-items:center; gap:5px; min-width:max-content; padding:4px 8px 4px calc(8px + var(--depth) * 15px); min-height:26px; font-size:13px; cursor:default; user-select:none; }
.library-row:hover,.library-row[aria-selected="true"] { background:#edf1f4; }
.library-row.drop-target { background:#d9edf7; outline:1px solid #5a9bc0; }
.library-folder { font-weight:600; }
.library-icon { width:18px; flex:none; color:#65727b; text-align:center; font:16px/18px "Segoe UI Symbol","Noto Sans Symbols 2",sans-serif; }
.library-toggle { width:18px; height:18px; flex:none; padding:0; border:0; border-radius:2px; color:#65727b; background:transparent; font:16px/18px "Segoe UI Symbol","Noto Sans Symbols 2",sans-serif; }
.library-toggle:hover,.library-toggle:focus-visible { background:#dfe7ec; }
.library-label { display:inline-flex; align-items:center; }
.library-changed { margin-left:2px; color:#c44b13; font-weight:800; }
.cache-row { display:grid; grid-template-columns:minmax(12rem,1fr) auto minmax(9rem,auto); gap:12px; font-variant-numeric:tabular-nums; }
.cache-row time { color:#687076; }
.library-selection { flex:none; border-top:1px solid #e1e3e5; padding:8px; }
.library-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
.library-actions button { padding:4px 3px; font-size:11px; }
#library-mode { margin-left:5px; }
#preview .code-snippet { min-width:480px; }
dialog { width:min(24rem,calc(100vw - 32px)); padding:0; border:1px solid #bfc5c9; border-radius:8px; box-shadow:0 14px 50px #0004; }
dialog::backdrop { background:#17202a66; }
#login-form { display:grid; gap:14px; padding:20px; }
#login-form h2 { font-size:16px; }
#login-form label { display:grid; gap:5px; font-size:12px; }
#login-form input { width:100%; padding:8px; border:1px solid #bbb; border-radius:4px; font:inherit; }
#login-error { margin:0; color:#8a2020; font-size:12px; }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; }

h2 {
	font-size: 13px;
	padding: 0;
	margin: 0;
}

.pane-bar { background-color: #e0e8f0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-bottom: 1px solid #e1e3e5; flex: none; }
.pane-actions { display: flex; gap: 8px; flex:none; }
.pane-actions button { padding: 4px 10px; font-size: 13px; }
.preview-bar { flex-wrap:wrap; }
.preview-controls { display:flex; align-items:center; justify-content:flex-end; gap:6px; min-width:0; flex-wrap:wrap; }
.preview-controls label { display:flex; align-items:center; gap:5px; font-size:11px; }
.preview-controls select,.preview-controls button { padding:4px 7px; font-size:12px; }
.preview-content { display:flex; flex-direction:column; flex:1; min-height:0; overflow:auto; }
#markdown-preview { flex:1; width:100%; min-height:0; border:0; background:white; }
.preview-content { position:relative; }
.markdown-preview-buffer { position:absolute; inset:0; width:100%; height:100%; border:0; visibility:hidden; pointer-events:none; }
#generated-html { flex:1; width:100%; height:0; min-height:0; background:#fbfbfb; }

h2 span {
	font-weight: 400;
	color: #777;
	margin-left: 12px;
}

textarea {
	display: block;
	width: 100%;
	flex: 1;
	height: 0;
	min-height: 0;
	resize: none;
	overflow: auto;
	border: 0;
	padding: 20px;
	outline-offset: -3px;
	font: 13px/1.65 ui-monospace, Consolas, monospace;
	tab-size: 2;
}

#preview {
	padding: 26px;
	overflow: auto;
}

#preview svg {
	display: block;
	width: 100%;
	height: auto;
	min-width: 0;
}

#error {
	padding: 16px;
	color: #8a2020;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

footer {
	margin-top: 10px;
	flex: none;
	font-size: 12px;
	color: #d7dde1;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
}

@media (max-width:900px) {
	.workspace {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: minmax(250px,.7fr) repeat(2, minmax(230px, 1fr));
		overflow-y: auto;
	}
	.workspace.library-collapsed { grid-template-columns:minmax(0,1fr); grid-template-rows:34px repeat(2,minmax(230px,1fr)); }
	#pane-resizer,#library-resizer { display:none; }
	.library-pane[hidden] + #library-expand { writing-mode:horizontal-tb; min-width:0; }

	header,
	main {
		padding: 12px;
	}

	.status {
		display: none;
	}
}

nav {
	flex-wrap: wrap;
}

#asset-base {
	width: 19rem;
}

#opacity {
	width: 7rem;
}

[hidden] {
	display: none !important;
}
#action-status:not(:empty) { display: block; color: #fff; }
@media (max-width:600px) {
 header { gap: 10px; }
 header p { font-size: 12px; }
 nav { width: 100%; gap: 8px 12px; }
 nav label:first-child { width: 100%; }
 nav label:first-child select { flex: 1; }
 .diagram-control { width:100%; }
 #diagram-picker { flex:1; width:auto; }
 select, button { padding: 6px 8px; }
 #preview { padding: 14px; }
 .source-pane .pane-bar { align-items:flex-start; flex-wrap:wrap; }
 .source-pane .source-caption { flex:1 0 100%; }
 .source-pane .pane-actions { width:100%; justify-content:flex-end; }
 .preview-controls { width:100%; justify-content:flex-end; }
 footer { font-size: 10px; }
}
