@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f4f4f8;
  --surface: #ffffff;
  --surface-2: #f3f3f8;
  --text: #16161f;
  --muted: #575c6e;
  --border: #dcdde8;
  --border-strong: #b9bccc;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-text: #ffffff;
  --accent-soft: #f1eafe;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #17703a;
  --warn: #a15c07;
  --warn-soft: #fdf3e1;
  --info-soft: #eef1fd;
  --focus: #2563eb;
  --preview: #0d0d12;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 22, 31, 0.05), 0 4px 14px rgba(22, 22, 31, 0.05);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-sticky: 10;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e14;
    --surface: #17171f;
    --surface-2: #1f1f2a;
    --text: #ececf3;
    --muted: #a3a6b8;
    --border: #2b2c3a;
    --border-strong: #454760;
    --accent: #7c3aed;
    --accent-hover: #8b52f0;
    --accent-soft: #241a3f;
    --danger: #ff7a70;
    --danger-soft: #331a1b;
    --success: #4ade80;
    --warn: #f5b942;
    --warn-soft: #2e2413;
    --info-soft: #1b1e33;
    --focus: #7aa7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
}

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

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; min-width: 0; }
.brandmark span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text);
}
.brand-tile .icon { width: 17px; height: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.container { max-width: 860px; margin: 0 auto; padding: 28px 20px 72px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }

h1, h2, h3 { text-wrap: balance; letter-spacing: -0.015em; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; }
h2 { font-size: 1.0625rem; line-height: 1.3; margin: 0; }
h3 { font-size: 0.9375rem; margin: 0; }
p { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex; flex-direction: column; gap: 16px;
}
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { display: flex; align-items: flex-start; gap: 12px; min-width: 0; flex: 1 1 260px; }
.section-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
@media (prefers-color-scheme: dark) { .section-icon { color: #c4a8ff; } }
.section-sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; max-width: 62ch; }

.auth { display: flex; justify-content: center; padding: 6vh 0 0; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 30px 28px 26px;
  display: flex; flex-direction: column; gap: 20px;
}
.auth-head { display: flex; flex-direction: column; gap: 6px; }
.auth-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 13px; margin-bottom: 8px;
  background: var(--accent); color: var(--accent-text);
}
.auth-mark .icon { width: 23px; height: 23px; }
.auth-sub { color: var(--muted); font-size: 0.9375rem; }
.auth-foot { color: var(--muted); font-size: 0.85rem; padding-top: 16px; border-top: 1px solid var(--border); }
body.is-auth {
  background:
    radial-gradient(52rem 26rem at 50% -8rem, var(--accent-soft), transparent 72%),
    var(--bg);
  background-repeat: no-repeat;
}
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 12vh 0; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field label, .field-label label { font-weight: 600; font-size: 0.875rem; }
.counter { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.field-hint { color: var(--muted); font-size: 0.8125rem; line-height: 1.4; display: flex; align-items: flex-start; gap: 6px; }
.field-hint .icon { width: 14px; height: 14px; margin-top: 2px; }
.field-hint.ok { color: var(--success); }
.field-hint.warn { color: var(--warn); }
.field-hint.error { color: var(--danger); }

input[type="text"], input[type="url"], input[type="password"], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-height: 42px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover { border-color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--danger); }
.control { position: relative; display: flex; align-items: center; }
.control-icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.control .control-icon ~ input { padding-left: 38px; }
.control.has-reveal input { padding-right: 44px; }
.reveal {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.reveal:hover { color: var(--text); background: var(--surface-2); }
.lang-select { width: auto; min-height: 36px; padding: 6px 10px; background: var(--surface-2); border-color: var(--border); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600;
  min-height: 40px; padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.icon-only { min-width: 40px; padding: 8px; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 0.875rem; }
.btn.block { width: 100%; min-height: 44px; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 35%, transparent); border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}

.msg { font-size: 0.875rem; min-height: 1.3em; }
.msg:empty { min-height: 0; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--success); }

.guide {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--info-soft);
  padding: 18px 22px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 22px; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; align-items: start; align-content: start; }
