@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700&family=Rubik:wght@400;500;600;700&display=swap');

:root {
  --font-hud: 'Outfit', ui-sans-serif, sans-serif;
  --font-body: 'Rubik', ui-sans-serif, sans-serif;
  --bg: #0b0b0d;
  --panel: #15151a;
  --panel-2: #1c1c23;
  --amber: #f59e0b;
  --amber-dim: #b9770a;
  --amber-glow: rgba(245,158,11,.18);
  --text: #ececf1;
  --muted: #8a8a99;
  --border: #26262e;
  --border-glow: rgba(245,158,11,.13);
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --orange: #fb923c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Fit-to-screen lock: nothing on this page should ever be wider than the
   viewport. Without this, any element that's a few px too wide (the tab bar
   on a narrow phone, a long unbroken word) makes the WHOLE page horizontally
   scrollable, which drags fixed/sticky elements out of place. */
html, body { overflow: hidden; max-width: 100vw; overscroll-behavior: none; }
html { height: 100%; height: 100dvh; background: var(--bg); }
body {
  height: 100%; height: 100dvh; margin: 0;
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  display: flex; flex-direction: column;
  background: var(--bg);
}
/* iOS Safari auto-zooms the whole page on focus of any input/textarea with a
   computed font-size under 16px — this is what caused the composer "zoom in
   and lose the chat log" behavior. Every real input on the page gets 16px. */
input, textarea, select { font-size: 16px; }
/* ambient glow blobs behind everything */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 15% 20%, rgba(245,158,11,.07) 0%, transparent 65%),
    radial-gradient(ellipse 55% 60% at 85% 75%, rgba(180,83,9,.05) 0%, transparent 65%),
    radial-gradient(ellipse 40% 35% at 50% 50%, rgba(245,158,11,.03) 0%, transparent 60%);
  animation: float-blobs 18s ease-in-out infinite alternate;
}
@keyframes float-blobs {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-8px, 6px); }
  66%  { transform: translate(5px, -4px); }
  100% { transform: translate(-3px, 8px); }
}
.ti { width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex: none; }

/* ---- header ---- */
/* Fixed, not sticky/in-flow — the header and composer are the app's chrome
   and must never move. Only #chat/.view (see below) scrolls. */
