:root {
  --yellow: #ffd200;
  --yellow-strong: #f2c200;
  --yellow-soft: #fff6cc;
  --blue: #1f4e9c;
  --cyan: #1fb3d3;
  --ink: #26292e;
  --ink-2: #545a63;
  --muted: #6f7680;
  --line: #dfe2e6;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ok: #1d7a46;
  --ok-bg: #e3f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff1cc;
  --bad: #b3261e;
  --bad-bg: #fce8e6;
  --focus: #1f4e9c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --yellow-soft: #3a3214;
    --blue: #8fb4ff;
    --cyan: #5fd0ea;
    --ink: #e9ebee;
    --ink-2: #c3c8cf;
    --muted: #9aa1ab;
    --line: #353a42;
    --bg: #15171b;
    --surface: #1e2126;
    --surface-2: #262a30;
    --ok: #7fd6a2;
    --ok-bg: #173323;
    --warn: #ffd36b;
    --warn-bg: #3a2f12;
    --bad: #ff8f86;
    --bad-bg: #3d1a18;
    --focus: #ffd200;
    --shadow: none;
    color-scheme: dark;
  }
  .brand-logo, .eu-logo { background: #fff; border-radius: 8px; padding: 4px 6px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-top: 24px; padding-bottom: 48px; }
.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
h2 { font-size: 1.3rem; margin: 0 0 8px; }
h3 { font-size: 1.05rem; margin: 20px 0 6px; }
a { color: var(--blue); }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.optional { font-weight: 400; color: var(--muted); font-size: .9em; }
.hint { color: var(--ink-2); margin: 0 0 16px; }
.fine { color: var(--muted); font-size: .85rem; max-width: 640px; margin: 12px auto 0; text-align: center; }
.icon { width: 20px; height: 20px; flex: none; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; min-width: 0; }
.brand-logo { height: 44px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; border-left: 1px solid var(--line); padding-left: 14px; min-width: 0; }
.brand-title { font-weight: 700; }
.brand-sub { font-size: .85rem; color: var(--muted); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  appearance: none; border: 0; background: none; font: inherit; color: var(--ink-2);
  padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--yellow); }
.tabs button:hover { color: var(--ink); }
.count { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; background: var(--surface-2); font-size: .8rem; font-weight: 600; }
.count:empty { display: none; }
.banner { background: var(--warn-bg); color: var(--warn); padding: 8px 0; font-size: .9rem; }

/* Buttons */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .95rem; line-height: 1.2; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-ghost { border-color: transparent; background: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue); filter: brightness(1.1); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0d1526; } }
.btn-danger { color: var(--bad); border-color: currentColor; }
.btn-danger:hover { background: var(--bad-bg); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.yellow-button {
  appearance: none; display: inline-flex; align-items: center; gap: 14px;
  font: inherit; font-size: 1.15rem; font-weight: 700; color: #26292e;
  background: var(--yellow); border: 0; border-radius: 14px; padding: 14px 28px 14px 18px;
  box-shadow: 0 2px 0 var(--yellow-strong), 0 6px 18px rgba(255, 210, 0, .35); cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.yellow-button img { width: 30px; height: auto; filter: brightness(0) saturate(100%) invert(14%); }
.yellow-button:hover { background: var(--yellow-strong); }
.yellow-button:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--yellow-strong); }
.yellow-button:disabled { opacity: .6; cursor: progress; }

