/* Esineet – selkeä, inventaariomainen ilme. Värit ja typografia muuttujina. */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f0f0ee;
  --surface-3: #ecece8;
  --ink: #1b1b1a;
  --ink-2: #4a4a46;
  --muted: #5e5e5a;
  --line: #dcdcd8;
  --line-soft: #ecece9;
  --line-input: #cfcfca;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-ink: #ffffff;
  --accent-soft: #e6edfb;
  --accent-text: #1e3a8a;
  --select-bg: #eef3fd;
  --hover-bg: #f7f8fb;
  --private-bg: #fafaf7;
  --private-line: #b8b8b2;
  --warn: #8a4a12;
  --warn-soft: #fbf0e4;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 8px;
  --radius-sm: 6px;
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1280px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-text); }
h1, h2, h3 { font-family: var(--font-sans); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 13px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.stack > * + * { margin-top: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Pienet osioiden otsikot: isot kirjaimet, harmaa */
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 0; }

/* htmx-latauspalkki */
.loading-bar { position: fixed; top: 0; left: 0; z-index: 100; height: 3px; width: 0; background: var(--accent); opacity: 0; pointer-events: none; }
.loading-bar.htmx-request { opacity: 1; width: 85%; transition: width 2s cubic-bezier(.1, .7, .3, 1) .15s, opacity .1s .15s; }

/* --- Yläpalkki --- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .wrap { display: flex; align-items: center; gap: 20px; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-tld { color: var(--muted); font-weight: 500; }
.brand-mark { width: 30px; height: 30px; flex: none; color: var(--ink); }
.nav { display: flex; gap: 2px; align-items: center; flex: 1; flex-wrap: wrap; }
.nav a, .nav button { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); background: none; border: 0; font: inherit; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav .nav-end { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.nav .nav-end .btn-primary { background: var(--accent); color: var(--accent-ink); padding: 0 14px; }
.nav .nav-end .btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.nav form { margin: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #e4e4e0; color: var(--ink); display: grid; place-items: center; font-weight: 600; font-size: 12px; text-transform: uppercase; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line-input); border-radius: var(--radius-sm); padding: 0 12px; min-height: 40px; font: inherit; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 10px; }
  .nav.open { display: flex; }
  .nav .nav-end { margin-left: 0; flex-direction: column; align-items: stretch; }
  .topbar .wrap { flex-wrap: wrap; }
}

main { padding: 20px 0 48px; }
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 20px 0 32px; }

/* --- Painikkeet --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-input);
  background: var(--surface); color: var(--ink); font: 500 14px/1.2 var(--font-sans);
  text-decoration: none; cursor: pointer; min-height: 40px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn svg { flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger-solid:hover { background: #912018; color: #fff; }
.btn-small { padding: 0 10px; min-height: 32px; font-size: 13px; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* --- Viestit --- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { background: var(--accent-soft); color: var(--accent-text); border: 1px solid #c7d5f5; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.messages li.error { background: var(--danger-soft); color: var(--danger); border-color: #f3c3be; }
.messages li.info { background: var(--surface); color: var(--ink); border-color: var(--line); }

/* --- Merkit: näkyvyys aina sanana, ei pelkkänä värinä --- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
.badge-public { background: var(--accent-soft); color: var(--accent-text); }
.badge-private { background: var(--surface-2); color: var(--ink-2); }
.badge-private::before { content: ""; width: 10px; height: 11px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='1'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='1'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center / contain no-repeat; }
.badge-example { background: var(--warn-soft); color: var(--warn); }
.chip { display: inline-flex; align-items: center; font-size: 13px; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* Värinäyte ja kategoriasiru */
.swatch { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--sw, transparent); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25); vertical-align: -1px; }
.cat-chip { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; line-height: 1.4; text-decoration: none; }
a.cat-chip-link:hover { border-color: var(--accent); background: var(--select-bg); color: var(--ink); }
.swatch-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.swatch-link { display: inline-flex; padding: 3px; border-radius: 50%; }
.swatch-link:hover { background: var(--select-bg); }
.swatch-link .swatch { width: 16px; height: 16px; }
table.data .cat-chip { white-space: nowrap; overflow-wrap: normal; }
.cat-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* --- Etusivu --- */
.hero { padding: 32px 0 24px; display: grid; gap: 40px; grid-template-columns: 1fr 1fr; align-items: center; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); letter-spacing: -0.02em; margin-bottom: .3em; }
.hero p.lead { font-size: 17px; color: var(--ink-2); max-width: 34em; }
.hero-art { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.hero-art table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hero-art th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); padding: 9px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.hero-art td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.hero-art tr:last-child td { border-bottom: 0; }
.hero-art td:first-child { font-family: var(--font-mono); }
.features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 24px 0 40px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.feature h3 { margin-bottom: .3em; }
.feature p { margin: 0; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; padding-top: 8px; } .hero-art { display: none; } }