.bar {
  padding: calc(env(safe-area-inset-top) + 11px) 14px 11px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--border-glow);
  background: rgba(11,11,13,.68);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: 0 1px 0 rgba(245,158,11,.06), inset 0 1px 0 rgba(255,255,255,.03);
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  max-width: 100vw;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 14px var(--amber), 0 0 28px rgba(245,158,11,.4); flex: none; animation: pulse-dot 3s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { opacity:1; box-shadow: 0 0 14px var(--amber), 0 0 28px rgba(245,158,11,.4); } 50% { opacity:.7; box-shadow: 0 0 8px var(--amber); } }
.app-version { font-family: var(--font-hud); font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .3px; margin-left: 2px; }
.tabs {
  display: flex; gap: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 3px;
  min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none; background: none; color: var(--muted);
  font-family: var(--font-hud); font-weight: 500; font-size: 12px; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 9px;
  transition: color .15s, background .15s;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
}
.tab.active { background: var(--amber); color: #1a1205; box-shadow: 0 0 10px rgba(245,158,11,.5); }
/* .bar has two trailing icon buttons (quota + new-chat) — only the first
   (quota-btn) should absorb the leftover flex space, so they sit adjacent at
   the right edge instead of splitting the gap between them. */
.bar #new-chat { margin-left: 0; }
.quota-btn.iconbtn { position: relative; }
.iconbtn {
  margin-left: auto; width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s, border-color .15s;
  cursor: pointer;
}
.iconbtn:active { transform: scale(.92); }
.iconbtn .ti { width: 20px; height: 20px; }

/* ---- views ---- */
.view {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  /* 68px klarerte bare .bar. Innboksen er nå ogsa fast (~77px), sa toppen ma
     klarere begge — ellers starter alt innhold under fangstfeltet. */
  padding: calc(env(safe-area-inset-top) + 145px) 16px calc(env(safe-area-inset-bottom) + 78px);
  position: relative; z-index: 1;
}
/* Én regel for alt som skjules med `hidden`-attributtet.
 *
 * Her sto det tidligere en liste over fem id-er: #chat, #dash, #history,
 * #plans, #vault. Den måtte vedlikeholdes hver gang noe nytt fikk en egen
 * `display`, og 2026-08-14 gikk det galt to steder samtidig:
 *
 *   .meny      { display: flex }   → hamburgermenyen kunne aldri lukkes
 *   #dashbord  { display: flex }   → dashbordet lå permanent over alt annet
 *
 * `hidden` er bare en regel i nettleserens egen stilark med minimal
 * spesifisitet, så enhver `display` fra oss slår den ut. Elementene fikk
 * riktig `hidden`-attributt hele tiden — de nektet bare å forsvinne.
 *
 * !important fordi denne skal vinne over alt, uansett hvor spesifikk
 * regelen som satte `display` er. En liste man må huske å oppdatere, blir
 * ikke oppdatert. */
[hidden] { display: none !important; }
#chat { display: flex; flex-direction: column; gap: 12px; }
#history { display: flex; flex-direction: column; gap: 10px; }
#plans { display: flex; flex-direction: column; gap: 10px; }

/* ---- Jarvis intro (new/empty chat) ---- */
.jarvis-intro {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; padding: 24px; min-height: 0;
  animation: jarvis-intro-in .5s cubic-bezier(.22,1,.36,1) both;
}
@keyframes jarvis-intro-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.jarvis-orb-wrap {
  position: relative; width: 128px; height: 128px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  filter: drop-shadow(0 0 18px rgba(245,158,11,.55)) drop-shadow(0 0 40px rgba(245,158,11,.25));
  animation: jarvis-orb-breathe 2.6s ease-in-out infinite;
}
.jarvis-orb-wrap canvas { display: block; }
@keyframes jarvis-orb-breathe {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(245,158,11,.5)) drop-shadow(0 0 40px rgba(245,158,11,.22)); }
  50%      { filter: drop-shadow(0 0 26px rgba(245,158,11,.7)) drop-shadow(0 0 55px rgba(245,158,11,.32)); }
}
.jarvis-intro-text {
  font-size: 15px; color: var(--text); max-width: 320px; line-height: 1.5; min-height: 1.5em;
}
.jarvis-intro-text .caret {
  display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--amber); animation: jarvis-caret-blink .9s step-end infinite;
}
@keyframes jarvis-caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .jarvis-orb-wrap, .jarvis-intro-text .caret { animation: none; }
}

/* ---- messages ---- */
.msg {
  max-width: 86%; padding: 11px 14px; border-radius: 18px;
  white-space: pre-wrap; word-wrap: break-word;
  animation: msg-pop .22s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes msg-pop {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(170deg, var(--amber), var(--amber-dim));
  color: #1a1205; font-weight: 600; border-bottom-right-radius: 5px;
  box-shadow: 0 4px 20px rgba(245,158,11,.25);
}
.msg.jarvis {
  align-self: flex-start; background: var(--panel);
  border: 1px solid var(--border); border-bottom-left-radius: 5px;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px; border-radius: 14px;
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3);
  color: var(--amber); font-weight: 600; cursor: pointer;
  transition: background .15s, transform .15s;
}
.chip:active { transform: scale(.97); background: rgba(245,158,11,.18); }