.steps li::before {
  content: counter(step); grid-row: span 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 700;
}
.steps strong { font-size: 0.9375rem; }
.steps span { grid-column: 2; color: var(--muted); font-size: 0.875rem; }

.portal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.portal {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px 12px;
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color 160ms var(--ease);
}
.portal:focus-within { border-color: var(--border-strong); }
.portal.disabled .portal-fields { opacity: 0.6; }
.portal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.portal-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8125rem; font-weight: 650;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface);
}
.portal-badge.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.portal-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 14px; align-items: start; transition: opacity 160ms var(--ease); }
.portal-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.portal-actions .spacer { flex: 1; }

.switch { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 0.875rem; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 38px; height: 22px; border-radius: 999px;
  background: var(--border-strong); border: 0; cursor: pointer; position: relative;
  transition: background-color 180ms var(--ease);
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 180ms var(--ease);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); text-align: center; padding: 24px 16px;
  border: 1px dashed var(--border-strong); border-radius: 12px;
}
.empty strong { color: var(--text); }

.help { border-top: 1px solid var(--border); padding-top: 12px; }
.help + .help { margin-top: -4px; }
.help summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  font-weight: 600; font-size: 0.875rem; color: var(--muted);
  border-radius: 6px;
}
.help summary::-webkit-details-marker { display: none; }
.help summary:hover, .help[open] summary { color: var(--text); }
.help summary::after {
  content: ""; width: 7px; height: 7px; margin-left: auto; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform 180ms var(--ease);
}
.help[open] summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.help-body { padding: 10px 0 2px 26px; color: var(--muted); font-size: 0.875rem; max-width: 68ch; display: flex; flex-direction: column; gap: 10px; }
.help-body code {
  font: 0.8125rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; color: var(--text);
  overflow-wrap: anywhere;
}

.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--info-soft); border: 1px solid var(--border);
  font-size: 0.875rem; color: var(--text);
}
.callout > .icon { margin-top: 1px; color: var(--muted); }
.callout p { max-width: 70ch; }

.warning {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--warn-soft); border: 1px solid var(--warn);
  animation: rise 220ms var(--ease);
}
.warning > .icon { width: 20px; height: 20px; margin-top: 1px; color: var(--warn); }
.warning-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.warning ul { margin: 0; padding-left: 18px; }
.warning li { overflow-wrap: anywhere; }
.warning p { font-size: 0.875rem; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.savebar {
  position: sticky; bottom: 14px; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px 10px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.save-state { display: inline-flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 200px; }
.save-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--border-strong); transition: background-color 180ms var(--ease); }
.savebar.is-dirty .save-dot { background: var(--warn); }
.savebar.is-saved .save-dot { background: var(--success); }
.savebar.is-error .save-dot { background: var(--danger); }
.savebar.is-busy .save-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.asset-block { display: flex; flex-direction: column; gap: 6px; }
.asset-list { list-style: none; margin: 0; padding: 0; }
.asset {
  display: flex; gap: 16px; padding: 14px; align-items: center;
  border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2);
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.asset.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.asset-preview {
  flex: 0 0 132px; height: 84px; border-radius: 10px; padding: 10px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--preview); color: #a3a6b8; font-size: 0.75rem; text-align: center;
}
.asset-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.asset-info .portal-actions { margin-top: 8px; }
.hint-inline { display: block; color: var(--muted); font-size: 0.8125rem; }

@media (max-width: 600px) {
  .topbar { padding: 10px 14px; }
  .container { padding: 18px 12px 56px; }
  .card { padding: 16px; }
  .guide { padding: 16px; }
  .auth { padding-top: 2vh; }
  .auth-card { padding: 24px 20px 20px; }
  .portal-fields { grid-template-columns: 1fr; }
  .asset { flex-direction: column; align-items: stretch; }
  .asset-preview { flex-basis: auto; height: 96px; }
  .savebar .btn { flex: 1; }
  .btn-label-wide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.field-hint:empty { display: none; }
