:root {
  --bg: #F6F4EF; --card: #fff; --ink: #1C1B19; --ink2: #55524C; --muted: #6B6760;
  --line: #E3DFD6; --line2: #D6D2C8; --soft: #F1EEE8; --accent: #2F5D50; --accent-d: #1E3F36;
  --accent-l: #E4ECE8; --danger: #A63A24; --danger-l: #FBECE8; --warn-l: #FBEEDC; --warn: #8A4B12;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
svg { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.splash, .center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 40px 28px; text-align: center; }
.logo { width: 88px; height: 88px; border-radius: 24px; background: var(--accent) url(/icons/icon-192.png) center/cover; }
.center h1 { font-size: 34px; margin: 0; letter-spacing: -.02em; }
.center p { margin: 0; color: var(--ink2); line-height: 1.5; }

header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(14px + var(--safe-t)) 18px 10px; background: var(--bg); }
header.top h1 { flex: 1; margin: 0; font-size: 22px; letter-spacing: -.01em; }
.avatar { width: 40px; height: 40px; border-radius: 20px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; text-decoration: none; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; background: transparent; border: none; }

main { flex: 1; padding: 4px 18px calc(96px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line); padding: 6px 8px calc(8px + var(--safe-b)); display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); max-width: 560px; margin: 0 auto; }
nav.bottom a { height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); text-decoration: none; }
nav.bottom a.on { color: var(--accent); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
.btn { height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line2); background: #fff; font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.soft { background: var(--accent-l); border-color: var(--accent-l); color: var(--accent-d); }
.btn.sm { height: 38px; font-size: 14px; border-radius: 10px; padding: 0 12px; }
.btn.block { width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: #E9E6DF; border-radius: 12px; padding: 4px; }
.seg button { height: 40px; border: none; border-radius: 9px; background: transparent; color: var(--ink2); font-size: 14px; font-weight: 500; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px #0001; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line2); background: #fff; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.banner { display: flex; align-items: center; gap: 12px; background: var(--accent-l); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.4; }
.banner span { flex: 1; }
.banner .x { border: none; background: transparent; font-size: 20px; width: 32px; height: 32px; color: var(--accent-d); }

.row { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.stage { position: relative; height: min(34dvh, 280px); border-radius: 12px; background: var(--soft); display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; user-select: none; }
.stage.tall { height: min(62dvh, 540px); }
.stage img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.stage .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 22px; border: none; background: #ffffffd9; font-size: 24px; line-height: 1; box-shadow: 0 1px 3px #0002; }
.stage .prev { left: 6px; } .stage .next { right: 6px; }
.rowfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 24px 16px; line-height: 1.5; }

.tile { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.tile .ph { aspect-ratio: 1; border-radius: 10px; background: var(--soft); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile .ph img { width: 100%; height: 100%; object-fit: contain; }
.tile .meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.tile .nm { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .ct { font-size: 12px; color: var(--muted); }
.del { width: 40px; height: 40px; border-radius: 10px; border: none; background: var(--danger-l); color: var(--danger); display: flex; align-items: center; justify-content: center; flex: none; }

.bigbtn { height: 96px; border-radius: 18px; display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 17px; font-weight: 500; border: 1px solid var(--line2); background: #fff; cursor: pointer; }
.bigbtn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.bigbtn input { display: none; }
.cropwrap { height: min(46dvh, 420px); border-radius: 16px; overflow: hidden; background: #222; }
.cropwrap img { max-width: 100%; }
label.lbl { font-size: 14px; font-weight: 500; }
input.txt { height: 48px; border-radius: 12px; border: 1px solid var(--line2); padding: 0 14px; font-size: 16px; background: #fff; width: 100%; }

.fav { display: flex; align-items: center; gap: 10px; }
.fav .th { width: 64px; height: 64px; border-radius: 10px; background: var(--soft); overflow: hidden; flex: none; }
.fav .th img { width: 100%; height: 100%; object-fit: contain; }
.fav .lbl2 { flex: 1; font-size: 13px; line-height: 1.35; min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.bars { height: 110px; display: flex; align-items: flex-end; gap: 4px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; font-size: 10px; color: var(--muted); }
.bars i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: var(--accent); min-height: 2px; }
.q { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.q .t { display: flex; justify-content: space-between; gap: 8px; }
.q .track { height: 8px; border-radius: 4px; background: #EEEAE2; overflow: hidden; }
.q .fill { height: 8px; border-radius: 4px; background: var(--accent); }
.q .fill.hot { background: var(--danger); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); }
table.t td.n, table.t th.n { text-align: right; white-space: nowrap; }
.tablebox { overflow-x: auto; }
.badge { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 7px; }
.badge.red { background: var(--danger-l); color: var(--danger); }
.badge.grn { background: var(--accent-l); color: var(--accent-d); }
.badge.warn { background: var(--warn-l); color: var(--warn); }
.urow { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.urow .ini { width: 38px; height: 38px; border-radius: 19px; background: var(--accent-l); color: var(--accent-d); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.urow .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.urow .em { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: #000d; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox button { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; width: 44px; height: 44px; border-radius: 22px; border: none; background: #fff; font-size: 22px; }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#offline { position: sticky; top: 0; z-index: 20; background: var(--warn-l); color: var(--warn); font-size: 13px; text-align: center; padding: calc(6px + var(--safe-t)) 12px 6px; }
.spin { text-align: center; color: var(--muted); padding: 30px; }

.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; min-height: 44px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.cutprev { position: fixed; inset: 0; z-index: 55; background: var(--bg); display: flex; flex-direction: column; gap: 10px; padding: calc(18px + var(--safe-t)) 18px calc(18px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.cutprev .cp-img { flex: 1; min-height: 0; border-radius: 16px; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: #fff conic-gradient(#EEEAE2 25%, #fff 0 50%, #EEEAE2 0 75%, #fff 0) 0 0 / 24px 24px; }
.cutprev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cutprev p { margin: 0; text-align: center; color: var(--ink2); }

.viewer { position: fixed; inset: 0; z-index: 30; background: #EDEAE4; overflow: hidden; }
.vstage { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.vcontent { width: 100%; height: 100%; box-sizing: border-box; padding: calc(72px + var(--safe-t)) 8px calc(150px + var(--safe-b)); transform-origin: 0 0; will-change: transform; }
.vcontent svg { width: 100%; height: 100%; display: block; }
.vtop { position: absolute; top: calc(14px + var(--safe-t)); left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.vtop > * { pointer-events: auto; }
.vbtn { width: 44px; height: 44px; border-radius: 22px; border: none; background: #ffffffE6; font-size: 26px; line-height: 1; box-shadow: 0 1px 4px #00000026; }
.vseg { display: flex; gap: 2px; background: #ffffffE6; border-radius: 22px; padding: 3px; box-shadow: 0 1px 4px #00000026; }
.vseg button { height: 38px; padding: 0 14px; border-radius: 19px; border: none; background: transparent; color: var(--ink2); font-size: 14px; font-weight: 500; }
.vseg button.on { background: var(--ink); color: #fff; }
.vbottom { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.vbottom .vseg { pointer-events: auto; }
.vzoom { pointer-events: auto; display: flex; align-items: center; gap: 2px; background: #ffffffE6; border-radius: 24px; padding: 3px; box-shadow: 0 1px 4px #00000026; }
.vzoom button { width: 44px; height: 44px; border-radius: 22px; border: none; background: transparent; font-size: 24px; }
.vzoom span { min-width: 56px; text-align: center; font-size: 14px; font-weight: 500; }
.vzoom .fit { width: auto; padding: 0 14px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 500; }
body:has(.viewer) #toast { bottom: auto; top: calc(70px + var(--safe-t)); }
.vsave { height: 44px; padding: 0 14px; border-radius: 22px; border: none; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 1px 4px #00000026; }
.vtop .vseg button { padding: 0 12px; }

/* --- Garderobe 2: søk, oversikt, favorittplagg, skjema --- */
.searchbar { display: flex; gap: 8px; }
.searchbar .txt { flex: 1; min-width: 0; }
.btn.ai { background: #3F2D86; border-color: #3F2D86; color: #fff; }
.ainote { color: #3F2D86; display: flex; align-items: center; gap: 6px; margin-top: -6px; }
.chip .cnt { color: var(--muted); font-size: 12px; }
.chip.on .cnt { color: #ffffffb3; }
.chip.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.plain { border: none; background: transparent; color: var(--accent); }
.chip .dot { width: 16px; height: 16px; border-radius: 8px; border: 1px solid #00000026; display: inline-block; }
details.overview { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
details.overview summary { font-weight: 700; font-size: 14px; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
details.overview[open] summary { margin-bottom: 4px; }
details.overview .chips { margin: 4px 0 10px; }
.tile { position: relative; }
.star { position: absolute; top: 12px; right: 12px; z-index: 2; width: 40px; height: 40px; border-radius: 20px; border: none; background: #ffffffE6; color: #B7791F; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px #0002; }
.star.on svg { fill: #E0A526; }
.star.big { width: auto; height: 40px; padding: 0 14px; gap: 6px; font-size: 14px; font-weight: 600; color: #7A4E0B; background: #FFF8E8; border: 1px solid #E7D3A8; box-shadow: none; }
.tile .note { font-size: 12px; color: var(--ink2); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.formbox { display: flex; flex-direction: column; gap: 10px; }
.formbox .lbl, span.lbl { font-size: 14px; font-weight: 700; }
.aitag { font-size: 11px; font-weight: 700; color: #3F2D86; background: #EEE9FB; border-radius: 6px; padding: 2px 6px; margin-left: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 36px; height: 36px; border-radius: 18px; border: 1px solid #00000026; }
.sw.on { border: 2px solid #fff; box-shadow: 0 0 0 2px var(--ink); }
.sizes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.sizes button { height: 42px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-size: 14px; font-weight: 600; }
.sizes button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.stepper { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.stepper > span { font-size: 12px; color: var(--muted); }
.stepper > div { display: flex; align-items: center; justify-content: space-between; }
.stepper button { width: 42px; height: 42px; border-radius: 21px; border: none; background: var(--soft); font-size: 20px; }
.stepper b { font-size: 22px; }
textarea.area { height: auto; padding: 10px 14px; line-height: 1.4; resize: vertical; font: inherit; }
.uphead { display: flex; gap: 12px; align-items: center; }
.upimg { width: 104px; height: 104px; flex: none; border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: #fff conic-gradient(#EEEAE2 25%, #fff 0 50%, #EEEAE2 0 75%, #fff 0) 0 0 / 16px 16px; border: 1px solid var(--line); }
.upimg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.banner.ai { background: #EEE9FB; color: #3F2D86; }
.banner.warn { background: var(--warn-l); color: var(--warn); }
.stage.small { height: 120px; }
.card.col { display: flex; flex-direction: column; gap: 10px; }
.rowhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge.ai { background: #EEE9FB; color: #3F2D86; }
label.lbl input.txt { margin-top: 6px; font-weight: 400; }
.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 15px; background: #CFCAC0; transition: .15s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px #0003; transition: .15s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
