/**
 * Unified Design Tokens & Stylesheet for Fuzengine Tools
 * Supports system color-scheme preference by default and explicit meta-driven override
 * without FOUC or duplicate CSS declarations.
 */

@view-transition {
  navigation: auto;
}

:root {
  color-scheme: light dark;

  --bg: #F4F6F3;
  --surface: #FFFFFF;
  --surface-2: #EBEFEA;
  --ink: #12211A;
  --ink-2: #33463B;
  --muted: #52645B;
  --line: #DCE3DC;
  --accent: #0B7A55;
  --accent-dark: #065C40;
  --accent-soft: #E1F1E8;
  --amber: #D98E1B;
  --amber-soft: #FBF0DA;
  --danger: #B3261E;
  --danger-soft: #FBE9E7;
  --chip: #FFFFFF;
  --btn-ink: #FFFFFF;
  --btn-hover: #065C40;
  --shadow: 0 1px 2px rgba(18, 33, 26, .05), 0 8px 24px -12px rgba(18, 33, 26, .12);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D130F;
    --surface: #151D17;
    --surface-2: #1C261E;
    --ink: #EAF2EC;
    --ink-2: #C4D4C8;
    --muted: #9AB0A2;
    --line: #27352A;
    --accent: #2FBF8F;
    --accent-dark: #4CD8A8;
    --accent-soft: #173427;
    --amber: #E8A83E;
    --amber-soft: #33270F;
    --danger: #F0807A;
    --danger-soft: #3A1D1B;
    --chip: #151D17;
    --btn-ink: #08130D;
    --btn-hover: #57D6AB;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .5);
  }
}

:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
  --bg: #F4F6F3;
  --surface: #FFFFFF;
  --surface-2: #EBEFEA;
  --ink: #12211A;
  --ink-2: #33463B;
  --muted: #52645B;
  --line: #DCE3DC;
  --accent: #0B7A55;
  --accent-dark: #065C40;
  --accent-soft: #E1F1E8;
  --amber: #D98E1B;
  --amber-soft: #FBF0DA;
  --danger: #B3261E;
  --danger-soft: #FBE9E7;
  --chip: #FFFFFF;
  --btn-ink: #FFFFFF;
  --btn-hover: #065C40;
  --shadow: 0 1px 2px rgba(18, 33, 26, .05), 0 8px 24px -12px rgba(18, 33, 26, .12);
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
  --bg: #0D130F;
  --surface: #151D17;
  --surface-2: #1C261E;
  --ink: #EAF2EC;
  --ink-2: #C4D4C8;
  --muted: #9AB0A2;
  --line: #27352A;
  --accent: #2FBF8F;
  --accent-dark: #4CD8A8;
  --accent-soft: #173427;
  --amber: #E8A83E;
  --amber-soft: #33270F;
  --danger: #F0807A;
  --danger-soft: #3A1D1B;
  --chip: #151D17;
  --btn-ink: #08130D;
  --btn-hover: #57D6AB;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Sora", system-ui, sans-serif;
  line-height: 1.18;
  margin: 0;
}

button, [role="button"], select, summary, input:not([type="checkbox"]):not([type="radio"]) {
  min-height: 2.75rem;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: max(1rem, 1em);
  color: var(--ink);
}

textarea {
  line-height: 1.6;
}

.mono,
code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

code {
  font-size: .88em;
  background: var(--surface-2);
  padding: .1rem .35rem;
  border-radius: 5px;
}

a {
  color: var(--accent-dark);
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 200;
  width: auto;
  height: auto;
  clip-path: none;
  margin: 0;
  padding: .65rem 1rem;
  background: var(--accent);
  color: var(--btn-ink);
  font-weight: 800;
  border-radius: 10px;
  text-decoration: none;
}

/* ---------- Top Bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

.brand img {
  display: block;
  object-fit: contain;
  flex: none;
}

.brand strong {
  font-family: "Sora", sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.01em;
}

.brand strong span {
  color: var(--accent);
}

.topnav {
  display: none;
  gap: .2rem;
}

.topnav a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  padding: .55rem .7rem;
  border-radius: 9px;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--accent-dark);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Color-scheme icon state toggling without JS flicker */
