/* Redigeringsläge — Klyvare Studio. The editor around the customer's page: top bar, preview, panels, login. */
:root {
  --ink: #0c0e1a; --ink-2: #181b2c; --ink-3: #262a40;
  --paper: #f2f0eb; --paper-2: #e8e5de; --line: #d6d3cb;
  --muted: #545a6e; --muted-dark: #a3a8bd;
  --signal: #3d3dff; --signal-light: #a3a8ff;
  --amber: #e5a400; --ok: #1f8a4c; --bad: #c2362b;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --bar: 3.75rem;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper-2); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.rl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.5rem; padding: .5rem 1rem; border-radius: 99px; border: 1.5px solid transparent;
  font-weight: 600; font-size: .9rem; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background-color .2s, color .2s, border-color .2s, opacity .2s, transform .15s var(--ease);
}
.rl-btn:active:not(:disabled) { transform: scale(.97); }
.rl-btn:disabled { opacity: .45; cursor: default; }
.rl-btn svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rl-btn--go { background: var(--signal); color: #fff; }
.rl-btn--go:hover:not(:disabled) { background: #2f2fe6; }
.rl-btn--ghost { background: transparent; color: inherit; border-color: currentColor; }
.rl-btn--icon { width: 2.5rem; padding: 0; background: transparent; color: inherit; }
.rl-btn--icon svg { fill: currentColor; stroke: none; }

/* ---------- Top bar ---------- */
.rl-app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.bar {
  position: relative; z-index: 10; flex: none;
  display: flex; align-items: center; gap: .75rem;
  min-height: var(--bar); padding: .5rem max(.75rem, env(safe-area-inset-right)) .5rem max(.75rem, env(safe-area-inset-left));
  background: var(--ink); color: var(--paper);
}
.bar__left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.bar__brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; min-width: 0; }
.bar__brand svg, .door__brand svg { width: 1.6rem; height: 1.6rem; flex: none; fill: var(--paper); }
.bar__brand .half, .door__brand .half { fill: var(--signal-light); }
.bar__brand > span { display: grid; line-height: 1.15; min-width: 0; }
.bar__mode { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--signal-light); }
.bar__site { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14rem; }
.bar__pages select {
  appearance: none; background: var(--ink-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23f2f0eb' stroke-width='1.5'/%3E%3C/svg%3E") right .6rem center / .75rem no-repeat;
  border: 0; border-radius: 99px; padding: .45rem 2rem .45rem .9rem; font-weight: 600; font-size: .875rem; cursor: pointer; max-width: 12rem;
}
.bar__status { flex: 1; margin: 0; text-align: center; font-size: .875rem; color: var(--muted-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__status.is-dirty { color: #ffd166; font-weight: 600; }
.bar__status.is-ok { color: #7ee2a8; }
.bar__right { position: relative; display: flex; align-items: center; gap: .5rem; }
.bar .rl-btn--ghost { border-color: var(--ink-3); }
.bar .rl-btn--ghost:hover:not(:disabled) { border-color: var(--muted-dark); }
.seg { display: flex; padding: .2rem; border-radius: 99px; background: var(--ink-3); }
.seg__btn { display: grid; place-items: center; width: 2.2rem; height: 2.1rem; border: 0; border-radius: 99px; background: none; color: var(--muted-dark); cursor: pointer; }
.seg__btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.seg__btn.is-on { background: var(--paper); color: var(--ink); }
.menu {
  position: absolute; right: 0; top: calc(100% + .5rem); min-width: 13rem; padding: .4rem;
  background: #fff; color: var(--ink); border-radius: .9rem; box-shadow: 0 1rem 2.5rem -1rem rgb(12 14 26 / .45), 0 0 0 1px rgb(12 14 26 / .06);
}
.menu a, .menu button { display: block; width: 100%; padding: .65rem .8rem; border: 0; border-radius: .6rem; background: none; text-align: left; text-decoration: none; cursor: pointer; font-weight: 500; }
.menu a:hover, .menu button:hover { background: var(--paper-2); }
.menu__who { margin: 0; padding: .55rem .8rem .65rem; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: .3rem; }

/* ---------- Demo strip (demolage only) ---------- */
.demo-strip { flex: none; display: flex; align-items: center; gap: .75rem; padding: .45rem .75rem; background: var(--signal); color: #fff; font-size: .875rem; line-height: 1.3; }
.demo-strip p { flex: 1; min-width: 0; margin: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-strip a { flex: none; display: inline-flex; align-items: center; gap: .35rem; min-height: 2.1rem; padding: .3rem .85rem; border-radius: 99px; font-weight: 700; text-decoration: none; color: inherit; }
.demo-strip__back { background: rgb(255 255 255 / .16); }
.demo-strip__back:hover { background: rgb(255 255 255 / .28); }
.demo-strip__cta { background: #fff; color: var(--ink) !important; }
.demo-strip__cta:hover { background: var(--paper); }
.demo-strip :focus-visible { outline-color: #fff; }
@media (max-width: 720px) {
  .demo-strip { font-size: .8125rem; gap: .5rem; padding: .35rem .5rem; }
  .demo-strip__long { display: none; }
  .demo-strip a { min-height: 1.9rem; padding: .2rem .7rem; }
}
@media (max-width: 720px) { .tip { padding: .45rem .75rem; font-size: .8125rem; } }

/* ---------- Tip ---------- */
.tip { flex: none; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: #e6e7ff; color: var(--ink); font-size: .9rem; }
.tip p { margin: 0 auto; max-width: 60rem; }
.tip__close { flex: none; width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: rgb(12 14 26 / .08); font-size: 1.2rem; line-height: 1; cursor: pointer; }

/* ---------- Preview ---------- */
.stage { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; overflow: hidden; background: var(--paper-2); }
.frame { position: relative; width: 100%; height: 100%; transition: width .45s var(--ease), margin .45s var(--ease), border-radius .45s var(--ease), box-shadow .45s; background: #fff; }
.frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.stage.is-mobile .frame { width: 390px; height: calc(100% - 2.5rem); margin-top: 1.25rem; border-radius: 1.75rem; overflow: hidden; box-shadow: 0 0 0 10px var(--ink), 0 2rem 4rem -1.5rem rgb(12 14 26 / .6); }
.stage.is-loading .frame::after { content: ""; position: absolute; inset: 0; background: rgb(255 255 255 / .6); }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 2rem; background: var(--paper-2); }
.empty h2 { margin: 0 0 .5rem; }

/* ---------- Panels (bottom sheet on phones, dialog on desktop) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgb(12 14 26 / .45); animation: fade .2s; }
.sheet__panel {
  width: 100%; max-height: 88dvh; overflow: auto; padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  background: #fff; border-radius: 1.25rem 1.25rem 0 0; animation: rise .35s var(--ease);
}
@media (min-width: 640px) {
  .sheet { align-items: center; }
  .sheet__panel { width: min(30rem, 92vw); border-radius: 1.25rem; padding: 1.5rem; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(1.5rem); opacity: 0; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.sheet__head h2 { margin: 0; font-size: 1.25rem; }
.sheet__x { width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50%; background: var(--paper-2); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.sheet__lead { color: var(--muted); margin: 0 0 1rem; }
.sheet__msg { min-height: 1.25rem; margin: .5rem 0; font-size: .875rem; color: var(--muted); }
.sheet__msg.is-error { color: var(--bad); font-weight: 600; }
.sheet__foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.sheet__foot .rl-btn--ghost { border-color: var(--line); }
.pic { display: grid; place-items: center; min-height: 9rem; max-height: 16rem; overflow: hidden; border-radius: .9rem; background: var(--paper-2) repeating-conic-gradient(#e2dfd8 0 25%, transparent 0 50%) 0 0 / 18px 18px; }
.pic img { max-width: 100%; max-height: 16rem; object-fit: contain; }
.drop { position: relative; display: block; margin-top: .75rem; padding: 1rem; border: 1.5px dashed var(--muted); border-radius: .9rem; text-align: center; cursor: pointer; transition: border-color .2s, background-color .2s; }
.drop:hover, .drop.is-over { border-color: var(--signal); background: #f1f1ff; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop small { color: var(--muted); }
.drop:focus-within { outline: 3px solid var(--signal); outline-offset: 2px; }
.field { display: grid; gap: .3rem; margin-top: .75rem; font-weight: 600; font-size: .9rem; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .door__form input { width: 100%; padding: .7rem .85rem; border: 1.5px solid var(--line); border-radius: .7rem; background: #fff; font-weight: 400; font-size: 1rem; }
.field input:focus, .door__form input:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 3px rgb(61 61 255 / .18); }
.hist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.hist li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.hist b { display: block; }
.hist small { color: var(--muted); }
.hist .rl-btn--ghost { border-color: var(--line); min-height: 2.1rem; padding: .4rem .85rem; }
.hist__empty { color: var(--muted); padding: 1rem 0; }
.help { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .6rem; }
.help__mark { background: rgb(255 200 0 / .35); outline: 2px solid var(--amber); border-radius: 2px; padding: 0 .2rem; }
kbd { font-family: inherit; font-size: .8em; padding: .1rem .35rem; border-radius: .3rem; background: var(--paper-2); border: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); z-index: 40; translate: -50% 0;
  max-width: min(32rem, calc(100vw - 2rem)); padding: .8rem 1.1rem; border-radius: .9rem;
  background: var(--ink); color: var(--paper); font-weight: 600; box-shadow: 0 1rem 2rem -1rem rgb(12 14 26 / .6);
  animation: rise .35s var(--ease);
}
.toast.is-ok::before { content: "✓"; display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; margin-right: .55rem; border-radius: 50%; background: var(--ok); color: #fff; font-size: .8rem; }
.toast.is-error { background: var(--bad); }

/* ---------- Narrow screens: icons only, status on its own row ---------- */
@media (max-width: 900px) {
  .bar { flex-wrap: wrap; row-gap: .35rem; }
  .bar__status { order: 3; flex-basis: 100%; text-align: left; font-size: .8rem; }
  .bar__right { margin-left: auto; }
  .bar .lbl { display: none; }
  .bar .rl-btn--ghost { width: 2.5rem; padding: 0; }
  .bar__site { max-width: 8rem; }
  .seg { display: none; }
}
@media (max-width: 480px) {
  .bar__mode { display: none; }
  .bar__pages select { max-width: 8.5rem; }
}

/* ---------- Login + account creation ---------- */
.rl-door { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; padding: 1.5rem; background: var(--ink); }
.door { width: min(26rem, 100%); padding: 2rem 1.75rem; border-radius: 1.5rem; background: var(--paper); }
.door__brand { display: flex; align-items: center; gap: .55rem; margin: 0 0 1.5rem; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.door__brand svg { fill: var(--ink); }
.door__brand .half { fill: var(--signal); }
.door h1 { margin: 0 0 .4rem; font-size: 1.9rem; line-height: 1.1; letter-spacing: -.02em; }
.door__lead { margin: 0 0 1.5rem; color: var(--muted); }
.door__form { display: grid; gap: .9rem; }
.door__form label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.door__form small { font-weight: 400; color: var(--muted); }
.door__form .rl-btn { min-height: 3rem; margin-top: .4rem; font-size: 1rem; }
.door__msg { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: .7rem; font-size: .9rem; font-weight: 600; }
.door__msg.is-error { background: #fbe4e1; color: var(--bad); }
.door__msg.is-ok { background: #def4e6; color: var(--ok); }
.door__form .door__msg { margin: 0; }
.door__help { margin: 1.25rem 0 0; font-size: .875rem; color: var(--muted); }
.door__help a, .door__foot a { color: inherit; font-weight: 600; }
.door__foot { margin: 1.25rem 0 0; font-size: .8rem; color: var(--muted-dark); }

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