/* Steps & forms */
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.step-action { text-align: center; background: none; border: 0; box-shadow: none; padding-top: 8px; }
.step-no { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--yellow); color: #26292e; font-size: .95rem; margin-right: 6px; vertical-align: 2px; }
.field { margin-bottom: 18px; }
.field > label, .field label:first-child { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input:not([type]), input[type=password], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; resize: vertical; }
select { width: auto; min-width: 220px; }
.help { color: var(--ink-2); font-size: .88rem; margin: 6px 0 0; max-width: 720px; }
.field-foot { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.counter { color: var(--muted); font-size: .8rem; padding-top: 6px; font-variant-numeric: tabular-nums; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; }
.checkbox-field { display: flex; gap: 10px; align-items: flex-start; }
.checkbox-field input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.checkbox-field label { margin: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap-row { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.summary { margin: 4px 0 0; padding: 10px 14px; border-radius: 8px; background: var(--yellow-soft); font-size: .92rem; }
.summary:empty { display: none; }
.error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 10px 14px; text-align: left; max-width: 640px; margin: 12px auto 0; }
.field-msg { font-size: .88rem; color: var(--ink-2); }
.field-msg.bad { color: var(--bad); }
.field-msg.ok { color: var(--ok); }

/* Bundles */
.bundle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.bundle-card { position: relative; display: flex; flex-direction: column; gap: 6px; border: 2px solid var(--line); border-radius: 10px; padding: 14px; cursor: pointer; background: var(--surface); }
.bundle-card:hover { border-color: var(--muted); }
.bundle-card:has(input:checked) { border-color: var(--yellow-strong); background: var(--yellow-soft); }
.bundle-card:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.bundle-card input { position: absolute; opacity: 0; pointer-events: none; }
.bundle-title { font-weight: 700; padding-right: 26px; }
.bundle-card .check { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); }
.bundle-card:has(input:checked) .check { border-color: #26292e; background: var(--yellow) center/14px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3 3 7-7' fill='none' stroke='%2326292e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.bundle-desc { font-size: .9rem; color: var(--ink-2); margin: 0; }
.bundle-meta { font-size: .8rem; color: var(--muted); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 4px; }
.chip { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.bundle-card .preview-btn { align-self: flex-start; margin-top: 4px; }
.own-bundle { margin-top: 14px; }
.own-bundle summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.own-bundle-body { padding-top: 10px; display: grid; gap: 6px; max-width: 720px; }
.own-bundle-body label { font-weight: 600; font-size: .9rem; margin-top: 6px; }

/* Result / link detail */
.result { margin-top: 24px; scroll-margin-top: 140px; }
.result:focus { outline: none; }
.link-detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.link-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.link-detail-head h3 { margin: 0; font-size: 1.15rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.link-grid { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 24px; align-items: start; }
.qr-box { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.qr-frame { background: #fff; padding: 12px; border-radius: 12px; border: 3px solid var(--yellow); width: 100%; max-width: 300px; }
.qr-frame canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-caption { font-size: .8rem; color: var(--muted); text-align: center; margin: 0; }
.link-text { display: flex; gap: 8px; margin-bottom: 4px; }
.link-text input { font: .82rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-width: 0; flex: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 14px 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-active { color: var(--ok); background: var(--ok-bg); }
.status-expired, .status-locked { color: var(--warn); background: var(--warn-bg); }
.status-revoked { color: var(--bad); background: var(--bad-bg); }
.status-unknown { color: var(--muted); background: var(--surface-2); }
.log { width: 100%; border-collapse: collapse; font-size: .85rem; }
.log th, .log td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.log th { color: var(--muted); font-weight: 600; }
.log-wrap { overflow-x: auto; }
.section-title { font-size: .95rem; font-weight: 700; margin: 18px 0 6px; }
.checked-at { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }
.note {font-size: .85rem; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 10px 0 0; }

/* Links list */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar h2 { margin: 0; }
.links-list { display: grid; gap: 10px; }
.link-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.link-item > summary { list-style: none; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px; cursor: pointer; }
.link-item > summary::-webkit-details-marker { display: none; }
.link-item-title { font-weight: 600; overflow-wrap: anywhere; }
.link-item-meta { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); }
.link-item[open] > summary { border-bottom: 1px solid var(--line); }
.link-item .link-detail-head { display: none; }
.link-item .link-detail {border: 0; box-shadow: none; border-radius: 0 0 var(--radius) var(--radius); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty img { width: 56px; height: auto; opacity: .9; margin-bottom: 8px; }

/* Test viewer */
.test-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.test-result { margin-top: 20px; }
.viewer-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.viewer-card h3 { margin-top: 0; }
.doc-section { border-top: 1px solid var(--line); padding: 12px 0; }
.doc-section h4 { margin: 0 0 6px; font-size: .98rem; }
.narrative { font-size: .9rem; color: var(--ink-2); white-space: pre-line; max-height: 280px; overflow: auto; }
pre.json { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow: auto; max-height: 420px; font-size: .78rem; margin: 8px 0 0; }
details.plain > summary { cursor: pointer; color: var(--blue); font-weight: 600; margin-top: 8px; }

/* Prose / about */
.prose { max-width: 720px; }
.prose p, .prose li { color: var(--ink-2); }
.about-icon { float: right; margin: 0 0 12px 20px; width: 88px; height: auto; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 20px 0; font-size: .78rem; color: var(--muted); }
.footer-inner { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; align-items: center; }
.footer-inner p { margin: 0; grid-column: 2; }
.eu-logo { grid-row: span 2; height: 44px; width: auto; }

/* Dialog & toast */
dialog { border: 0; border-radius: var(--radius); padding: 24px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dialog-actions { margin-top: 8px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #26292e; color: #fff; padding: 10px 18px; border-radius: 99px; font-size: .9rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 100; max-width: calc(100vw - 32px); }

@media (max-width: 720px) {
  .link-grid { grid-template-columns: 1fr; }
  .qr-box { order: -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .brand-logo { height: 34px; }
  .brand-sub { display: none; }
  .brand-title { font-size: .95rem; }
  #open-settings span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .header-inner { padding-top: 8px; padding-bottom: 4px; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-inner p { grid-column: 1; }
  .eu-logo { grid-row: auto; }
  .yellow-button { width: 100%; justify-content: center; }
  select { width: 100%; }
  .about-icon { width: 64px; }
}
