:root {
  --violet: #7c3aed;
  --violet-2: #a855f7;
  --pink: #ec4899;
  --cyan: #67e8f9;
  --bg: #f7f6fc;
  --surface: #ffffff;
  --surface-2: #f3f1fa;
  --border: #e5e2ef;
  --text: #24172f;
  --muted: #6f6883;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 10px 30px -12px rgba(36, 23, 47, 0.25), 0 2px 6px rgba(36, 23, 47, 0.06);
  --radius: 12px;
  --header-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120e1a;
    --surface: #1b1626;
    --surface-2: #241d33;
    --border: #342b47;
    --text: #ece8f7;
    --muted: #a59dbb;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--violet); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Painikkeet & lomakkeet ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--violet), var(--violet-2)); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon.sm { width: 30px; }
.btn.on { background: color-mix(in srgb, var(--violet) 14%, var(--surface)); border-color: color-mix(in srgb, var(--violet) 40%, var(--border)); color: var(--violet); }
@media (prefers-color-scheme: dark) { .btn.on { color: #c4b5fd; } }

input[type=text], input[type=password], input[type=url], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 8px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 18%, transparent); }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .03em; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.pro { background: linear-gradient(135deg, var(--violet), var(--pink)); color: #fff; }
.badge.ai { background: color-mix(in srgb, var(--cyan) 35%, var(--surface)); color: #0e7490; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; margin: 8px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--violet); }
.sep { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------- Kirjautuminen ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px 60px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--violet) 22%, transparent), transparent),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--pink) 18%, transparent), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.login-card h1 { font-size: 22px; margin: 22px 0 4px; }
.login-card .btn.primary { width: 100%; height: 42px; margin-top: 18px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- Yläpalkki ---------- */
.topbar { height: var(--header-h); display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 20; }
.topbar .brand { font-size: 16px; margin-right: 8px; }
.topbar .brand img { width: 28px; height: 28px; }
.topbar .spacer { flex: 1; }
.vsep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.title-input { border: 1px solid transparent !important; background: transparent !important; font-weight: 600; font-size: 15px; max-width: 320px; padding: 6px 8px !important; box-shadow: none !important; }
.title-input:hover { border-color: var(--border) !important; }
.title-input:focus { border-color: var(--violet) !important; background: var(--surface) !important; }
.save-status { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 88px; }
.save-status.err { color: var(--danger); }

/* Valikot */
.menu-wrap { position: relative; }
.menu { position: fixed; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 150; }
.menu.left { left: 0; right: auto; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button .k { margin-left: auto; font-size: 11px; color: var(--muted); }
.menu .mh { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px 4px; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }

/* ---------- Koti / karttalista ---------- */
.home { display: flex; height: calc(100vh - var(--header-h)); }
.side { width: 240px; border-right: 1px solid var(--border); background: var(--surface); padding: 14px 10px; overflow: auto; flex-shrink: 0; }
.side .nav { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; border: 0; background: none; cursor: pointer; text-align: left; }
.side .nav:hover { background: var(--surface-2); }
.side .nav.on { background: color-mix(in srgb, var(--violet) 12%, var(--surface)); color: var(--violet); font-weight: 600; }
.side .nav .cnt { margin-left: auto; font-size: 12px; color: var(--muted); }
.side h4 { margin: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; }
.side h4 button { margin-left: auto; }
.home-main { flex: 1; overflow: auto; padding: 24px 28px 70px; }
.home-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.home-head h2 { margin: 0 12px 0 0; font-size: 22px; }
.home-head .search { max-width: 280px; }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 16px; }
.chip { height: 26px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 12px; }
.chip.on { background: var(--violet); color: #fff; border-color: var(--violet); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; cursor: pointer; transition: box-shadow .2s, transform .2s; position: relative; display: flex; flex-direction: column; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card .thumb { height: 110px; display: grid; place-items: center; background: linear-gradient(135deg, color-mix(in srgb, var(--violet) 14%, var(--surface)), color-mix(in srgb, var(--pink) 12%, var(--surface))); }
.card .thumb svg { width: 150px; height: 80px; opacity: .85; }
.card .body { padding: 12px 14px 14px; }
.card .t { font-weight: 600; font-size: 15px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 28px; }
.card .m { font-size: 12px; color: var(--muted); }
.card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.card .tags span { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.card .star { position: absolute; top: 118px; right: 38px; border: 0; background: none; cursor: pointer; font-size: 16px; opacity: .35; }
.card .star.on { opacity: 1; }
.card .more { position: absolute; top: 114px; right: 6px; }
.card.new { border-style: dashed; align-items: center; justify-content: center; min-height: 190px; color: var(--muted); font-weight: 600; gap: 6px; background: transparent; }
.card.new .plus { font-size: 34px; color: var(--violet); line-height: 1; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ---------- Editori ---------- */
.editor-wrap { display: flex; height: calc(100vh - var(--header-h)); position: relative; }
.canvas-area { flex: 1; position: relative; min-width: 0; }
.mm-host { position: absolute; inset: 0; overflow: hidden; }
.mm-viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; outline: none; cursor: default; user-select: none; -webkit-user-select: none; }
.mm-viewport.panning { cursor: grabbing; }
.mm-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.mm-world.animate { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.mm-svg { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.mm-svg .mm-rel-hit { cursor: pointer; pointer-events: stroke; }
.mm-svg .mm-bound.sel { stroke-width: 2.5; stroke-dasharray: none; }
.mm-nodes, .mm-stickies { position: absolute; left: 0; top: 0; }
.mm-node { position: absolute; cursor: pointer; transition: opacity .25s, box-shadow .15s; }
.mm-node.d0 { box-shadow: 0 6px 18px -10px rgba(124, 58, 237, .45); }
.mm-node .mm-text { position: absolute; white-space: pre; pointer-events: none; }
.mm-node .mm-text.strike { text-decoration: line-through; opacity: .6; }
.mm-node .mm-ic { position: absolute; display: flex; align-items: center; justify-content: center; pointer-events: none; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.mm-node .mm-prio, .mm-node .mm-prog { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-style: normal; font-weight: 700; }
.mm-node .mm-badge { position: absolute; width: 18px; height: 18px; font-size: 12px; display: grid; place-items: center; cursor: pointer; border-radius: 5px; }
.mm-node .mm-badge:hover { background: rgba(124, 58, 237, .15); }
.mm-node .mm-img { position: absolute; object-fit: cover; border-radius: 6px; pointer-events: none; }
.mm-node.sel { outline: 1.5px solid var(--violet); outline-offset: 3px; border-radius: 8px; }
.mm-node.sh-underline.sel { outline-offset: 2px; }
.mm-node.match { box-shadow: 0 0 0 4px #facc15 !important; border-radius: 8px; }
.mm-node.dim { opacity: .18; }
.mm-node.editing { visibility: hidden; }
.mm-node.dragsrc { opacity: .35; }
.mm-ghost { opacity: .75; pointer-events: none; z-index: 10; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.mm-toggle { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 1px solid; background: var(--mm-bg, #fff); font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; font-family: Inter, sans-serif; }
.mm-node:hover .mm-toggle, .mm-node.sel .mm-toggle, .mm-toggle.on { opacity: 1; }
.mm-edit { position: absolute; z-index: 20; resize: none; border: 2px solid var(--violet); border-radius: 8px; background: var(--mm-bg, #fff); outline: none; white-space: pre; overflow: hidden; box-shadow: 0 6px 20px rgba(124, 58, 237, .25); }
.mm-summary { position: absolute; border: 2px solid; border-radius: 15px; background: var(--mm-bg); font-weight: 600; font-size: 14px; display: grid; place-items: center; cursor: pointer; white-space: nowrap; padding: 0 12px; outline: none; }
.mm-summary.sel, .mm-rel-label.sel, .mm-bound-label.sel { outline: 2.5px solid var(--violet); outline-offset: 2px; }
.mm-bound-label { position: absolute; color: #fff; font-size: 12px; font-weight: 600; height: 22px; line-height: 22px; padding: 0 8px; border-radius: 11px; cursor: pointer; white-space: nowrap; }
.mm-rel-label { position: absolute; transform: translate(-50%, -50%); background: var(--mm-bg); border: 1px solid; border-radius: 11px; padding: 1px 8px; font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.mm-rel-label:empty { display: none; }
.mm-sticky { position: absolute; border-radius: 4px; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .1); color: #2b2b2b; display: flex; flex-direction: column; cursor: grab; }
.mm-sticky.sel { outline: 2.5px solid var(--violet); outline-offset: 2px; }
.mm-sticky-bar { height: 12px; flex-shrink: 0; background: rgba(0, 0, 0, .05); border-radius: 4px 4px 0 0; }
.mm-sticky-text { flex: 1; padding: 6px 12px 12px; font-size: 14px; line-height: 20px; white-space: pre-wrap; overflow: hidden; outline: none; word-break: break-word; }
.mm-sticky-text[contenteditable="true"], .mm-sticky-text[contenteditable="plaintext-only"] { cursor: text; user-select: text; -webkit-user-select: text; }
.mm-sticky-rs { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, .18) 50%); border-radius: 0 0 4px 0; }
.mm-sticky.ro { cursor: default; }
.mm-drop { position: absolute; pointer-events: none; border-radius: 8px; z-index: 5; }
.mm-drop.child { border: 2.5px dashed var(--pink); background: color-mix(in srgb, var(--pink) 10%, transparent); }
.mm-drop.before, .mm-drop.after { background: var(--pink); border-radius: 2px; }
.mm-ftb { position: absolute; z-index: 15; display: flex; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow); }
.mm-ftb button { border: 0; background: none; height: 30px; padding: 0 9px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.mm-ftb button:hover { background: var(--surface-2); }
.mm-minimap { position: absolute; right: 14px; bottom: 40px; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; z-index: 6; }
.mm-modehint { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--violet); color: #fff; padding: 8px 14px; border-radius: 99px; font-weight: 600; font-size: 13px; z-index: 16; box-shadow: var(--shadow); }
.mm-host.presenting .mm-toggle, .mm-host.presenting .mm-ftb { display: none; }
.mm-host.presenting .mm-node.sel { outline: none; }

/* Kelluvat työkalut */
.toolstrip { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 5px; box-shadow: var(--shadow); z-index: 8; }
.toolstrip button { width: 38px; height: 38px; border: 0; background: none; border-radius: 9px; cursor: pointer; font-size: 17px; display: grid; place-items: center; position: relative; }
.toolstrip button:hover { background: var(--surface-2); }
.toolstrip hr { border: 0; border-top: 1px solid var(--border); margin: 3px 4px; }
.zoombar { position: absolute; left: 12px; bottom: 36px; display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 4px; box-shadow: var(--shadow); z-index: 8; }
.zoombar span { min-width: 46px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.breadcrumb { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 4px 6px 4px 12px; box-shadow: var(--shadow); z-index: 9; max-width: 80%; overflow: hidden; }
.breadcrumb button.crumb { border: 0; background: none; cursor: pointer; color: var(--violet); font-weight: 500; padding: 2px 4px; white-space: nowrap; }
.present-bar { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: rgba(20, 14, 30, .85); color: #fff; padding: 6px 8px; border-radius: 99px; z-index: 30; backdrop-filter: blur(6px); }
.present-bar button { background: rgba(255, 255, 255, .12); border: 0; color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.present-bar span { min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; }
.searchbar { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); z-index: 9; }
.searchbar input { width: 190px; height: 32px; }
.searchbar select { width: 170px; height: 32px; padding: 4px 8px; }
.searchbar .cnt { font-size: 12px; color: var(--muted); min-width: 36px; text-align: center; }

/* Sivupaneeli */
.panel { width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel.closed { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 6px; gap: 2px; flex-shrink: 0; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 10px 10px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--violet); border-bottom-color: var(--violet); }
.panel-body { flex: 1; overflow: auto; padding: 4px 16px 60px; }
.panel h3 { font-size: 13px; margin: 16px 0 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--violet); }
.swatch.none { background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 4px, var(--border) 4px, var(--border) 6px); }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.icongrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.icongrid button { height: 32px; border: 1px solid transparent; background: none; border-radius: 7px; cursor: pointer; font-size: 17px; padding: 0; }
.icongrid button:hover { background: var(--surface-2); }
.icongrid button.on { background: color-mix(in srgb, var(--violet) 16%, var(--surface)); border-color: var(--violet); }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--surface); height: 32px; cursor: pointer; font-size: 13px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--violet); color: #fff; }
.themegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.themecard { border: 2px solid var(--border); border-radius: 10px; padding: 8px; cursor: pointer; text-align: left; background: var(--surface); }
.themecard.on { border-color: var(--violet); }
.themecard .pv { height: 42px; border-radius: 6px; margin-bottom: 6px; display: flex; align-items: center; justify-content: center; gap: 5px; }
.themecard .pv i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.themecard .pv b { padding: 3px 7px; border-radius: 5px; font-size: 10px; }
.themecard span { font-size: 12px; font-weight: 600; }
.tasklist .ti { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border-radius: 9px; cursor: pointer; }
.tasklist .ti:hover { background: var(--surface-2); }
.tasklist .ti .tt { flex: 1; min-width: 0; }
.tasklist .ti .tt div { overflow: hidden; text-overflow: ellipsis; }
.tasklist .ti.done .tt div:first-child { text-decoration: line-through; color: var(--muted); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.progress i { display: block; height: 100%; background: var(--ok); }
.vlist .vi { display: flex; gap: 6px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.vlist .vi .grow div:last-child { font-size: 11px; color: var(--muted); }
.ai-out { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; line-height: 1.5; font-size: 13px; max-height: 360px; overflow: auto; }
.ai-ideas label { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; cursor: pointer; }
.ai-ideas label small { display: block; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { background: var(--surface-2); border-radius: 10px; padding: 12px; color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 14px; }
.kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; font-size: 12px; text-align: center; background: var(--surface); }

/* Rakennenäkymä */
.outline { position: absolute; inset: 0; overflow: auto; background: var(--surface); padding: 28px 40px 80px; z-index: 12; }
.outline h2 { margin: 0 0 4px; }
.outline .ol-row { display: flex; align-items: center; gap: 4px; }
.outline .ol-row .tw { width: 20px; height: 20px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 11px; flex-shrink: 0; }
.outline .ol-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin: 0 6px 0 2px; }
.outline .ol-row input { border: 0; background: none; padding: 5px 4px; border-radius: 6px; box-shadow: none; }
.outline .ol-row input:focus { background: var(--surface-2); box-shadow: none; }
.outline .ol-row.d1 input { font-weight: 600; font-size: 15px; }
.outline .ol-row.d0 input { font-weight: 700; font-size: 20px; }

/* Modaalit & ilmoitukset */
.modal-backdrop { position: fixed; inset: 0; background: rgba(18, 12, 28, .45); display: grid; place-items: center; z-index: 100; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.wide { max-width: 780px; }
.modal-head { padding: 18px 20px 6px; font-weight: 700; font-size: 17px; display: flex; align-items: center; }
.modal-head button { margin-left: auto; }
.modal-body { padding: 6px 20px 8px; overflow: auto; line-height: 1.5; }
.modal-foot { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tpl { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 10px; cursor: pointer; text-align: center; background: var(--surface); }
.tpl:hover { border-color: var(--violet); background: var(--surface-2); }
.tpl .i { font-size: 28px; }
.tpl .n { font-weight: 600; font-size: 13px; margin-top: 6px; }
.toasts { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: #24172f; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: tin .2s ease-out; }
.toast.err { background: var(--danger); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.shortcuts div:nth-child(odd) { white-space: nowrap; }

/* Alatunniste */
.site-footer { position: fixed; right: 12px; bottom: 8px; font-size: 11px; color: var(--muted); z-index: 40; background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 3px 9px; border-radius: 99px; backdrop-filter: blur(4px); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--violet); }

body.zen .topbar, body.zen .panel, body.zen .toolstrip, body.zen .searchbar { display: none !important; }
body.zen .editor-wrap { height: 100vh; }
body.presenting .topbar, body.presenting .panel, body.presenting .toolstrip, body.presenting .zoombar, body.presenting .searchbar, body.presenting .breadcrumb, body.presenting .site-footer { display: none !important; }
body.presenting .editor-wrap { height: 100vh; }

@media (max-width: 860px) {
  .side { display: none; }
  .home-main { padding: 16px 16px 70px; }
  .panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 25; width: min(340px, 92vw); box-shadow: var(--shadow); }
  .hide-sm { display: none !important; }
  .title-input { max-width: 150px; }
  .searchbar { left: 60px; right: 8px; flex-wrap: wrap; }
  .searchbar input, .searchbar select { width: auto; flex: 1; }
}
@media (max-width: 520px) {
  .topbar { gap: 4px; padding: 0 6px; }
  .topbar .brand span { display: none; }
  .save-status { display: none; }
}
