:root {
  --bg: #0b0c10;
  --bg-2: #111318;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: #2a2f3a;
  --text: #f3f4f6;
  --muted: #9aa1ad;
  --accent: #ffc14d;
  --accent-2: #ff7a59;
  --accent-ink: #1a1203;
  --focus: #7cb7ff;
  --radius: 12px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f6f2;
    --bg-2: #efede6;
    --surface: #ffffff;
    --surface-2: #f1efe9;
    --line: #dedad0;
    --text: #15161a;
    --muted: #5d6270;
    --accent: #f5a524;
    --accent-2: #ef5b38;
    --accent-ink: #1a1203;
    --focus: #2f6fdb;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; flex: none; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

button, label.link { font: inherit; cursor: pointer; }
button { border: 0; background: none; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

kbd {
  font: 600 12px/1 var(--mono);
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  color: var(--text);
  white-space: nowrap;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  flex: none;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 750; font-size: 20px; letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; color: var(--accent); }
.topnav { display: flex; gap: 6px; }
.ghost { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-size: 14px; }
.ghost:hover { background: var(--surface); color: var(--text); }
.ghost svg { width: 18px; height: 18px; }

/* ---------- Startsida ---------- */
.view { flex: 1; min-height: 0; }
#home { overflow-y: auto; }
.hero {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(40px, 9vh, 110px) clamp(20px, 5vw, 40px) 40px;
  text-align: center;
  position: relative;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 60px 10% auto;
  height: 380px;
  background: radial-gradient(60% 60% at 50% 30%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
}
.eyebrow { display: inline-block; margin: 0 0 22px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
h1 { font-size: clamp(40px, 7.2vw, 78px); line-height: 1.02; letter-spacing: -0.045em; margin: 0 0 22px; font-weight: 780; }
.shine { background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: clamp(17px, 2.1vw, 20px); color: var(--muted); max-width: 620px; margin: 0 auto 36px; text-wrap: pretty; }

.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 18px; border-radius: 12px; font-weight: 650;
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 30px -10px color-mix(in srgb, var(--accent) 80%, transparent); }
.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.primary:active, .secondary:active { transform: translateY(1px); }
.secondary { background: var(--surface); border: 1px solid var(--line); }
.secondary:hover { background: var(--surface-2); }
.big { padding: 16px 26px; font-size: 17px; border-radius: 14px; }
.big svg { width: 22px; height: 22px; }

.cta-alt { margin-top: 22px; display: flex; gap: 8px 22px; justify-content: center; flex-wrap: wrap; }
.link { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); padding: 6px 8px; border-radius: 8px; font-size: 15px; }
.link:hover { color: var(--text); }
.link svg { width: 18px; height: 18px; }
.link kbd { margin-left: 2px; }
.nocapture { margin: 26px auto 0; max-width: 520px; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 14px; }

.features {
  max-width: 1040px; margin: 30px auto 0; padding: 0 clamp(20px, 5vw, 40px);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
}
.features article { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px 20px 18px; }
.features h2 { font-size: 16px; margin: 0 0 6px; letter-spacing: -0.01em; }
.features p { margin: 0; color: var(--muted); font-size: 14.5px; }

.recent { max-width: 1040px; margin: 48px auto 0; padding: 0 clamp(20px, 5vw, 40px); }
.recent-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.recent-head h2 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
.recent-head p { margin: 0; font-size: 13px; }
.recent-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.recent-grid li { position: relative; }
.recent-item {
  display: block; width: 100%; padding: 0; text-align: left; overflow: hidden;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  transition: transform .12s ease, border-color .12s ease;
}
.recent-item:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.recent-item img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; background: var(--bg-2); }
.recent-item span { display: block; padding: 8px 10px 9px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-del {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff; opacity: 0; transition: opacity .12s;
}
.recent-grid li:hover .recent-del, .recent-del:focus-visible { opacity: 1; }
.recent-del svg { width: 16px; height: 16px; }

.foot { max-width: 1040px; margin: 56px auto 0; padding: 22px clamp(20px, 5vw, 40px) 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* ---------- Redigerare ---------- */
.editor { display: flex; flex-direction: column; background: var(--bg-2); border-top: 1px solid var(--line); }
.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none;
}
.group { display: flex; align-items: center; gap: 2px; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; }
.grow { flex: 1; }
.icon {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: var(--muted);
}
.icon:hover { background: var(--surface-2); color: var(--text); }
.icon:disabled { opacity: .35; cursor: default; background: none; }
.tool[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
}
.swatch i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25); display: block; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }
.widths { margin-left: 8px; background: var(--bg-2); border-radius: 10px; padding: 3px; }
.width { height: 30px; min-width: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.width i { display: block; border-radius: 99px; background: currentColor; width: 16px; }
.width[aria-checked="true"] { background: var(--surface-2); color: var(--text); }
.action { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.action:hover { background: var(--surface-2); }
.action.primary { color: var(--accent-ink); }
.action.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.action svg { width: 18px; height: 18px; }

.stage {
  flex: 1; min-height: 0; overflow: auto; position: relative;
  display: grid; padding: 28px;
  background-color: var(--bg-2);
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 18%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
}
.canvas-wrap { position: relative; margin: auto; line-height: 0; box-shadow: 0 1px 0 rgb(255 255 255 / .04), 0 18px 60px -20px rgb(0 0 0 / .6); border-radius: 4px; }
#canvas { display: block; touch-action: none; image-rendering: auto; border-radius: 4px; }
#canvas.t-select { cursor: default; }
#canvas.t-text { cursor: text; }
#canvas.t-move { cursor: move; }
#canvas.t-draw { cursor: crosshair; }

.text-input {
  position: absolute; margin: 0; padding: 0 2px; border: 1px dashed var(--accent); border-radius: 3px;
  background: rgb(255 255 255 / .85); resize: none; overflow: hidden; outline: none;
  line-height: 1.2; font-weight: 650; font-family: var(--font); white-space: pre; min-width: 40px;
}

.statusbar {
  display: flex; align-items: center; gap: 14px; flex: none;
  padding: 6px 14px; font-size: 12.5px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.zoom { display: inline-flex; align-items: center; gap: 2px; }
.mini { padding: 3px 8px; border-radius: 6px; color: var(--muted); font-size: 12.5px; min-width: 26px; }
.mini:hover { background: var(--surface-2); color: var(--text); }
#zoomLabel { min-width: 58px; }

/* ---------- Dialog, toast, nedräkning, drop ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px 22px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgb(0 0 0 / .6);
}
.dialog::backdrop { background: rgb(0 0 0 / .5); backdrop-filter: blur(3px); }
.dialog h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -0.02em; }
.dialog h3 { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dialog dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; align-items: center; }
.dialog dt { text-align: right; }
.dialog dd { margin: 0; font-size: 14.5px; }
.dialog .primary { margin-top: 10px; float: right; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.dialog-actions .primary { float: none; margin-top: 0; }
.ocr-result { width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: 14px/1.55 var(--mono); resize: vertical; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #111; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 550;
  box-shadow: 0 14px 40px -12px rgb(0 0 0 / .6); transition: opacity .18s ease, transform .18s ease; max-width: min(560px, calc(100vw - 32px));
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #5a1414; }

.countdown {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 60;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 140px; font-weight: 800; letter-spacing: -0.05em;
}
.dropzone { position: fixed; inset: 12px; z-index: 40; border: 2px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--bg) 85%, transparent); display: grid; place-items: center; font-size: 22px; font-weight: 650; pointer-events: none; }

/* ---------- Annonser (diskreta, bara startvy och bruksanvisning) ---------- */
.ad { max-width: 1040px; margin: 44px auto 0; padding: 0 clamp(20px, 5vw, 40px); }
.doc .ad { padding: 0; margin: 8px 0 0; }
.ad-label { margin: 0 0 8px; font-size: 12px; letter-spacing: .04em; color: var(--muted); text-align: center; }
.ad-box { min-height: 90px; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }

/* ---------- Bruksanvisning ---------- */
.help-page { display: block; }
.brand-img { width: 28px; height: 28px; border-radius: 7px; }
.small-btn { padding: 8px 14px; font-size: 14px; text-decoration: none; }
.doc { max-width: 760px; margin: 0 auto; padding: 24px clamp(20px, 5vw, 40px) 20px; }
.doc h1 { font-size: clamp(34px, 6vw, 52px); margin: 18px 0 10px; }
.doc-lede { font-size: 19px; color: var(--muted); margin: 0 0 28px; }
.doc h2 { font-size: 26px; letter-spacing: -0.025em; margin: 0 0 12px; scroll-margin-top: 20px; }
.doc h3 { font-size: 17px; margin: 22px 0 6px; }
.doc section { padding: 30px 0; border-top: 1px solid var(--line); }
.doc p, .doc li { font-size: 16.5px; line-height: 1.65; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc code { font: 14px var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 22px; margin-bottom: 8px; }
.toc ol { margin: 0; columns: 2; column-gap: 28px; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.note { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 8px; }
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 12px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 15px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.doc th { background: var(--surface); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.doc tr:last-child td { border-bottom: 0; }
.doc td:first-child { white-space: nowrap; font-weight: 600; }
.keys-table td:first-child { white-space: normal; }
.ti { width: 18px; height: 18px; vertical-align: -4px; margin-right: 8px; color: var(--accent); }
.doc details { border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px; margin: 10px 0; background: var(--surface); }
.doc summary { cursor: pointer; font-weight: 650; padding: 10px 0; }
.doc details p { margin-top: 0; }
.doc-cta { text-align: center; margin: 30px 0 0; }
.doc-cta a { text-decoration: none; }
@media (max-width: 600px) { .toc ol { columns: 1; } }

@media (max-width: 1180px) {
  .action:not(.primary) span { display: none; }
  .toolbar { gap: 3px; }
  .toolbar .sep { margin: 0 3px; }
  .icon { width: 34px; height: 34px; }
  .swatch { width: 22px; height: 22px; }
  .widths { margin-left: 4px; }
}

@media (max-width: 820px) {
  .toolbar { gap: 4px; padding: 6px 8px; }
  .action span { display: none; }
  .sep { display: none; }
  .widths { margin-left: 0; }
  .stage { padding: 12px; }
  .topnav .ghost span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
a.ghost { text-decoration: none; }