.theme-toggle .state-dark {
  display: none;
}
.theme-toggle .state-light {
  display: inline-flex;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle .state-light {
    display: none;
  }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle .state-dark {
    display: inline-flex;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .state-light {
  display: none;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .state-dark {
  display: inline-flex;
}

@media (min-width: 820px) {
  .topnav {
    display: flex;
  }
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- Hero ---------- */
.hero {
  padding: 2.2rem 0 1.4rem;
  text-align: left;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -.02em;
  max-width: 22ch;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  color: var(--muted);
  font-size: clamp(1rem, 1.9vw, 1.12rem);
  max-width: 64ch;
  margin: .85rem 0 1.3rem;
  font-weight: 500;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .85rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.searchbar {
  display: flex;
  gap: .5rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: .45rem;
  box-shadow: var(--shadow);
  max-width: 640px;
}

.searchbar:has(#searchInput:focus-visible) {
  border-color: var(--accent);
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

.searchbar svg {
  width: 22px;
  height: 22px;
  color: var(--muted);
  flex: none;
  margin: auto 0 auto .5rem;
}

.searchbar input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 1.02rem;
  min-width: 0;
}

.searchbar input:focus-visible {
  outline: none;
}

.searchbar button {
  background: var(--accent);
  color: var(--btn-ink);
  border: 0;
  border-radius: 11px;
  padding: 0 1.2rem;
  font-weight: 700;
  font-size: .95rem;
}

.quickchips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .9rem;
  align-items: center;
}

.quickchips span {
  font-size: .85rem;
  color: var(--muted);
  font-weight: 600;
}

.qchip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--chip);
  border-radius: 999px;
  padding: .42rem .85rem;
  font-size: .85rem;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: none;
  min-height: 2.25rem;
}

.qchip:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  margin-top: 1.6rem;
}

.stat b {
  font-family: "Sora", sans-serif;
  font-size: 1.35rem;
  display: block;
}

.stat small {
  color: var(--muted);
  font-weight: 600;
  font-size: .82rem;
}

/* ---------- Category Pills & Tool Grid ---------- */
.catrow {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1.1rem;
  align-items: center;
}

.catpill {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: .5rem .95rem;
  font-weight: 700;
  font-size: .88rem;
  text-decoration: none;
}

.catpill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.catpill:hover {
  border-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .85rem;
  padding-bottom: .5rem;
}

@media (min-width: 620px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 980px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  text-align: left;
  width: 100%;
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
  color: var(--ink);
  text-decoration: none;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card .ic {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  flex: none;
}

.card .ic svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent-dark);
}

.card h2,
.card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

.card p {
  margin: .25rem 0 .5rem;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.45;
}

.card .tag {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.card .arrow {
  margin-left: auto;
  color: var(--muted);
  font-weight: 800;
  flex: none;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Breadcrumb & Tool Header ---------- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  margin: 1.15rem 0 .55rem;
}

.breadcrumb a {
  color: var(--accent-dark);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.tool-hero-head {
  text-align: center;
  margin: .45rem auto 1.35rem;
  max-width: 780px;
}

.tool-hero-head .pill-badge {
  margin-bottom: .6rem;
}

.tool-hero-head h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.02em;
}

.tool-hero-head p {
  color: var(--muted);
  font-size: clamp(.98rem, 1.8vw, 1.08rem);
  margin: .55rem auto 0;
  max-width: 62ch;
  font-weight: 500;
}

/* ---------- Tool Layout ---------- */
.tool-layout {
  display: grid;
  gap: 1.15rem;
  grid-template-columns: 1fr;
  padding-bottom: 1rem;
}

@media (min-width: 920px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem;
  box-shadow: var(--shadow);
}

.rail .panel {
  margin-bottom: 1.1rem;
}

.rail h2,
.rail h3 {
  font-size: 1rem;
  margin-bottom: .55rem;
}

.rail p,
.rail li {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

.rail ol,
.rail ul {
  margin: .3rem 0;
  padding-left: 1.15rem;
}

.rail li {
  margin: .35rem 0;
}

.relbtn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: .6rem;
  background: var(--surface-2);
  border: 0;
  border-radius: 10px;
  padding: .6rem .75rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .45rem;
  text-align: left;
  text-decoration: none;
}

.relbtn:hover {
  background: var(--accent-soft);
}

.relbtn svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent-dark);
  flex: none;
}