.working { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ── saved plan toast in chat ── */
.plan-toast {
  align-self: flex-start; display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-radius: 14px;
  background: rgba(96,165,250,.1); border: 1px solid rgba(96,165,250,.3);
  color: var(--blue); font-weight: 600; font-size: 14px;
  animation: msg-pop .22s cubic-bezier(.34,1.56,.64,1) both;
  cursor: pointer;
}

/* ---- report card ---- */
.report { width: 100%; max-width: 100%; background: var(--panel-2); padding: 16px; border-radius: 18px; box-shadow: 0 2px 16px rgba(0,0,0,.35); }
.rep-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.rep-head h3 { margin: 0; font-size: 18px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .4px; white-space: nowrap; }
.badge.kill { background: rgba(248,113,113,.16); color: var(--red); }
.badge.go { background: rgba(52,211,153,.16); color: var(--green); }
.badge.pivot { background: rgba(245,158,11,.16); color: var(--amber); }
.why { color: #cfcfe0; margin: 6px 0 14px; }
.swot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.swot { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px; border-left-width: 3px; min-width: 0; }
.swot.s { border-left-color: var(--green); } .swot.w { border-left-color: var(--red); }
.swot.o { border-left-color: var(--blue); } .swot.t { border-left-color: var(--orange); }
.swot h4 { margin: 0 0 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.swot ul { margin: 0; padding-left: 15px; font-size: 13.5px; }
.swot li { margin: 2px 0; overflow-wrap: anywhere; }
.block { margin-top: 12px; }
.block h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 5px; font-size: 14px; color: var(--amber); }
.block p { margin: 0; }
.block ol, .block ul { margin: 0; padding-left: 18px; }
.block.test { background: rgba(245,158,11,.06); border: 1px solid rgba(245,158,11,.2); border-radius: 12px; padding: 11px; }
.eff { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.decide { display: flex; gap: 8px; margin-top: 14px; }
.dec { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border-radius: 12px; font: inherit; font-weight: 700; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; transition: transform .12s; }
.dec.go { border-color: rgba(52,211,153,.4); color: var(--green); }
.dec.kill { border-color: rgba(248,113,113,.4); color: var(--red); }
.dec:active { transform: scale(.97); }
.decided { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; margin-top: 14px; }
.decided.go { color: var(--green); } .decided.kill { color: var(--red); }

.followup { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.followup-input { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; font: inherit; font-size: 13px; color: var(--text); outline: none; resize: none; transition: border-color .2s; }
.followup-input:focus { border-color: var(--amber-dim); box-shadow: 0 0 0 3px rgba(245,158,11,.08); }
.followup-send { width: 40px; height: 40px; flex: none; border: none; border-radius: 12px; background: linear-gradient(170deg, var(--amber), var(--amber-dim)); color: #1a1205; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 14px rgba(245,158,11,.25); }
.followup-send:disabled { opacity: .5; cursor: default; }

/* ---- dashboard ---- */
#dash { display: flex; flex-direction: column; gap: 10px; }
.dash-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; transition: border-color .15s, transform .12s; }
.dash-card:hover { border-color: var(--border-glow); }
.dash-card:active { transform: scale(.99); }
.dash-card b { display: block; }
.hint { color: var(--muted); text-align: center; padding: 30px 10px; }

/* ---- overlay ---- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(8,8,10,.93);
  backdrop-filter: blur(6px) saturate(160%);
  -webkit-backdrop-filter: blur(6px) saturate(160%);
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 54px) 16px calc(env(safe-area-inset-bottom) + 16px);
}
#overlay-close { position: fixed; top: calc(env(safe-area-inset-top) + 10px); right: 14px; margin: 0; z-index: 21; }

/* ---- composer ---- */
.composer {
  display: flex; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-glow);
  background: rgba(11,11,13,.82);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: 0 -1px 0 rgba(245,158,11,.05);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  max-width: 100vw;
}
.composer textarea {
  flex: 1; resize: none; background: var(--panel); color: var(--text);
  border: 1px solid #2c2c36; border-radius: 16px; padding: 11px 14px;
  font: inherit; font-size: 16px; max-height: 140px; outline: none;
  transition: border-color .2s;
}
.composer textarea:focus { border-color: var(--amber-dim); box-shadow: 0 0 0 3px rgba(245,158,11,.08); }
/* "Jarvis is listening" — a slow breathing amber glow while there's text to send. */
.composer textarea.is-listening {
  border-color: rgba(245,158,11,.5);
  animation: jarvis-listening-glow 2.4s ease-in-out infinite;
}
@keyframes jarvis-listening-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(245,158,11,0); }
  50%      { box-shadow: 0 0 14px rgba(245,158,11,.35); }
}
@media (prefers-reduced-motion: reduce) {
  .composer textarea.is-listening { animation: none; box-shadow: 0 0 10px rgba(245,158,11,.25); }
}
/* Research running for this session — composer stays usable, just visibly in "queue mode". */
.composer.queue-mode textarea { border-color: rgba(96,165,250,.45); }
.queued-note {
  align-self: center; font-size: 12px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px;
  animation: msg-pop .22s cubic-bezier(.34,1.56,.64,1) both;
}
.busy-badge { color: var(--blue); }
.composer button#send {
  width: 48px; border: none; border-radius: 16px;
  background: linear-gradient(170deg, var(--amber), var(--amber-dim));
  color: #1a1205; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(245,158,11,.3);
  transition: transform .12s, box-shadow .12s;
  cursor: pointer;
}
.composer button#send .ti { width: 22px; height: 22px; }
.composer button#send:active { transform: scale(.93); box-shadow: 0 2px 8px rgba(245,158,11,.2); }
body.dash-mode .composer, body.history-mode .composer, body.plans-mode .composer, body.research-mode .composer, body.map-mode .composer { display: none; }

