/* =========================================================
   SiapinData — design tokens
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #f8fafc;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #5b6b82;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --on-accent: #ffffff;
  --accent-soft: #eff6ff;
  --accent-soft-2: #dbeafe;
  --focus: #93c5fd;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #047857;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #92400e;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --dim: rgba(15, 23, 42, 0.48);
  --overlay: rgba(15, 23, 42, 0.55);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.14);
  --toast-bg: #0f172a;
  --toast-text: #f8fafc;
  --toast-error-bg: #7f1d1d;
  --toast-success-bg: #064e3b;
  --toast-info-bg: #1e3a8a;
  --paper: #ffffff;
  --range-track: #e2e8f0;
  --header-height: 68px;
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #16213a;
  --surface-2: #1e293b;
  --surface-3: #111c31;
  --text: #f1f5f9;
  --text-soft: #d7e0ec;
  --muted: #9db0c7;
  --border: #334155;
  --border-strong: #475569;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --on-accent: #0f172a;
  --accent-soft: #172554;
  --accent-soft-2: #1e3a8a;
  --focus: #93c5fd;
  --danger: #fca5a5;
  --danger-bg: #3b1d22;
  --danger-border: #7f1d1d;
  --success: #6ee7b7;
  --success-bg: #102d26;
  --success-border: #065f46;
  --warning: #fcd34d;
  --warning-bg: #382e12;
  --warning-border: #78350f;
  --dim: rgba(0, 0, 0, 0.56);
  --overlay: rgba(0, 0, 0, 0.68);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.42);
  --toast-bg: #f1f5f9;
  --toast-text: #0f172a;
  --toast-error-bg: #fecaca;
  --toast-success-bg: #a7f3d0;
  --toast-info-bg: #bfdbfe;
  --paper: #ffffff;
  --range-track: #334155;
}

/* =========================================================
   Base
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-busy {
  cursor: progress;
}

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

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h1 {
  font-size: clamp(1.65rem, 1.35rem + 1.2vw, 2.2rem);
}

h2 {
  font-size: clamp(1.3rem, 1.15rem + 0.7vw, 1.6rem);
}

h3 {
  font-size: 1.05rem;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft-2);
  color: var(--text);
}

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

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  min-height: 44px;
  z-index: 200;
  transform: translateY(-160%);
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.nowrap {
  white-space: nowrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-0 {
  margin-bottom: 0;
}

/* =========================================================
   Header
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  width: min(1040px, 100%);
  min-height: var(--header-height);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  border-radius: 10px;
  padding: 4px;
  margin-left: -4px;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.14rem;
  letter-spacing: -0.02em;
}

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

.brand-text small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
}

.icon-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-sun,
.theme-moon {
  display: none;
}

:root:not([data-theme="dark"]) .theme-moon,
[data-theme="dark"] .theme-sun {
  display: block;
}

.update-banner {
  background: var(--accent-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.update-banner .inner {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.update-banner button {
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  font-weight: 700;
  min-height: 44px;
}

.lib-loading {
  width: min(960px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--accent-soft-2);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-soft);
  font-size: 0.88rem;
}

.lib-warning {
  width: min(960px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.92rem;
}

/* =========================================================
   Layout & pages
   ========================================================= */
#main-content {
  flex: 1 0 auto;
  width: 100%;
}

.page {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 64px;
}

.tool-page,
.narrow-page {
  width: min(720px, calc(100% - 32px));
}

.history-page {
  width: min(920px, calc(100% - 32px));
}

.kit-page {
  width: min(840px, calc(100% - 32px));
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 10px 8px 4px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 650;
  border-radius: 8px;
}

.back-link:hover {
  color: var(--accent);
}

.back-link svg {
  width: 19px;
  height: 19px;
}

.tool-heading {
  margin-bottom: 22px;
}

.tool-heading h1 {
  margin-bottom: 7px;
}

.tool-heading p {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 62ch;
}