/* ---------- Form Controls ---------- */
label.flabel {
  display: block;
  font-weight: 700;
  font-size: .86rem;
  margin: 0 0 .35rem;
  color: var(--ink-2);
}

.field {
  margin-bottom: 1rem;
}

.tin,
.tsel,
textarea.tin {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: .65rem .8rem;
  color: var(--ink);
}

.tin:focus-visible,
.tsel:focus-visible,
textarea.tin:focus-visible {
  border-color: var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

textarea.tin {
  min-height: 130px;
  resize: vertical;
}

.row2 {
  display: grid;
  gap: .9rem;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .row2 {
    grid-template-columns: 1fr 1fr;
  }
  .row3 {
    display: grid;
    gap: .9rem;
    grid-template-columns: repeat(3, 1fr);
  }
}

.controls-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

@media (min-width: 580px) {
  .controls-row {
    grid-template-columns: 1fr 1fr;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border-radius: 11px;
  border: 0;
  padding: .7rem 1.25rem;
  font-weight: 800;
  font-size: .95rem;
  background: var(--accent);
  color: var(--btn-ink);
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background: var(--btn-hover);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--surface-2);
  color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btnrow {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: .4rem;
}

.result {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-top: 1rem;
  border-left: 4px solid var(--accent);
}

.result .big {
  font-family: "Sora", sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}

.result p {
  margin: .2rem 0;
  color: var(--ink-2);
  font-weight: 600;
  font-size: .93rem;
}

.result.warn {
  background: var(--amber-soft);
  border-left-color: var(--amber);
}

.result.bad {
  background: var(--danger-soft);
  border-left-color: var(--danger);
}

.err {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 11px;
  padding: .75rem .95rem;
  font-weight: 700;
  font-size: .92rem;
  margin-top: .8rem;
  display: none;
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-top: 1rem;
}

@media (min-width: 560px) {
  .statgrid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.statbox {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: .7rem .8rem;
}

.statbox b {
  font-family: "Sora", sans-serif;
  font-size: 1.22rem;
  display: block;
  color: var(--ink);
}

.statbox small {
  color: var(--muted);
  font-weight: 700;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 11px;
  padding: .3rem;
  gap: .3rem;
  flex-wrap: wrap;
}

.seg button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: .5rem .9rem;
  font-weight: 700;
  color: var(--ink-2);
  min-height: 2.4rem;
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  min-height: 2rem;
}

input[type="color"] {
  width: 64px;
  height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  padding: 4px;
  cursor: pointer;
}

.checkline {
  display: flex;
  gap: .6rem;
  align-items: center;
  font-weight: 600;
  padding: .45rem 0;
  cursor: pointer;
  min-height: 2.75rem;
  color: var(--ink);
}

.checkline input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.swatchrow {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .7rem;
}

.swatch {
  width: 52px;
  height: 52px;
  border-radius: 11px;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  min-height: 52px;
}

#qrBox {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--line);
  min-height: 180px;
  margin: 1rem 0;
}

#qrBox img,
#qrBox canvas {
  max-width: 100%;
}

table.mini {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  margin-top: .6rem;
}

table.mini th,
table.mini td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

table.mini th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

table.mini td.num,
table.mini th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Dropzone & File Queue ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 2.2rem 1.2rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background-color .15s;
}

.dropzone:hover,
.dropzone.dragover,
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dz-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto .75rem;
  color: var(--accent);
}

.dz-icon svg {
  width: 100%;
  height: 100%;
}