/* ── system map ── */
#map { padding: 0; overflow: hidden; }
.systemmap-wrap { position: absolute; inset: 0; }
.systemmap-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.map-recenter-btn {
  position: absolute; bottom: 16px; right: 16px; display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border); background: rgba(21,21,26,.85);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ── research tab: live quota + active jobs ── */
.research-jobs { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.research-jobs h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; color: var(--amber); }
.research-jobs h4 .ti { width: 18px; height: 18px; }
.quota-popover {
  position: fixed; z-index: 30;
  top: calc(env(safe-area-inset-top) + 58px); right: 14px; width: 240px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 12px 32px rgba(0,0,0,.4);
  animation: msg-pop .18s cubic-bezier(.34,1.56,.64,1) both;
}
.quota-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.quota-row span:last-child { white-space: nowrap; flex: none; }
.quota-track { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.quota-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); transition: width .5s ease; }
.quota-reset { margin-top: 4px; }
.research-job-card { padding: 11px 13px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color .15s, transform .12s; margin-bottom: 10px; }
.research-job-card:last-child { margin-bottom: 0; }
.research-job-card:active { transform: scale(.99); }
.research-job-card:hover { border-color: var(--border-glow); }
.research-job-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 8px; }
.research-job-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── session history cards ── */
.session-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; transition: border-color .15s, transform .12s; }
.session-card:active { transform: scale(.99); }
.session-card.active-session { border-color: var(--amber-dim); background: rgba(245,158,11,.05); }
.session-info { flex: 1; min-width: 0; }
.session-info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-del { margin-left: 0; flex: none; color: var(--muted); }
.session-del:hover { color: var(--red); border-color: rgba(248,113,113,.4); }

/* ── multiple choice buttons ── */
.choices { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; padding: 0 4px; }
.choice-groups { display: flex; flex-direction: column; gap: 12px; align-self: flex-start; max-width: 92%; }
.choice-group { display: flex; flex-direction: column; gap: 6px; }
.choice-group-q { font-size: 13px; color: var(--muted); padding: 0 4px; }
.choice-btn {
  padding: 8px 15px; border-radius: 20px; font: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(245,158,11,.45); background: rgba(245,158,11,.07); color: var(--amber);
  cursor: pointer; transition: background .12s, transform .1s;
}
.choice-btn:active { transform: scale(.96); background: rgba(245,158,11,.18); }

/* ── SSE progress bar ── */
.progress-wrap { align-self: flex-start; width: 86%; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; animation: msg-pop .22s cubic-bezier(.34,1.56,.64,1) both; }
.progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.progress-step { color: var(--text); }
.progress-timer { color: var(--amber); font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.progress-track { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); transition: width .5s ease; }
.progress-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px 4px 6px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; text-decoration: none; max-width: 140px;
}
.source-chip img { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.source-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── folder badges and filters ── */
.folder-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin: 3px 0 6px; }
.folder-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.folder-chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 20px; font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer; transition: border-color .15s, color .15s; }
.folder-chip.active-folder { border-color: var(--amber-dim); color: var(--amber); background: rgba(245,158,11,.1); }
.folder-editor { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; flex-wrap: wrap; }
.folder-edit-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 5px 11px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; transition: border-color .15s, color .15s; }
.folder-edit-btn:hover { border-color: var(--amber-dim); color: var(--amber); }