/* --- Sivun otsikko --- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.page-head .eyebrow { font: 500 15px/1.2 var(--font-mono); color: var(--ink-2); margin-bottom: 6px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { color: #a8a8a2; }
.desc { color: var(--ink-2); max-width: 52em; white-space: pre-line; margin: 0 0 16px; }

/* --- Kokoelmakortit (julkiset listat) --- */
.collection-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.collection-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.collection-card:hover { border-color: #a8a8a2; color: inherit; }
.collection-card .cover { aspect-ratio: 16/10; background: var(--surface-3); object-fit: cover; width: 100%; border-bottom: 1px solid var(--line); }
.collection-card .cover-empty { aspect-ratio: 16/10; background: var(--surface-3); border-bottom: 1px solid var(--line); display: grid; place-items: center; font: 500 28px/1 var(--font-mono); color: #8a8a85; }
.collection-card .body { padding: 10px 12px 12px; }
.collection-card h3 { margin: 0 0 2px; }
.collection-card .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Kokoelman kansikuva taulukossa */
.cover-thumb { width: 72px; height: 54px; border-radius: 4px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--line); display: grid; place-items: center; font: 500 16px/1 var(--font-mono); color: #8a8a85; }

/* --- Esittelysivu --- */
.showcase-hero { text-align: center; padding: 8px 0 24px; }
.showcase-hero img { max-height: 340px; width: 100%; object-fit: cover; border-radius: var(--radius); margin-bottom: 24px; }
.showcase-hero h1 { font-size: clamp(28px, 4vw, 40px); }
.showcase-hero .desc { max-width: 40em; margin: 0 auto; font-size: 16px; }

/* --- Työkalupalkki: haku ja suodattimet --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.toolbar .search { position: relative; flex: 1 1 260px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar .search input { padding-left: 34px; }
.toolbar input[type=search] { flex: 1 1 260px; }
.toolbar select { flex: 0 1 190px; width: auto; }
.toolbar .spacer { flex: 1; }
.btn-clear { gap: 6px; }
/* Suodatinpalkki: haku aina näkyvissä, muut suodattimet paneelissa */
.filterbar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.filterbar-main { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filterbar .search { position: relative; flex: 1 1 240px; }
.filterbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.filterbar .search input { padding-left: 34px; }
.filter-toggle { gap: 6px; }
.filter-toggle[aria-expanded=true] { background: var(--select-bg); border-color: var(--accent); }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.filter-panel { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.filter-panel select { flex: 0 1 220px; width: auto; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.active-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border: 1px solid var(--accent); border-radius: 999px; background: var(--select-bg); color: var(--accent-text); font-size: 13px; text-decoration: none; }
.active-chip span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; }
.active-chip:hover span { background: var(--accent); color: var(--accent-ink); }
.clear-filters { font-size: 13px; margin-left: 4px; }
.results-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin: 0 0 10px; }
.results-info { display: flex; align-items: center; gap: 10px; }
.results-count { font-size: 14px; color: var(--muted); }
/* Sarakkeet on vasemmalla, joten paneeli avautuu oikealle */
.results-info .col-picker { margin: 0; }
.results-info .col-picker-panel { left: 0; right: auto; }
.results-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.results-tools select { width: auto; min-height: 36px; }
@media (max-width: 640px) {
  .filterbar .search { flex-basis: 100%; }
  .filterbar-main .btn { flex: 1; justify-content: center; }
  .filter-panel select { flex: 1 1 100%; }
  .results-tools { margin-left: 0; width: 100%; }
  .results-tools .segmented { order: -1; flex: 1 1 100%; }
  .results-tools .segmented a { flex: 1; justify-content: center; }
}

/* Värisuodatin: värinäytteet radionappeina */
.swatch-filter { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.swatch-filter legend { float: left; font-size: 13px; color: var(--muted); margin-right: 4px; padding: 0; }
.swatch-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px 4px 8px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--surface); color: var(--ink-2); }
.swatch-opt:hover { background: var(--hover-bg); }
.swatch-opt input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-opt:has(input:checked) { border-color: var(--accent); background: var(--select-bg); color: var(--ink); font-weight: 600; }
.swatch-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch-opt .n { color: var(--muted); font-weight: 400; }
.segmented { display: inline-flex; border: 1px solid var(--line-input); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented a { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; text-decoration: none; color: var(--ink); }
.segmented a:hover { background: var(--surface-2); color: var(--ink); }
.segmented a[aria-current] { background: var(--ink); color: #fff; font-weight: 500; }
.result-count { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.list-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 12px; }

/* --- Esineruudukko --- */
.item-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.item-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.item-card:hover { border-color: #a8a8a2; color: inherit; }
.item-card .img { position: relative; aspect-ratio: 4/3; background: var(--surface-3); border-bottom: 1px solid var(--line); }
/* Koko esine näkyy: kuva mahtuu kehykseen rajautumatta */
.item-card .img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.item-card .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.item-card .body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; }
.item-card .t { font-weight: 600; line-height: 1.3; }
.item-card .m { font-size: 13px; color: var(--muted); display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.item-card .m .m-text { margin-left: 2px; }
.item-card .aid { font: 12px/1.3 var(--font-mono); color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.item-card .aid .badge { font-family: var(--font-sans); padding: 0 6px; font-size: 11px; }
.showcase .item-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
@media (max-width: 520px) { .item-grid, .showcase .item-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }

/* --- Taulukko --- */
/* position: relative: absoluuttiset lapset (esim. .visually-hidden) pysyvät vierityskehyksen sisällä eivätkä levitä sivua */
.table-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 8px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
table.data th:first-child, table.data td:first-child { padding-left: 16px; }
table.data th:last-child, table.data td:last-child { padding-right: 16px; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; border-bottom-color: var(--line); padding-top: 10px; padding-bottom: 10px; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--hover-bg); }
table.data tbody tr:has(input[type=checkbox]:checked) td { background: var(--select-bg); }
table.data .thumb { display: block; flex: none; min-width: 52px; max-width: none; width: 52px; height: 52px; border-radius: 4px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--line); }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .mono { white-space: nowrap; }
table.data .name { color: var(--ink); text-decoration: none; font-weight: 600; }
table.data .name:hover { text-decoration: underline; }
table.data .sub { color: var(--muted); font-size: 13px; }
table.data .col-check { width: 44px; }
table.data .col-thumb { width: 52px; }
table.data input[type=checkbox] { width: 16px; height: 16px; }
table.data .row-actions { text-align: right; white-space: nowrap; }
.vis-private { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.vis-public { color: var(--accent-text); font-weight: 500; }

/* Valintapalkki: näkyy, kun rivejä on valittu */
.bulkbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 8px 8px 8px 16px; position: sticky; top: 64px; z-index: 5; }
.bulkbar strong { font-weight: 600; }
.bulkbar .spacer { flex: 1; }
.bulkbar .btn { background: #fff; border-color: #fff; color: var(--ink); font-weight: 600; min-height: 36px; }
.bulkbar .btn:hover { background: #e4e4e0; }
.bulkbar .btn-ghost { background: transparent; border: 0; color: #d4d4cf; font-weight: 400; }
.bulkbar .btn-ghost:hover { background: transparent; color: #fff; text-decoration: underline; }
.bulk-hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* --- Lomakkeet --- */
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-input); border-radius: var(--radius-sm); padding: 0 10px; min-height: 40px;
}
textarea { min-height: 84px; padding: 8px 10px; resize: vertical; }
/* Oma nuoli valikoille: selaimen oma nuoli on kiinni reunassa */
select:not([multiple]):not([size]) {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235e5e5a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=file] { font: inherit; max-width: 100%; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px 20px; }
.form-card + .form-card { margin-top: 16px; }
.form-card > h2, .form-card .card-head h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 0 0 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { margin: 0 !important; }
.card-head .note { font-size: 12px; color: var(--muted); }
.form-narrow { max-width: 640px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field label, .field > legend, .field fieldset > legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
.field .helptext, .field .help { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.field ul.errorlist, ul.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--danger); font-size: 12px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field > div > label, .checks label, .field fieldset div label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 0; }
.checks, .field div[id] { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.field fieldset { border: 0; padding: 0; margin: 0; }
.check-row { display: flex; gap: 10px; align-items: flex-start; }
.check-row input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); }
.check-row label { font-weight: 600; margin: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.private-box { background: var(--private-bg); border: 1px dashed var(--private-line); }
.private-note { font-size: 12px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.lock-title { display: inline-flex; align-items: center; gap: 6px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); margin-top: 16px; padding: 12px 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; z-index: 4; }
.sticky-actions .btn { min-height: 44px; }
.type-picker { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.type-picker .field { flex: 1 1 240px; }
.drop { border: 1px dashed #a8a8a2; border-radius: var(--radius); padding: 16px; text-align: center; background: var(--surface); color: var(--ink-2); }
.drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop .drop-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; justify-content: center; }
.previews img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* --- Esineen tietosivu --- */
.item-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.item-layout .media-col, .item-layout .info { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 760px) { .item-layout { grid-template-columns: minmax(0, 1fr); } }
.gallery-main { border-radius: var(--radius); overflow: hidden; background: var(--surface-3); border: 1px solid var(--line); }
.gallery-main img { width: 100%; max-height: 72vh; object-fit: contain; background: var(--surface-3); }
.gallery-open { position: relative; display: block; cursor: zoom-in; }
.gallery-zoom { position: absolute; right: 10px; bottom: 10px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff; opacity: .8; transition: opacity .15s; }
.gallery-open:hover .gallery-zoom, .gallery-open:focus-visible .gallery-zoom { opacity: 1; }
/* Lightbox */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgb(12 12 12 / .96); color: #f2f2f0; }
.lightbox::backdrop { background: rgb(0 0 0 / .7); }
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
body.lb-open { overflow: hidden; }
.lb-stage { position: relative; overflow: hidden; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 16px 64px; min-height: 0; touch-action: pan-y; }
.lb-stage img { max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; object-fit: contain; cursor: zoom-in; user-select: none; -webkit-user-drag: none; }
.lb-stage.zoomed { overflow: auto; display: block; padding: 0; touch-action: auto; }
.lb-stage.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.lb-bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-top: 1px solid rgb(255 255 255 / .12); font-size: 14px; }
.lb-count { font-family: var(--font-mono); color: #b5b5b0; white-space: nowrap; }
.lb-caption { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-link { color: #f2f2f0; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.lb-close { background: none; border: 1px solid rgb(255 255 255 / .3); color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.lb-nav { position: absolute; top: calc(50% - 50px); width: 48px; height: 64px; border: 0; border-radius: var(--radius); background: rgb(255 255 255 / .1); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.lb-nav:hover, .lb-close:hover { background: rgb(255 255 255 / .2); }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.lightbox :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 640px) {
  .lb-stage { padding: 8px; }
  .lb-nav { top: auto; bottom: 64px; width: 44px; height: 44px; font-size: 26px; background: rgb(0 0 0 / .5); }
}
.gallery-main .noimg { aspect-ratio: 1; display: grid; place-items: center; color: var(--muted); }
.gallery-thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.gallery-thumbs button { border: 1px solid var(--line); padding: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-3); cursor: pointer; aspect-ratio: 1; }
.gallery-thumbs button[aria-current] { outline: 2px solid var(--ink); outline-offset: -2px; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.caption { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.caption:empty { display: none; }
.archive-id { font-family: var(--font-mono); font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; display: inline-block; color: var(--ink); }
.meta-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); margin-top: 6px; }
/* Liittyvät esineet */
.related-list { list-style: none; margin: 0; padding: 0; }
.related-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.related-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.related-link:hover .name { text-decoration: underline; }
.related-link .thumb { width: 44px; height: 44px; flex: none; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--line); }
.related-text { display: flex; flex-direction: column; min-width: 0; }
.related-text .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.related-text .mono { font-size: 12px; }
.related-empty { margin: 0; padding: 8px 0; font-size: 14px; }
.related-list li:last-child { border-bottom: 0; }
.panel .panel-head .panel-link { font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: normal; }
.form-intro { margin: -8px 0 12px; font-size: 13px; }
/* Selite ja arvo samalla rivillä; väli on selitteen täytettä, jotta rivin viiva ei katkea. */
dl.facts { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr); margin: 0; }
dl.facts dt, dl.facts dd { padding: 8px 0; border-bottom: 1px solid var(--line-soft); margin: 0; }
dl.facts dt { padding-right: 16px; }
dl.facts dt:last-of-type, dl.facts dd:last-of-type { border-bottom: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { white-space: pre-line; overflow-wrap: anywhere; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > h2, .panel .panel-head { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.panel .panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel .panel-head h2 { margin: 0; font-size: inherit; font-weight: inherit; color: inherit; letter-spacing: inherit; }
.panel-body { padding: 4px 16px 8px; }
.panel-body.pad { padding: 12px 16px 16px; }
.panel.private { background: var(--private-bg); border-style: dashed; border-color: var(--private-line); }
/* Liittyvien esineiden haku (Select2-tyylinen) */
.picker { display: grid; gap: 8px; }
.picker-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.picker-chips:empty { display: none; }
.picker-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.picker-thumb { width: 36px; height: 36px; flex: none; object-fit: cover; border-radius: 4px; background: var(--surface-3); border: 1px solid var(--line); }
.picker-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.picker-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-meta { font: 12px var(--font-mono); color: var(--muted); }
.picker-remove { flex: none; width: 28px; height: 28px; border: 0; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.picker-remove:hover { background: var(--danger-soft); color: var(--danger); }
.picker-search { position: relative; }
.picker-input { width: 100%; min-height: 40px; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; list-style: none; margin: 0; padding: 4px; max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.picker-option { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.picker-option[aria-selected=true], .picker-option:hover { background: var(--select-bg); }
.picker-option .picker-thumb { width: 44px; height: 44px; }
.picker-empty { padding: 10px 8px; color: var(--muted); font-size: 14px; }
/* Muokkauslomakkeen kuvat ja liitteet */
.img-edit-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.img-edit-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.img-edit-row:has(.img-edit-delete input:checked) { opacity: .5; background: var(--danger-soft); }
.img-edit-row:has(input[name=paakuva]:checked) { border-color: var(--accent); }
.img-edit-media { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 96px; }
.img-edit-thumb { width: 72px; height: 72px; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-3); transition: transform .2s; }
.img-edit-rotate { display: flex; gap: 4px; }
.img-edit-rotate .btn { min-height: 28px; padding: 0 8px; font-size: 15px; }
.img-edit-rotation { width: 96px; min-height: 30px; font-size: 12px; padding-left: 6px; }
.img-edit-fields { display: grid; gap: 6px; min-width: 0; }
.img-edit-fields input[type=text] { min-height: 34px; }
.img-edit-opts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.img-edit-delete { color: var(--danger); }
.img-edit-order { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.img-edit-num { width: 56px; min-height: 32px; text-align: center; }
.js .img-edit-num { display: none; }
.att-edit-list { list-style: none; margin: 0 0 12px; padding: 0; }
.att-edit-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.qr-label { border: 1px solid var(--ink); border-radius: 4px; padding: 10px; display: flex; gap: 10px; align-items: center; background: #fff; }
.qr-label img { width: 72px; height: 72px; flex: none; }
.qr-label .aid { font: 500 14px/1.3 var(--font-mono); }
.qr-label .nm { font-size: 12px; font-weight: 600; line-height: 1.3; }
.qr-label .url { font: 10px/1.3 var(--font-mono); color: var(--ink-2); word-break: break-all; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { min-height: 36px; font: 12px var(--font-mono); background: #fafaf9; }
.copy-row .btn { min-height: 36px; }
.qr-box { display: flex; gap: 16px; align-items: center; }
.qr-box img { width: 110px; height: 110px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--line); padding: 4px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.cover-field { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 8px; }
.cover-field legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.cover-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.cover-field .cover-option { display: grid; grid-template-rows: auto auto; justify-items: stretch; gap: 4px; margin: 0; cursor: pointer; text-align: center; font-weight: 400; }
.cover-option input { position: absolute; opacity: 0; pointer-events: none; }
.cover-option-img { display: grid; place-items: center; aspect-ratio: 1; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-3); overflow: hidden; font-size: 12px; }
.cover-option-img img { width: 100%; height: 100%; object-fit: cover; }
.cover-option-label { font: 11px var(--font-mono); color: var(--muted); }
.cover-option:has(input:checked) .cover-option-img { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cover-option:has(input:checked) .cover-option-label { color: var(--accent-text); font-weight: 600; }
.cover-option:has(input:focus-visible) .cover-option-img { outline: 2px solid var(--accent); outline-offset: 2px; }
.cover-upload { display: grid; gap: 4px; font-size: 14px; }

/* Jakolinkit */
.share-layout { display: grid; grid-template-columns: minmax(260px, 320px) 1fr; gap: 16px; align-items: start; }
.share-new { position: sticky; top: 72px; }
.share-list { display: grid; gap: 12px; min-width: 0; }
.share-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.share-filter a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); text-decoration: none; font-size: 14px; }
.share-filter a[aria-current] { border-color: var(--accent); background: var(--select-bg); color: var(--ink); font-weight: 600; }
.share-card { display: grid; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); scroll-margin-top: 72px; }
.share-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.share-card.is-inactive { background: var(--private-bg); }
.share-card.is-inactive h3 { color: var(--muted); }
.share-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.share-card-head h3 { margin: 0; font-size: 16px; }
.share-card-head p { margin: 2px 0 0; font-size: 13px; }
.share-card .copy-row input { font-family: var(--font-mono); font-size: 13px; }
.share-view { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.share-view select { width: auto; min-height: 32px; font-size: 13px; }
.share-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
@media (max-width: 800px) { .share-layout { grid-template-columns: minmax(0, 1fr); } .share-new { position: static; } }

/* Kansionäkymä */
.folder-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.folder-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 300px; font-size: 15px; }
.folder-crumbs svg { color: var(--muted); }
.folder-crumbs [aria-current] { font-weight: 600; }
.folder-crumbs .sep { color: var(--muted); }
.folder-group { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--ink-2); }
.folder-group select { width: auto; min-height: 34px; }
.folder-default { font-size: 13px; }
.folder-grid { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.folder-card { display: flex; align-items: stretch; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.folder-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgb(0 0 0 / .06); }
.folder-thumbs { flex: 0 0 132px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; height: 76px; align-self: center; margin: 8px 0 8px 8px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-3); }
.folder-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.folder-thumbs img:only-child { grid-column: 1 / -1; }
.folder-thumbs img:first-child:nth-last-child(2) { grid-column: span 2; }
.folder-icon { grid-column: 1 / -1; display: grid; place-items: center; color: var(--muted); }
.folder-meta { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 10px 14px; min-width: 0; }
.folder-name { display: flex; align-items: center; gap: 6px; font-weight: 600; line-height: 1.3; }
.folder-count { font-size: 13px; color: var(--muted); }
.folder-items-title { margin: 4px 0 10px; }
/* Sarakevalitsin */
.col-picker { position: relative; display: flex; justify-content: flex-end; margin-bottom: 8px; }
.col-picker > summary { list-style: none; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.col-picker > summary::-webkit-details-marker { display: none; }
.col-picker-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 15; width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12); padding: 14px 16px; display: grid; gap: 12px; }
.col-picker-panel fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.col-picker-panel legend { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin-bottom: 6px; padding: 0; }
/* Ponnahdusvalikko (details) */
.popover { position: relative; }
.popover > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.popover > summary::-webkit-details-marker { display: none; }
.popover-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; width: min(340px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12); padding: 16px; }
.popover-danger { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

/* Kategoriasivu */
.cat-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.cat-jump a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); text-decoration: none; font-size: 14px; }
.cat-jump a:hover { background: var(--hover-bg); color: var(--ink); }
.cat-jump .n, .cat-count { color: var(--muted); font-size: 13px; }
.cat-groups { display: grid; gap: 16px; max-width: 880px; }
.cat-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); scroll-margin-top: 72px; }
.cat-group-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.cat-group-head h2 { font-size: 17px; margin: 0; }
.cat-group-head p { margin: 2px 0 0; font-size: 13px; }
.cat-rows { list-style: none; margin: 0; padding: 0; }
.cat-rows > li { border-bottom: 1px solid var(--line-soft); }
.cat-edit > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 16px 6px calc(16px + var(--depth, 0) * 24px); cursor: pointer; }
.cat-edit > summary::-webkit-details-marker { display: none; }
.cat-edit > summary:hover { background: var(--hover-bg); }
.cat-row.is-child .cat-edit > summary::before { content: ""; width: 10px; height: 10px; margin-left: -16px; margin-right: -4px; border-left: 1px solid var(--line-input); border-bottom: 1px solid var(--line-input); transform: translateY(-4px); flex: none; }
.cat-edit .swatch { width: 18px; height: 18px; }
.cat-name { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.cat-count { white-space: nowrap; }
.cat-edit-btn { pointer-events: none; }
.cat-edit[open] > summary { background: var(--select-bg); }
.cat-edit .if-open, .cat-edit[open] .if-closed { display: none; }
.cat-edit[open] .if-open { display: inline; }
.cat-edit-panel { padding: 12px 16px 16px calc(16px + var(--depth, 0) * 24px); background: var(--private-bg); border-top: 1px solid var(--line-soft); display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.cat-edit-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; flex: 1; }
.cat-edit-form .field { margin: 0; flex: 1 1 160px; }
.cat-edit-form .field-color { flex: 0 0 auto; }
.cat-edit-form input[type=color], .cat-add-color { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-input); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.cat-edit-form .help { font-size: 12px; }
.cat-edit-delete { margin: 0; }
.cat-add { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.cat-add input[type=text] { flex: 1 1 200px; min-height: 36px; }
.cat-add select { flex: 0 1 200px; width: auto; min-height: 36px; }
.cat-add-errors { padding: 0 16px 12px; color: var(--danger); font-size: 13px; }
.cat-add-errors ul { margin: 0; padding-left: 18px; }
@media (max-width: 640px) {
  .cat-count { display: none; }
  .cat-edit-panel { padding-left: 16px; }
}
.list-plain li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.list-plain li:last-child { border-bottom: 0; }

/* Viimeksi lisätyt -lista */
.recent-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.recent-list li { display: flex; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; align-items: baseline; }
.recent-list li:last-child { border-bottom: 0; }
.recent-list .aid { font: 13px var(--font-mono); width: 96px; }
.recent-list .nm { flex: 1; color: var(--ink); font-weight: 500; min-width: 160px; }
.recent-list .where, .recent-list .when { color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 28px 0 8px; }
.section-head h2 { margin: 0; font-size: 16px; }

/* --- Tyypit --- */
.type-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.type-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.type-card .fields { font-size: 13px; color: var(--ink-2); }
/* --- Kenttäeditori --- */
.fe-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.fe-layout .fe-actions { grid-column: 1 / -1; }
.fe-preview { position: sticky; top: 72px; }
@media (max-width: 980px) { .fe-layout { grid-template-columns: 1fr; } .fe-preview { position: static; } }
.fe-warning { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; margin: 0 0 12px; }
.fe-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.fe-list:empty { display: none; }
.fe-row { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.fe-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.fe-row:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.fe-row.has-error { background: var(--danger-soft); }
.fe-row.fe-flash { animation: fe-flash 1s ease-out; }
@keyframes fe-flash { from { background: var(--select-bg); } to { background: var(--surface); } }
.fe-main { display: grid; grid-template-columns: auto minmax(0, 1.4fr) minmax(150px, 1fr) auto auto; gap: 8px; align-items: center; }
.fe-move { display: flex; flex-direction: column; gap: 2px; }
.fe-icon { width: 30px; height: 19px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; color: var(--ink-2); cursor: pointer; font-size: 12px; line-height: 1; padding: 0; }
.fe-icon:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.fe-icon:disabled { opacity: .35; cursor: default; }
.fe-del { height: 40px; width: 36px; font-size: 14px; }
.fe-del:hover { color: var(--danger) !important; border-color: var(--danger); background: var(--danger-soft) !important; }
.fe-name input { font-weight: 600; }
.fe-req { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; cursor: pointer; padding: 0 4px; }
.fe-extra { padding-left: 38px; display: grid; gap: 8px; }
.fe-extra:has(> [data-fe-choices]:not([hidden])), .fe-extra:has(> [data-fe-help]:not([hidden])) { margin-top: 10px; }
.fe-extra label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.fe-extra textarea { min-height: 76px; }
.fe-help-toggle { font-size: 12px; justify-self: start; margin-top: 6px; }
.fe-errors { padding-left: 38px; }
.fe-deleted-note { display: none; font-size: 13px; color: var(--ink-2); gap: 10px; align-items: center; }
.fe-row.is-deleted { background: var(--surface-2); }
.fe-row.is-deleted > :not(.fe-deleted-note) { display: none !important; }
.fe-row.is-deleted .fe-deleted-note { display: flex; }
.fe-add { margin-top: 12px; }
.fe-preview-body { display: grid; gap: 14px; }
.fe-preview-body .pv-label { font-weight: 600; margin-bottom: 6px; display: block; }
.fe-preview-body .pv-help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fe-preview-body .pv-input { border: 1px solid var(--line-input); border-radius: var(--radius-sm); min-height: 36px; background: var(--surface); padding: 8px 10px; color: var(--muted); font-size: 13px; }
.fe-preview-body .pv-area { min-height: 64px; }
.fe-preview-body .pv-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.fe-preview-body .pv-checks span::before { content: "☐ "; color: var(--muted); }
.fe-preview-empty { color: var(--muted); font-size: 13px; margin: 0; }
@media (max-width: 640px) {
  .fe-main { grid-template-columns: auto minmax(0, 1fr) auto; }
  .fe-type { grid-column: 2 / 3; grid-row: 2; }
  .fe-req { grid-column: 3 / 4; grid-row: 2; }
  .fe-del { grid-column: 3 / 4; grid-row: 1; }
  .fe-move { grid-row: 1 / 3; }
  .fe-extra, .fe-errors { padding-left: 0; }
}

.empty { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed #b8b8b2; border-radius: var(--radius); color: var(--ink-2); }
.empty p:last-child { margin-bottom: 0; }
.empty h2 { margin-bottom: .3em; }
.empty p { max-width: 36em; margin-left: auto; margin-right: auto; }
.example-note { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.owner-note { background: var(--accent-soft); color: var(--accent-text); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .toolbar .search, .toolbar input[type=search] { flex-basis: 100%; }
  .toolbar select { flex: 1 1 calc(50% - 5px); }
  .toolbar .btn { flex: 1 1 calc(50% - 5px); }
  .bulkbar { top: 0; }
}

/* --- Tunnistelappujen tulostus --- */
.labels-layout { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.labels-settings { flex: 1 1 280px; max-width: 360px; }
.labels-settings .field label, .labels-settings .field legend { margin-bottom: 6px; }
.labels-settings fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.label-parts { display: flex; flex-direction: column; gap: 8px; }
.label-parts label { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 0; }
.note-box { margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 12px; color: var(--ink-2); }
.labels-preview { flex: 999 1 560px; min-width: 0; background: #e4e4e0; border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 24px; overflow-x: auto; }
.sheet {
  width: var(--page-w); height: var(--page-h); padding: var(--pad-y) var(--pad-x);
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 15%); flex: none;
  display: grid; grid-template-columns: repeat(var(--cols), var(--w)); grid-auto-rows: var(--h); align-content: start;
  zoom: .75;
}
.sheet-rulla { zoom: 1.6; }
.label {
  width: var(--w); height: var(--h); padding: 3mm 3mm 3mm 4mm; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--qr); gap: 2.5mm; align-items: center;
  outline: 1px solid #d4d4cf; outline-offset: -0.5px; break-inside: avoid; color: #000; background: #fff;
}
.label-skip { outline: 1px dashed #e4e4e0; }
.label .text { display: flex; flex-direction: column; min-width: 0; height: 100%; justify-content: center; gap: .6mm; }
.label .brandline { font-size: 6pt; letter-spacing: .1em; text-transform: uppercase; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .name { font-weight: 700; font-size: 9pt; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.label .aid { font: 700 11pt/1.1 var(--font-mono); letter-spacing: .02em; }
.label .place { font: 7pt/1.2 var(--font-mono); color: #333; }
.label .url { font: 6.2pt/1.2 var(--font-mono); color: #333; word-break: break-all; }
.label .qr svg { width: var(--qr); height: var(--qr); display: block; }
.sheet-a4-2x7 .label .name { font-size: 11pt; -webkit-line-clamp: 3; }
.sheet-a4-2x7 .label .aid { font-size: 13pt; }
.sheet-a4-2x7 .label .url, .sheet-a4-2x7 .label .place { font-size: 7.5pt; }
.sheet-rulla .label { padding: 2mm 2mm 2mm 3mm; gap: 2mm; outline: 0; }
.sheet-rulla .label .name { font-size: 8pt; }
.sheet-rulla .label .aid { font-size: 10pt; }
@media (max-width: 900px) { .sheet { zoom: .42; } .sheet-rulla { zoom: 1.2; } .labels-preview { padding: 12px; } }

@media print {
  body.labels-page { background: #fff; }
  body.labels-page .topbar, body.labels-page .footer, body.labels-page .page-head,
  body.labels-page .labels-settings, body.labels-page .messages { display: none; }
  body.labels-page main { padding: 0; }
  body.labels-page .wrap { max-width: none; padding: 0; }
  .labels-layout { display: block; }
  .labels-preview { display: block; padding: 0; background: none; border-radius: 0; overflow: visible; }
  .sheet { zoom: 1; box-shadow: none; margin: 0; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .label, .label-skip { outline: 0; }
}
