:root {
	--bg: #f6f5f2; --surface: #ffffff; --fg: #1c1b19; --muted: #6b6862; --quiet: #9a968e;
	--line: #e4e1da; --hover: #efede8; --accent: #1c1b19; --accent-fg: #f6f5f2;
	--warn: #8a4b0f; --warn-bg: #fdf3e6; --error: #a1261b; --ok: #2d6a3e;
	--radius: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #121211; --surface: #1b1b19; --fg: #ecebe7; --muted: #a7a39b; --quiet: #77736c;
		--line: #2c2b28; --hover: #24231f; --accent: #ecebe7; --accent-fg: #121211;
		--warn: #f0b36b; --warn-bg: #2a2014; --error: #f08a7e; --ok: #7cc58f;
		color-scheme: dark;
	}
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.loading { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; } .warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: var(--radius); }
.error { color: var(--error); } .ok { color: var(--ok); }

/* inloggning och godkännande */
body.center, .center { min-height: 100%; display: flex; align-items: center; justify-content: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 420px; margin: 16px; }
.card h1 { font-size: 20px; margin: 0 0 12px; }
.brand { font-weight: 650; margin: 0 0 18px; }
.card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.card input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-size: 16px; }
.row { display: flex; gap: 10px; margin-top: 18px; }
.row > * { flex: 1; }

.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: transparent; color: var(--error); border-color: var(--line); }

/* arbetsytan */
.shell { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.side header { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.side header .org { font-weight: 650; }
.side header .who { font-size: 12px; color: var(--muted); }
.search { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.search input { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.tree { flex: 1; overflow: auto; padding: 6px 6px 20px; font-size: 14px; }
.node { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node:hover { background: var(--hover); }
.node.active { background: var(--hover); font-weight: 600; }
.node .caret { width: 12px; color: var(--quiet); flex: none; text-align: center; }
.node .count { margin-left: auto; color: var(--quiet); font-size: 12px; }
.children { margin-left: 14px; }
.side footer { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.side footer button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; font-size: 13px; }
.side footer button:hover { color: var(--fg); }

.main { overflow: auto; min-width: 0; }
.bar { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; z-index: 1; }
.crumbs { flex: 1; min-width: 200px; font-size: 14px; color: var(--muted); }
.crumbs a { cursor: pointer; text-decoration: none; } .crumbs a:hover { text-decoration: underline; color: var(--fg); }
.crumbs .sep { margin: 0 6px; color: var(--quiet); }
.content { padding: 20px 24px 60px; max-width: 1100px; }
.content h2 { font-size: 18px; margin: 0 0 6px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td { background: var(--hover); }
table.list td.num { text-align: right; color: var(--muted); white-space: nowrap; }
.desc { color: var(--muted); font-size: 13px; }
.tag { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--muted); margin-left: 6px; }

pre.text { font: 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
.md { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 26px; line-height: 1.6; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--hover); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--hover); padding: 12px; border-radius: 6px; overflow: auto; }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
iframe.view { width: 100%; height: calc(100vh - 140px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
img.view { max-width: 100%; border-radius: var(--radius); }
.meta { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.tabs { display: flex; gap: 4px; margin: 0 0 12px; }
.tabs button { background: none; border: 1px solid transparent; border-radius: 6px; padding: 3px 10px; cursor: pointer; color: var(--muted); font-size: 13px; }
.tabs button.on { border-color: var(--line); color: var(--fg); background: var(--surface); }

.hit { font: 13px/1.5 var(--mono); padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.hit .ln { color: var(--quiet); display: inline-block; min-width: 48px; }
.hit.ctx { color: var(--muted); }
.hitfile { margin: 16px 0 4px; font-weight: 600; cursor: pointer; } .hitfile:hover { text-decoration: underline; }

textarea.edit { width: 100%; min-height: 60vh; font: 13px/1.55 var(--mono); padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.form { display: grid; gap: 10px; max-width: 520px; }
.form input, .form select { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.notice { position: fixed; bottom: 18px; right: 18px; background: var(--accent); color: var(--accent-fg); padding: 10px 14px; border-radius: var(--radius); font-size: 14px; max-width: 420px; }
.notice.bad { background: var(--error); color: #fff; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); margin: 14px 0; }
.drop.over { border-color: var(--fg); color: var(--fg); }
.progress { font-size: 13px; color: var(--muted); }
code.copy { font-family: var(--mono); background: var(--surface); border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; display: inline-block; user-select: all; }

.menu-btn { display: none; }
@media (max-width: 800px) {
	.shell { grid-template-columns: 1fr; }
	.side { position: fixed; inset: 0 25% 0 0; z-index: 5; transform: translateX(-100%); transition: transform .2s; }
	.side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
	.menu-btn { display: inline-block; }
	.bar, .content { padding-left: 16px; padding-right: 16px; }
}
.summary { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--fg); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }
.summary p { margin: 6px 0 0; }
.node.motor { font-weight: 650; }
.node.motor .caret { color: var(--fg); }
tr.motor td:first-child { font-weight: 650; }
.lock { font-size: 11px; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 0 6px; margin-left: 6px; font-weight: 500; }
.node .lock { margin-left: 6px; }