/* ── PLANS TAB ─────────────────────────────────────────────────────────────── */

/* status filter chips */
.plan-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.plan-filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 20px; font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.plan-filter-chip.active { border-color: var(--amber-dim); color: var(--amber); background: rgba(245,158,11,.1); }

/* plan card */
.plan-card {
  padding: 14px 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  cursor: pointer; transition: border-color .15s, transform .12s, box-shadow .15s;
  animation: card-in .25s cubic-bezier(.34,1.44,.64,1) both;
}
.plan-card:hover { border-color: var(--border-glow); box-shadow: 0 4px 20px rgba(245,158,11,.07); }
.plan-card:active { transform: scale(.99); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.plan-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.plan-card-head b { font-size: 15px; flex: 1; min-width: 0; }

/* score circle */
.plan-score {
  min-width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  border: 2px solid var(--border);
}
.plan-score.high { border-color: var(--green); color: var(--green); background: rgba(52,211,153,.1); }
.plan-score.mid  { border-color: var(--amber); color: var(--amber); background: rgba(245,158,11,.1); }
.plan-score.low  { border-color: var(--muted); color: var(--muted); }

.plan-desc { margin: 2px 0 10px; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* dual progress bars */
.plan-bars { display: flex; flex-direction: column; gap: 5px; }
.plan-bar-row { display: flex; align-items: center; gap: 8px; }
.plan-bar-label { width: 62px; font-size: 11px; color: var(--muted); font-weight: 600; flex: none; }
.plan-bar-track { flex: 1; height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.plan-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); transition: width .6s cubic-bezier(.34,1.3,.64,1); }
.plan-bar-fill.blue { background: linear-gradient(90deg, #3b82f6, var(--blue)); }

/* status badge */
.plan-status { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; letter-spacing: .3px; margin-bottom: 8px; display: inline-flex; align-items: center; gap: 4px; }
.plan-status.ide        { background: rgba(245,158,11,.14); color: var(--amber); }
.plan-status.planlegging{ background: rgba(96,165,250,.14); color: var(--blue); }
.plan-status.klar       { background: rgba(52,211,153,.14); color: var(--green); }
.plan-status.gjennomforer{ background: rgba(251,146,60,.14); color: var(--orange); }
.plan-status.fullfort   { background: rgba(134,239,172,.1); color: #86efac; }

/* plan overlay */
.plan-overlay-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.plan-overlay-section h4 { margin: 0 0 10px; font-size: 14px; color: var(--amber); display: flex; align-items: center; gap: 6px; }
.plan-actions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plan-action-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel); border-radius: 10px; border: 1px solid var(--border); font-size: 14px; cursor: pointer; transition: background .12s; }
.plan-action-item.done { opacity: .5; text-decoration: line-through; }
.plan-action-item input[type=checkbox] { accent-color: var(--amber); width: 16px; height: 16px; flex: none; }
.plan-add-action { display: flex; gap: 6px; margin-top: 8px; }
.plan-add-action input { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font: inherit; color: var(--text); outline: none; font-size: 16px; }
.plan-add-action input:focus { border-color: var(--amber-dim); }
.plan-add-action button { padding: 8px 14px; border-radius: 10px; background: rgba(245,158,11,.15); border: 1px solid var(--amber-dim); color: var(--amber); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; }

.plan-meta-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.plan-meta-btn { flex: 1; min-width: 120px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border-radius: 12px; font: inherit; font-weight: 700; font-size: 14px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; transition: border-color .15s, color .15s, transform .1s; }
.plan-meta-btn:active { transform: scale(.97); }
.plan-meta-btn.chat-btn { border-color: rgba(245,158,11,.4); color: var(--amber); }
.plan-meta-btn.del-btn  { border-color: rgba(248,113,113,.3); color: var(--red); }

.plan-notes { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; color: var(--text); outline: none; resize: vertical; min-height: 80px; font-size: 16px; }
.plan-notes:focus { border-color: var(--amber-dim); }

.plan-slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.plan-slider-row label { font-size: 13px; color: var(--muted); min-width: 100px; }
.plan-slider-row input[type=range] { flex: 1; accent-color: var(--amber); }
.plan-slider-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }

.plan-status-select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font: inherit; color: var(--text); font-size: 14px; width: 100%;
  outline: none; cursor: pointer;
}
.plan-status-select:focus { border-color: var(--amber-dim); }