.panel > .alert {
  margin-bottom: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel + .panel {
  margin-top: 18px;
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-title {
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title h2,
.section-title h3 {
  margin: 0;
}

.section-sub {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.site-footer .inner {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
}

.site-footer p {
  margin: 0;
}

.footer-support {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.footer-support-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-support-btn {
  min-height: 44px;
}

.footer-support-btn svg {
  color: var(--accent);
}

.footer-version {
  margin-top: 7px !important;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

/* =========================================================
   Home
   ========================================================= */
.home-hero {
  max-width: 720px;
  margin: 10px 0 30px;
}

.home-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.home-hero .eyebrow svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.home-hero h1 {
  margin-bottom: 12px;
  max-width: 620px;
  font-size: clamp(1.9rem, 1.45rem + 1.9vw, 2.8rem);
}

.home-hero p {
  margin-bottom: 0;
  max-width: 600px;
  color: var(--muted);
  font-size: 1.02rem;
}

.home-section {
  margin-top: 28px;
}

.home-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.home-section-head h2 {
  margin: 0;
  font-size: 1.12rem;
}

.home-section-head span {
  color: var(--muted);
  font-size: 0.83rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-height: 142px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.tool-card:hover {
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-card-icon svg {
  width: 24px;
  height: 24px;
}

.tool-card h3 {
  margin: 0;
  font-size: 0.99rem;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.845rem;
  line-height: 1.45;
}

.tool-card-kit {
  grid-column: 1 / -1;
}

.kit-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.kit-banner:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kit-banner-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
}

.kit-banner-icon svg {
  width: 30px;
  height: 30px;
}

.kit-banner-body {
  flex: 1 1 auto;
  min-width: 0;
}

.kit-banner .eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.kit-banner h2 {
  margin: 0 0 5px;
  font-size: 1.2rem;
}

.kit-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.kit-banner-cta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.92rem;
}

.kit-banner-cta svg {
  width: 18px;
  height: 18px;
}

/* =========================================================
   Alerts & privacy
   ========================================================= */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.alert svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.alert-error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.alert-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.alert-info {
  border-color: var(--accent-soft-2);
  background: var(--accent-soft);
  color: var(--text-soft);
}

.alert-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.privacy {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.45;
}

.privacy svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--muted);
}

.privacy-list {
  margin-top: 14px;
}

/* =========================================================
   Forms & buttons
   ========================================================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > label,
.field-label,
legend {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.field-hint,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

input[type="text"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

input[type="text"]:disabled,
input[type="number"]:disabled,
select:disabled {
  opacity: 0.58;
  background: var(--surface-2);
}

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

input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.input-with-unit {
  display: flex;
  gap: 8px;
}

.input-with-unit input {
  flex: 1 1 auto;
  min-width: 0;
}

.input-with-unit select {
  flex: 0 0 96px;
  width: 96px;
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 44px;
}

.input-suffix span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.option-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.option-group > legend {
  padding: 0;
  margin-bottom: 10px;
}

.radio-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 52px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.radio-card:hover {
  border-color: var(--border-strong);
}

.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.radio-card:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.radio-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.radio-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
}

.radio-card:has(input:checked) .radio-dot {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 4px var(--accent);
}

.radio-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.radio-body strong {
  font-size: 0.93rem;
}

.radio-body small {
  color: var(--muted);
  font-size: 0.81rem;
  line-height: 1.45;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 650;
}

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

.preset-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-soft);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
}

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

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-danger-ghost:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.84rem;
  border-radius: 8px;
}

.btn-xs {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 0.79rem;
  border-radius: 7px;
}

.btn[disabled] {
  opacity: 0.52;
  box-shadow: none;
}

.btn-primary[disabled] {
  background: var(--border-strong);
  border-color: var(--border-strong);
  color: var(--surface);
}

.btn-icon-only {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.kbd-hint {
  margin: 9px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.77rem;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-family: var(--font);
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Dropzone
   ========================================================= */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 166px;
  padding: 28px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

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

.dropzone:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.dropzone.is-compact {
  min-height: 100px;
  padding: 16px;
  flex-direction: row;
  gap: 12px;
  text-align: left;
}

.dropzone.is-compact .dz-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.dropzone.is-compact .dz-icon svg {
  width: 22px;
  height: 22px;
}

.dz-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.dz-icon svg {
  width: 34px;
  height: 34px;
}

.dz-title {
  display: block;
  margin: 0;
  font-size: 0.98rem;
  font-weight: 750;
  line-height: 1.35;
}

.dz-hint {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.dropzone.is-busy {
  pointer-events: none;
  opacity: 0.62;
}

.tool-page.is-busy .dropzone,
.tool-page.is-busy .file-list-wrap {
  pointer-events: none;
}

/* =========================================================
   File display
   ========================================================= */
.file-chip {
  display: flex;
  margin-top: 12px;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.file-type-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}

.file-type-icon svg {
  width: 21px;
  height: 21px;
}

.file-chip-body {
  flex: 1 1 auto;
  min-width: 0;
}

.file-name {
  display: block;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: block;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.file-list-wrap {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}

.list-head p {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 650;
  color: var(--text-soft);
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.selected-list,
.result-list,
.sort-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.selected-list {
  max-height: 330px;
  overflow-y: auto;
}

.selected-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
}

.selected-row:last-child {
  border-bottom: 0;
}

.selected-row .file-type-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.selected-row .file-type-icon svg {
  width: 18px;
  height: 18px;
}

.selected-row .btn-icon-only {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  cursor: grab;
}

.sort-row:last-child {
  border-bottom: 0;
}

.sort-row.is-dragging {
  opacity: 0.48;
}

.sort-row.is-over {
  background: var(--accent-soft);
  box-shadow: inset 0 2px 0 var(--accent);
}

.sort-index {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
}

.sort-row .file-chip-body {
  flex: 1 1 auto;
}

.sort-controls {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.sort-controls .btn-icon-only {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
}

.drag-handle {
  color: var(--muted);
  display: grid;
  place-items: center;
  width: 22px;
  flex: 0 0 auto;
}

.drag-handle svg {
  width: 18px;
  height: 18px;
}

/* =========================================================
   Progress
   ========================================================= */
.progress-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--range-track);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 200ms ease;
}

.progress-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* =========================================================
   Results
   ========================================================= */
.result-card {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--text);
}

.result-card.is-neutral {
  border-color: var(--border);
  background: var(--surface-2);
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 13px;
}

.result-head h3 {
  margin: 0;
  font-size: 1rem;
}

.result-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge svg {
  width: 14px;
  height: 14px;
}

.badge-success {
  border-color: var(--success-border);
  color: var(--success);
}

.badge-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

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

.badge-accent {
  border-color: var(--accent-soft-2);
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-muted {
  color: var(--muted);
}

.size-compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.size-box {
  min-width: 0;
}

.size-box span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
}

.size-box strong {
  display: block;
  margin-top: 2px;
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.compare-arrow {
  color: var(--muted);
}

.compare-arrow svg {
  width: 20px;
  height: 20px;
}

.savings-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 11px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.result-note {
  margin: 10px 0 0;
  color: var(--warning);
  font-size: 0.82rem;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.result-actions .btn {
  width: 100%;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.result-row.is-error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.result-row .file-chip-body {
  flex: 1 1 auto;
}

.result-row .btn {
  flex: 0 0 auto;
}

.result-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.result-summary strong {
  color: var(--text);
}

.zip-actions {
  margin-top: 12px;
}

.zip-actions .btn {
  width: 100%;
}

/* =========================================================
   History
   ========================================================= */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head h1 {
  margin-bottom: 5px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.history-table th,
.history-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.history-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.history-table td:first-child {
  font-weight: 650;
  color: var(--text-soft);
  white-space: nowrap;
}

.history-file {
  max-width: 260px;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  color: var(--border-strong);
}

.empty-state h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
  color: var(--text);
}

.empty-state p {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.disclaimer svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
}

/* =========================================================
   Document previews
   ========================================================= */
.preview-area {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.preview-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.doc-preview {
  position: relative;
  width: 176px;
  aspect-ratio: 1 / 1.414;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.doc-preview-watermark {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: 150%;
  transform: translate(-50%, -50%) rotate(-45deg);
  transform-origin: center;
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.doc-preview-number {
  position: absolute;
  max-width: calc(100% - 16px);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-preview-number.pos-bottom-center {
  left: 50%;
  bottom: 7px;
  transform: translateX(-50%);
}

.doc-preview-number.pos-bottom-right {
  right: 9px;
  bottom: 7px;
  text-align: right;
}

.doc-preview-number.pos-top-right {
  right: 9px;
  top: 8px;
  text-align: right;
}

.preview-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.thumb-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.thumb-box canvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 310px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.thumb-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* =========================================================
   Crop editor
   ========================================================= */
.crop-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crop-stage {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
  line-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.crop-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crop-box {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px var(--dim);
  cursor: move;
  touch-action: none;
}

.crop-box:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.crop-handle {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
  touch-action: none;
}

.crop-handle::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 11px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 3px;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

.crop-handle[data-handle="nw"] {
  left: -16px;
  top: -16px;
  cursor: nwse-resize;
}

.crop-handle[data-handle="n"] {
  left: calc(50% - 16px);
  top: -16px;
  cursor: ns-resize;
}

.crop-handle[data-handle="ne"] {
  right: -16px;
  top: -16px;
  cursor: nesw-resize;
}

.crop-handle[data-handle="e"] {
  right: -16px;
  top: calc(50% - 16px);
  cursor: ew-resize;
}

.crop-handle[data-handle="se"] {
  right: -16px;
  bottom: -16px;
  cursor: nwse-resize;
}

.crop-handle[data-handle="s"] {
  left: calc(50% - 16px);
  bottom: -16px;
  cursor: ns-resize;
}

.crop-handle[data-handle="sw"] {
  left: -16px;
  bottom: -16px;
  cursor: nesw-resize;
}

.crop-handle[data-handle="w"] {
  left: -16px;
  top: calc(50% - 16px);
  cursor: ew-resize;
}

.crop-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
}

.crop-meta p {
  margin: 0;
}

/* =========================================================
   Kit dokumen
   ========================================================= */
.kit-template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.kit-template-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.kit-template-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kit-template-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.kit-template-icon svg {
  width: 26px;
  height: 26px;
}

.kit-template-card h2 {
  margin: 2px 0 0;
  font-size: 1.06rem;
}

.kit-template-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.kit-template-card .kit-template-go {
  margin-top: auto;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
}

.kit-wizard {
  margin-top: 4px;
}

.wizard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.wizard-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wizard-progress {
  display: flex;
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  gap: 0;
}

.wizard-progress li {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
}

.wizard-progress li::before {
  content: "";
  position: absolute;
  top: 15px;
  left: calc(-50% + 17px);
  right: calc(50% + 17px);
  height: 2px;
  background: var(--border);
}

.wizard-progress li:first-child::before {
  display: none;
}

.wizard-progress li.is-done::before,
.wizard-progress li.is-active::before {
  background: var(--accent);
}

.wizard-dot {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.wizard-progress li.is-active {
  color: var(--accent);
}

.wizard-progress li.is-active .wizard-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.wizard-progress li.is-done {
  color: var(--text-soft);
}

.wizard-progress li.is-done .wizard-dot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.wizard-progress li.is-skipped .wizard-dot {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.wizard-progress li.is-skipped {
  color: var(--warning);
}

.wizard-progress .wizard-dot svg {
  width: 15px;
  height: 15px;
}

.wizard-step-head {
  margin-bottom: 16px;
}

.wizard-step-head h2 {
  margin: 2px 0 6px;
  font-size: 1.35rem;
}

.wizard-step-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.91rem;
}

.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.wizard-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.kit-result {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-bg);
}

.kit-result.is-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.kit-result-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface);
  color: var(--success);
}

.kit-result.is-warning .kit-result-icon {
  color: var(--warning);
}

.kit-result-icon svg {
  width: 21px;
  height: 21px;
}

.kit-result-body {
  flex: 1 1 auto;
  min-width: 0;
}

.kit-result-body strong {
  display: block;
  font-size: 0.9rem;
}

.kit-result-body p {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.kit-thumb {
  width: 54px;
  height: 72px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.kit-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kit-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.kit-file-row .file-type-icon {
  width: 34px;
  height: 34px;
}

.kit-file-row .file-type-icon svg {
  width: 18px;
  height: 18px;
}

.kit-file-row .btn-icon-only {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
}

.kit-review-name {
  max-width: 320px;
}

.kit-review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.kit-review-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  flex-wrap: wrap;
}

.kit-review-row.is-skipped {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.kit-review-row .file-chip-body {
  flex: 1 1 210px;
}

.kit-review-name-file {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.kit-review-meta {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.kit-review-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.kit-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.84rem;
}

.kit-summary-bar p {
  margin: 0;
  color: var(--muted);
}

.kit-summary-bar strong {
  color: var(--text);
}

.kit-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.81rem;
}

/* =========================================================
   Toast
   ========================================================= */
.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 10px 11px 13px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-left-color: var(--accent);
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 160ms ease-out;
}

.toast.toast-error {
  border-left-color: var(--danger);
  background: var(--toast-error-bg);
}

.toast.toast-success {
  border-left-color: var(--success);
  background: var(--toast-success-bg);
}

.toast.toast-info {
  border-left-color: var(--accent);
  background: var(--toast-info-bg);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.toast-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-close {
  width: 44px;
  min-width: 44px;
  height: 44px;
  margin: -8px -8px -8px 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  opacity: 0.8;
}

.toast-close:hover {
  opacity: 1;
  background: var(--overlay);
}

.toast-close svg {
  width: 15px;
  height: 15px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (min-width: 640px) {
  .tool-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .tool-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .page {
    padding-top: 36px;
  }
}

@media (max-width: 760px) {
  .kit-template-grid {
    grid-template-columns: 1fr;
  }

  .kit-template-card {
    min-height: 0;
  }

  .kit-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .kit-banner-cta {
    margin-left: 74px;
  }
}

@media (max-width: 639px) {
  :root {
    --header-height: 60px;
  }

  body {
    font-size: 15px;
  }

  .header-inner {
    padding: 8px 12px;
    gap: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }

  .brand-mark svg {
    width: 20px;
    height: 20px;
  }

  .brand-text strong {
    font-size: 1.03rem;
  }

  .brand-text small,
  .icon-btn .btn-label {
    display: none;
  }

  .icon-btn {
    padding: 0;
    width: 44px;
    min-width: 44px;
  }

  .header-actions {
    gap: 1px;
  }

  .page,
  .tool-page,
  .narrow-page,
  .history-page,
  .kit-page {
    width: calc(100% - 24px);
    padding-top: 22px;
    padding-bottom: 48px;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .dropzone {
    min-height: 150px;
    padding: 24px 14px;
  }

  .dropzone.is-compact {
    min-height: 88px;
    padding: 13px;
  }

  .tool-card {
    min-height: 136px;
    padding: 14px;
  }

  .tool-card h3 {
    font-size: 0.94rem;
  }

  .tool-card p {
    font-size: 0.8rem;
  }

  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .kit-banner {
    padding: 16px;
    gap: 13px;
  }

  .kit-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }

  .kit-banner h2 {
    font-size: 1.06rem;
  }

  .kit-banner-cta {
    margin-left: 61px;
  }

  .kit-template-card {
    padding: 16px;
  }

  .wizard-progress li {
    font-size: 0.65rem;
  }

  .wizard-dot {
    width: 29px;
    height: 29px;
  }

  .wizard-progress li::before {
    top: 14px;
    left: calc(-50% + 15px);
    right: calc(50% + 15px);
  }

  .wizard-actions {
    align-items: stretch;
  }

  .wizard-actions-right {
    width: 100%;
    margin-left: 0;
  }

  .wizard-actions-right .btn {
    flex: 1 1 auto;
  }

  .doc-preview {
    width: 150px;
  }

  .compare-arrow {
    transform: rotate(90deg);
  }

  .size-compare {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .selected-list {
    max-height: 280px;
  }

  .sort-row {
    flex-wrap: wrap;
  }

  .sort-row .drag-handle,
  .sort-row .file-type-icon {
    display: none;
  }

  .sort-row .file-chip-body {
    flex: 1 1 calc(100% - 70px);
  }

  .sort-row .sort-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .footer-support {
    flex-direction: column;
    gap: 9px;
  }

  .footer-support-note {
    max-width: 34ch;
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .update-banner .inner {
    padding: 7px 12px;
  }

  .history-table {
    min-width: 620px;
  }
}

@media (max-width: 420px) {
  .tool-card {
    min-height: 0;
    padding: 14px;
  }

  .kit-banner-cta {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .kit-thumb {
    width: 46px;
    height: 61px;
  }

  .result-row {
    flex-wrap: wrap;
  }

  .result-row .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================
   SEO content, FAQ & related links
   ========================================================= */
.home-seo {
  max-width: 820px;
  margin: 46px auto 0;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.home-seo h2 {
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.home-seo h3 {
  margin-bottom: 8px;
}

.seo-lead {
  max-width: 74ch;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.7;
}

.seo-benefits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 30px;
}

.seo-benefit {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.seo-benefit h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  font-size: 0.94rem;
}

.seo-benefit h3 svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--accent);
}

.seo-benefit p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.seo-subhead {
  margin: 30px 0 12px;
  font-size: 1.14rem;
}

.seo-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: seo-step;
}

.seo-steps li {
  position: relative;
  padding: 14px 14px 14px 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
}

.seo-steps li::before {
  counter-increment: seo-step;
  content: counter(seo-step);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.73rem;
  font-weight: 800;
}

.seo-steps strong {
  color: var(--text);
}

.seo-copy {
  max-width: 74ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.seo-copy a {
  color: var(--accent);
  font-weight: 650;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.faq-item {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.faq-item summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 46px 12px 14px;
  list-style: none;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1;
}

.faq-item[open] summary {
  background: var(--accent-soft);
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item p {
  margin: 0;
  padding: 2px 14px 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.seo-related {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}

.seo-related a {
  color: var(--accent);
  font-weight: 650;
}

.seo-updated {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

@media (max-width: 760px) {
  .seo-benefits,
  .seo-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 639px) {
  .home-seo {
    margin-top: 36px;
    padding-top: 26px;
  }

  .seo-benefit {
    padding: 14px;
  }

  .faq-item summary {
    font-size: 0.86rem;
  }
}



/* =========================================================
   CSP-safe utility classes
   ========================================================= */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.input-narrow {
  max-width: 120px;
}

.inline-icon {
  vertical-align: -2px;
}

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

/* =========================================================
   Portal checker & PDF page organizer
   ========================================================= */
.tool-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  border: 1px solid var(--accent-soft-2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.role-select {
  flex: 1 1 140px;
  width: auto;
  max-width: 190px;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.checker-file-list .selected-row {
  flex-wrap: wrap;
}

.check-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.check-result.is-error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.check-result.is-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.check-result.is-ok {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.check-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.check-file-name {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.check-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-issue {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

.check-issue svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--muted);
}

.check-issue.is-error {
  color: var(--danger);
}

.check-issue.is-warning {
  color: var(--warning);
}

.check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.checker-disclaimer {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.atur-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.atur-counter {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.page-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--muted);
  font-size: 0.7rem;
}

.page-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

.page-rotation {
  font-size: 0.68rem;
}

.page-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  max-height: 190px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-2);
}

.page-thumb canvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 178px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.page-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  margin-top: auto;
}

.page-controls .btn-icon-only {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
}

@media (max-width: 760px) {
  .page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .role-select {
    flex-basis: 100%;
    width: 100%;
    max-width: none;
  }
}