.dz-text {
  font-family: "Sora", sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.dz-sub {
  color: var(--muted);
  font-size: .88rem;
  margin: 0;
}

.file-queue {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1.4rem;
}

.file-item {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem 1rem;
}

.file-thumb {
  width: 68px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.file-meta-col {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  overflow: hidden;
}

.file-meta-header {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.file-title {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-tag {
  font-size: .72rem;
  font-weight: 800;
  padding: .15rem .5rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-clean {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  font-size: .78rem;
  color: var(--muted);
}

.meta-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .1rem .45rem;
}

.file-actions-col {
  display: flex;
  align-items: center;
  gap: .45rem;
}

@media (max-width: 640px) {
  .file-item {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .file-thumb {
    margin: 0 auto;
  }
  .file-meta-header,
  .file-actions-col {
    justify-content: center;
  }
}

.thumbrow {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-top: 1rem;
}

.thumbitem {
  display: flex;
  align-items: center;
  gap: .7rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: .5rem .6rem;
}

.thumbitem img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex: none;
  background: #fff;
}

.thumbitem .nm {
  font-weight: 700;
  font-size: .88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumbitem .sz {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}

.thumbitem .sp {
  margin-left: auto;
  display: flex;
  gap: .35rem;
  flex: none;
}

.thumbitem button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 800;
  color: var(--ink);
}

.previewimg {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-top: .8rem;
  background: #fff;
}

.valrow {
  display: flex;
  gap: .6rem;
  align-items: stretch;
  margin-bottom: .6rem;
}

.valrow .tin {
  flex: 1;
}

.valrow .btn {
  flex: none;
}

/* ---------- Modal Dialog ---------- */
.modal-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  max-width: 620px;
  width: 90%;
  margin: auto;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
}

.modal-content {
  padding: 1.3rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: .85rem;
  margin-bottom: .85rem;
}

.modal-body {
  max-height: 55vh;
  overflow-y: auto;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.modal-footer {
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

/* ---------- Documentation, Entity & Guide Sections ---------- */
section.block {
  padding: 2rem 0 .4rem;
}

.sec-head {
  margin-bottom: 1rem;
}

.sec-head h2 {
  font-size: clamp(1.3rem, 2.8vw, 1.75rem);
  letter-spacing: -.01em;
}

.sec-head p {
  color: var(--muted);
  margin: .35rem 0 0;
  max-width: 65ch;
  font-weight: 500;
}

.guides {
  display: grid;
  gap: .85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .guides {
    grid-template-columns: repeat(3, 1fr);
  }
}

.guide {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.guide h3 {
  font-size: 1.05rem;
}

.guide p {
  color: var(--muted);
  font-size: .91rem;
  font-weight: 500;
  margin: 0;
}

.doc-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1rem;
}

@media (min-width: 780px) {
  .doc-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.doc-card h2,
.doc-card h3 {
  font-size: 1.06rem;
  margin-bottom: .45rem;
}

.doc-card p,
.doc-card li {
  color: var(--muted);
  font-size: .93rem;
  line-height: 1.6;
}

.doc-article h2 {
  font-size: 1.32rem;
  margin: 1.45rem 0 .55rem;
}

.doc-article h2:first-child {
  margin-top: 0;
}

.doc-article p,
.doc-article li {
  color: var(--ink-2);
  font-size: .97rem;
  line-height: 1.65;
}

details.faq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: .6rem;
}

details.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: .95rem 1.1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

details.faq summary::-webkit-details-marker {
  display: none;
}

details.faq summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 800;
}

details.faq[open] summary::after {
  content: "–";
}

details.faq p {
  margin: 0;
  padding: 0 1.1rem 1rem;
  color: var(--muted);
  font-weight: 500;
  font-size: .94rem;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.75rem 0 2.5rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

footer .cols {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 760px) {
  footer .cols {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }
}

footer b {
  color: var(--ink);
  font-family: "Sora", sans-serif;
}

footer ul {
  list-style: none;
  margin: .5rem 0 0;
  padding: 0;
}

footer li {
  margin: .3rem 0;
}

footer a {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: var(--bg);
  padding: .75rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .92rem;
  z-index: 99;
  transition: transform .25s;
  box-shadow: var(--shadow);
  max-width: 92vw;
  text-align: center;
}

#toast.show {
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