/* empty plans state */
.plans-empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.plans-empty .emoji { font-size: 48px; margin-bottom: 12px; }
.plans-empty h3 { margin: 0 0 8px; color: var(--text); }

/* ---- second-brain vault ---- */
#vault { padding: 0; display: flex; flex-direction: column; }
.vault-wrap { flex: 1; display: flex; min-height: 0; }
.vault-sidebar { width: 120px; flex: none; overflow-y: auto; border-right: 1px solid var(--border); padding: 8px 4px; display: flex; flex-direction: column; gap: 2px; }
.vault-file-btn { display: flex; align-items: center; gap: 6px; background: transparent; border: none; color: var(--muted); font-size: 11px; text-align: left; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.vault-file-btn svg { width: 14px; height: 14px; flex: none; }
.vault-file-btn.active { color: var(--text); background: var(--panel-2); }
.vault-content { flex: 1; min-width: 0; overflow-y: auto; padding: 12px 14px; }
.vault-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.vault-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 8px; }
.vault-btn svg { width: 14px; height: 14px; }
.vault-btn.primary { color: var(--amber); border-color: rgba(245,158,11,.4); }
.vault-save-msg { font-size: 11px; color: var(--muted); }
.vault-note-body { font-size: 13px; line-height: 1.55; color: var(--text); }
.vault-h { color: var(--amber); margin: 12px 0 6px; font-size: 13px; }
.vault-h:first-child { margin-top: 0; }
.vault-p { margin: 0 0 8px; color: var(--muted); }
.vault-li { margin: 0 0 4px 4px; color: var(--muted); }
.vault-check { display: flex; align-items: flex-start; gap: 6px; margin: 0 0 6px; color: var(--muted); }
.vault-check svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.vault-check.done span { text-decoration: line-through; opacity: .6; }
.vault-empty { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.vault-editor { width: 100%; min-height: 260px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-family: ui-monospace, monospace; font-size: 16px; line-height: 1.5; padding: 10px; resize: vertical; outline: none; }
.vault-editor:focus { border-color: var(--amber-dim); }

/* --- Idé-innboks (2026-08-02) --- */
/* Festet rett under .bar, som er position:fixed. Lå innboksen i normal flyt
   ble den DEKKET av baren — send-knappen var bokstavelig talt utilgjengelig
   (elementFromPoint på knappens senter traff .bar). Funnet 2026-08-02 ved å
   drive PWA-en i mobil-viewport; ingen test fanget det.
   Et fangstfelt skal dessuten alltid være innen rekkevidde, ikke scrolle bort. */
.inbox {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 61px);
  left: 0; right: 0;
  z-index: 4;
  padding: 10px 12px;
  background: rgba(11,11,13,.82);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border-glow);
}
.inbox-form { display: flex; gap: 8px; align-items: flex-end; }
.inbox-text {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(245,158,11,0.28);
  border-radius: 12px;
  color: #f4f4f5;
  /* 16px er ikke tilfeldig: mindre enn det, og iOS Safari zoomer inn på fokus. */
  font-size: 16px;
  line-height: 1.4;
  padding: 11px 13px;
  resize: none;
  font-family: inherit;
  max-height: 160px;
}
.inbox-text:focus { outline: none; border-color: rgba(245,158,11,0.65); }
.inbox-text::placeholder { color: rgba(255,255,255,0.3); }
.inbox-send {
  background: rgba(245,158,11,0.16);
  border: 1px solid rgba(245,158,11,0.4);
  color: #f59e0b;
  border-radius: 12px;
  width: 46px; height: 46px; flex: 0 0 46px;
  font-size: 20px; cursor: pointer;
}
.inbox-send:active { background: rgba(245,158,11,0.3); }
.inbox-flash {
  margin-top: 7px; font-size: 13px; color: #f59e0b;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.inbox-flash--in { opacity: 1; transform: translateY(0); }
.inbox-flash--error { color: #fca5a5; }
@media (prefers-reduced-motion: reduce) {
  .inbox-flash { transition: none; }
}
