/* HBLAB Shorten — app styles (2026 redesign). No framework; tokens follow the design canvas. */
:root {
  --hbl-yellow: #FDC010;
  --hbl-yellow-soft: #FFF4CC;
  --hbl-yellow-tint: #FFFAEB;
  --hbl-yellow-ink: #8A6500;
  --charcoal: #232325;
  --charcoal-2: #2B2B2E;
  --charcoal-3: #3A3A3E;
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #FAF9F6;
  --ink: #1F1F21;
  --ink-2: #4A4A50;
  --muted: #5B5B61;
  --line: #E2E0D9;
  --line-2: #ECEAE4;
  --field: #D3D1CA;
  --nav-ink: #E4E4E7;
  --nav-muted: #A1A1A8;
  --nav-dim: #C9C9CE;
  --link: #1D4F91;
  --link-hover: #123663;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --success: #1E6B3A;
  --success-soft: #E5F4EA;
  --font-head: Archivo, system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
}
:lang(ja) body, body:lang(ja) { font-family: 'IBM Plex Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo, sans-serif; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; }
p { margin: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--hbl-yellow);
  outline-offset: 1px;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--hbl-yellow); color: var(--ink); padding: 10px 16px; border-radius: var(--radius); font-weight: 600;
}
.skip-link:focus { top: 8px; }
.mono { font-family: var(--font-mono); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark { display: block; width: 22px; height: 22px; background: var(--hbl-yellow); transform: skewX(-14deg); flex: none; }
.brand-hbl { font: 800 20px var(--font-head); letter-spacing: 0.04em; }
.brand-name { font: 600 20px var(--font-head); color: var(--nav-dim); }
.brand-sm .brand-mark { width: 16px; height: 16px; }
.brand-sm .brand-hbl, .brand-sm .brand-name { font-size: 16px; }

/* ---------- Language switcher (flags) ---------- */
.lang-switch { display: flex; gap: 4px; margin: 0; }
.lang-switch button {
  height: 36px; min-width: 44px; padding: 0 10px; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.lang-switch button:hover { background: var(--charcoal-3); }
.lang-switch button[aria-pressed="true"] { background: var(--charcoal-3); box-shadow: inset 0 -2px 0 var(--hbl-yellow); }
.lang-switch svg { display: block; width: 22px; height: 15px; border-radius: 2px; }

/* ---------- Guest shell (top bar, no sidebar) ---------- */
.guest-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--charcoal); }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 14px clamp(16px, 3vw, 32px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
}
.topbar-inner .brand { margin-right: auto; }
.btn-google {
  height: 44px; display: inline-flex; align-items: center; gap: 10px; padding: 0 18px; border-radius: var(--radius);
  background: #fff; color: var(--ink); font-weight: 600; text-decoration: none;
}
.btn-google:hover { color: var(--ink); background: #F1F1F1; }
.g-mark {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink);
  display: inline-flex; align-items: center; justify-content: center; font: 700 11px var(--font-head);
}
.guest-main {
  flex: 1; width: 100%; max-width: 1120px; margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) clamp(16px, 3vw, 32px) 56px;
  display: flex; flex-direction: column; gap: 40px;
}
.site-footer { text-align: center; padding: 20px 16px; font-size: 13px; color: var(--muted); }

/* ---------- Signed-in shell (sidebar) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  flex: 0 0 256px; width: 256px; background: var(--charcoal); color: var(--nav-ink);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px; }
.nav-toggle {
  display: none; width: 44px; height: 44px; border: 1px solid var(--charcoal-3); border-radius: var(--radius);
  background: transparent; color: #fff; cursor: pointer; align-items: center; justify-content: center;
}
.sidebar-body { display: flex; flex-direction: column; gap: 24px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--nav-muted); padding: 0 12px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius);
  color: var(--nav-ink); text-decoration: none;
}
.nav-link:hover { background: var(--charcoal-3); color: #fff; }
.nav-link[aria-current="page"] { background: var(--hbl-yellow); color: var(--ink); font-weight: 600; }
.nav-link svg { flex: none; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--charcoal-3); padding-top: 16px; }
.sidebar-foot .lang-switch { padding: 0 12px 8px; }
.sidebar-foot .lang-switch button { flex: 1; height: 32px; }
.nav-link-sm { min-height: 40px; color: var(--nav-dim); font-size: 14px; }
.user-block { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--hbl-yellow); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
  flex: none; overflow: hidden; object-fit: cover;
}
.avatar-lg { width: 96px; height: 96px; font-size: 32px; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-weight: 600; color: #fff; font-size: 14px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name:hover { color: var(--hbl-yellow); }
.user-role { font-size: 12px; color: var(--nav-muted); }
.icon-btn-dark {
  color: var(--nav-dim); display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center;
  border-radius: var(--radius); flex: none;
}
.icon-btn-dark:hover { color: #fff; background: var(--charcoal-3); }

.app-main {
  flex: 1; min-width: 0; padding: 40px clamp(16px, 4vw, 56px) 48px;
  display: flex; flex-direction: column; gap: 24px;
}
.app-main > .site-footer { margin-top: auto; padding-bottom: 0; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex: none; padding: 12px 16px; gap: 0; }
  .nav-toggle { display: inline-flex; }
  .sidebar-body { display: none; padding-top: 16px; }
  .sidebar.is-open .sidebar-body { display: flex; }
  .app-main { padding-top: 28px; }
}

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title { font: 800 34px/1.15 var(--font-head); letter-spacing: -0.01em; }
.page-sub { margin-top: 6px; color: var(--muted); }
.eyebrow {
  display: flex; align-items: center; gap: 10px; font: 600 13px var(--font-mono);
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--hbl-yellow-ink);
}
.eyebrow::before { content: ""; display: block; width: 10px; height: 10px; background: var(--hbl-yellow); transform: skewX(-14deg); }

/* ---------- Buttons ---------- */
.btn {
  height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--field); background: var(--surface); color: var(--ink);
  font: 500 15px var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { color: var(--ink); background: var(--surface-2); border-color: #BDBAB1; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--hbl-yellow); border-color: var(--hbl-yellow); font: 700 15px var(--font-head); }
.btn-primary:hover { background: #F2B600; border-color: #F2B600; }
.btn-dark { background: var(--charcoal-2); border-color: var(--charcoal-2); color: #fff; font-weight: 600; }
.btn-dark:hover { background: #000; color: #fff; }
.btn-ghost-dark { background: transparent; border-color: #55555B; color: var(--bg); }
.btn-ghost-dark:hover { background: var(--charcoal-3); color: #fff; border-color: #6A6A70; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn .spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 14px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
.input, .select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--field);
  border-radius: var(--radius); padding: 0 12px; height: 44px; width: 100%; min-width: 0;
}
.input:disabled { background: var(--bg); color: var(--muted); }
.input-lg { height: 52px; font-size: 16px; }
.input-mono { font-family: var(--font-mono); }
.input-group { display: flex; align-items: stretch; }
.input-addon {
  display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--field); border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius); background: var(--bg); font: 500 14px var(--font-mono); color: var(--muted);
  white-space: nowrap;
}
.input-group .input { border-radius: 0 var(--radius) var(--radius) 0; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--charcoal-2); margin: 0; flex: none; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.row-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-inline > .grow { flex: 1 1 280px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card-pad { padding: 20px 24px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font: 700 16px var(--font-head); }
.card-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }

.option { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 12px; }
.option:last-child { border-bottom: 0; }
.option-label { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.option-label input { margin-top: 2px; }
.option-text { display: flex; flex-direction: column; gap: 2px; }
.option-title { font-weight: 600; }
.option-desc { color: var(--muted); font-size: 14px; }
.option-body { margin-left: 34px; max-width: 460px; }

/* ---------- Create link (home, signed in) ---------- */
.quota { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.quota-bar { display: block; width: 120px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.quota-bar > span { display: block; height: 100%; background: var(--charcoal-2); }
.quota strong { color: var(--ink); }
.create-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.create-form { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; margin: 0; }
.result {
  flex: 1 1 300px; min-width: 0; background: var(--charcoal-2); color: var(--bg); border-radius: 14px; padding: 24px;
  display: flex; flex-direction: column; gap: 18px; position: sticky; top: 24px;
}
.result-label {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--hbl-yellow);
}
.result-label::before { content: ""; display: block; width: 10px; height: 10px; background: var(--hbl-yellow); transform: skewX(-14deg); }
.result-link { font: 500 22px var(--font-mono); color: #fff; word-break: break-all; text-decoration: none; }
.result-link:hover { color: var(--hbl-yellow); }
.result-empty { color: #D6D6D9; font-size: 14px; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.result-actions .btn { flex: 1 1 auto; }
.qr-box { background: #fff; border-radius: 10px; padding: 16px; display: flex; justify-content: center; }
.qr-box img, .qr-box canvas { width: 184px !important; height: 184px !important; }
.result-meta { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: #D6D6D9; }
.result-meta li { display: flex; justify-content: space-between; gap: 12px; }
.result-meta strong { color: #fff; font-weight: 500; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }
@media (max-width: 900px) { .result { position: static; } }

/* ---------- Guest home ---------- */
.hero { display: flex; flex-direction: column; gap: 20px; max-width: 760px; }
.hero h1 { font: 800 clamp(36px, 6vw, 60px)/1.05 var(--font-head); letter-spacing: -0.02em; }
.hero p { font-size: 18px; color: var(--ink-2); }
.try { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.feature { border-top: 3px solid var(--charcoal-2); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.feature h2 { font: 700 17px var(--font-head); }
.feature p { color: var(--ink-2); font-size: 14px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font: 800 28px var(--font-head); }

/* ---------- Tables ---------- */
.table-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FCFBF8; }
.table .num { text-align: right; }
.cell-url { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.cell-url a { color: inherit; text-decoration: none; }
.cell-url a:hover { text-decoration: underline; color: var(--link); }
.cell-wrap { max-width: 360px; word-break: break-all; font-size: 13px; color: var(--ink-2); }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions > * + * { margin-left: 6px; }
.short-link { font: 500 14px var(--font-mono); text-decoration: none; }
.short-link:hover { text-decoration: underline; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500;
  border-radius: 999px; padding: 2px 10px; white-space: nowrap; background: var(--bg); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-yellow { background: var(--hbl-yellow-soft); color: #5C4300; }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-dark { background: var(--charcoal-2); color: var(--hbl-yellow); }

/* ---------- Pagination ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 14px; color: var(--muted); }
.pager-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pager-list a, .pager-list span {
  min-width: 40px; height: 40px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: 1px solid var(--field); color: var(--ink); text-decoration: none; background: var(--surface);
}
.pager-list a:hover { background: var(--surface-2); }
.pager-list a[aria-current="page"] { background: var(--charcoal-2); border-color: var(--charcoal-2); color: #fff; font-weight: 600; }
.pager-list span { border-color: transparent; background: transparent; color: var(--muted); }

/* ---------- Alerts & toast ---------- */
.alert { border-radius: 12px; padding: 14px 18px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.alert-info { background: var(--hbl-yellow-tint); border-color: #F3DE9A; }
.alert-error { background: var(--danger-soft); border-color: #F4C7C2; color: #7A1A12; }
.alert-success { background: var(--success-soft); border-color: #BFE3CB; color: #134A27; }
.secret { font: 500 14px var(--font-mono); background: rgba(0,0,0,.06); padding: 8px 10px; border-radius: 6px; word-break: break-all; }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  background: var(--charcoal-2); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); border-left: 4px solid var(--hbl-yellow);
}
.toast-error { border-left-color: #F97066; }

/* ---------- Profile ---------- */
.profile { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.profile-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.profile-name { font: 800 26px var(--font-head); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; word-break: break-word; }

/* ---------- Password / centered pages ---------- */
.center-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.center-card { width: 100%; max-width: 440px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.center-card h1 { font: 800 26px/1.2 var(--font-head); }
.lock-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--charcoal-2); color: var(--hbl-yellow); display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Error pages ---------- */
.error-page { display: flex; flex-direction: column; gap: 16px; max-width: 640px; padding: 24px 0; }
.error-code { font: 800 clamp(72px, 14vw, 128px)/1 var(--font-head); color: var(--charcoal-2); display: flex; align-items: center; gap: 16px; }
.error-code::before { content: ""; display: block; width: 0.32em; height: 0.75em; background: var(--hbl-yellow); transform: skewX(-14deg); }
.error-page h1 { font: 800 28px/1.2 var(--font-head); }
.error-page p { color: var(--ink-2); font-size: 17px; }

/* ---------- Guide ---------- */
.steps { display: flex; flex-direction: column; gap: 16px; counter-reset: step; }
.step { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.step h2 { font: 700 18px var(--font-head); display: flex; align-items: center; gap: 12px; }
.step h2::before {
  counter-increment: step; content: counter(step); width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--charcoal-2); color: var(--hbl-yellow); display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.step img { border: 1px solid var(--line); border-radius: 10px; display: block; }
.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }

/* ---------- Logs filter ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; padding: 16px 20px; }
.filters .input { width: 220px; }

/* ---------- Intro option on the create form ---------- */
.option-intro:has(#opt-intro:checked) { background: var(--hbl-yellow-tint); }
.tag-new { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; background: var(--charcoal-2); color: var(--hbl-yellow); border-radius: 4px; padding: 1px 6px; vertical-align: 1px; }
.option-body-wide { max-width: 640px; }
.select { appearance: auto; }

/* ---------- Shared bits for management screens ---------- */
.label-sm { font-size: 13px; font-weight: 600; }
.check-inline { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; border-radius: 4px; padding: 1px 8px; white-space: nowrap; line-height: 1.6; }
.tag-active { background: #E3F1E8; color: #1E5E3A; }
.tag-scheduled { background: #E3ECF7; color: var(--link); }
.tag-draft { background: var(--line-2); color: var(--ink-2); }
.tag-default { background: var(--hbl-yellow); color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.toolbar-search { flex: 0 1 300px; margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills a { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: 500 14px var(--font-body); text-decoration: none; display: inline-flex; align-items: center; }
.pills a:hover { background: var(--surface-2); }
.pills a[aria-current="true"] { background: var(--charcoal-2); border-color: var(--charcoal-2); color: #fff; }

/* ---------- Intro templates list ---------- */
.default-bar { background: var(--charcoal-2); color: var(--nav-ink); border-radius: 12px; padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 14px; }
.default-bar strong { color: #fff; }
.default-bar-mark { display: block; width: 12px; height: 12px; background: var(--hbl-yellow); transform: skewX(-14deg); flex: none; }
.default-bar a { margin-left: auto; color: var(--hbl-yellow); font-weight: 600; text-decoration: none; }
.default-bar a:hover { color: #fff; text-decoration: underline; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.tpl-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.tpl-thumb { position: relative; height: 150px; background: var(--bg); border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; }
.tpl-thumb-bar { height: 10px; background: var(--charcoal-2); flex: none; }
.tpl-thumb-frame { position: relative; flex: 1; overflow: hidden; background: #fff; }
.tpl-thumb-frame iframe { position: absolute; top: 0; left: 0; width: 400%; height: 400%; border: 0; transform: scale(0.25); transform-origin: 0 0; pointer-events: none; background: #fff; }
.tpl-default { position: absolute; top: 20px; right: 12px; display: inline-flex; align-items: center; gap: 4px; background: var(--hbl-yellow); color: var(--ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.tpl-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tpl-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tpl-title h2 { font: 700 16px/1.3 var(--font-head); word-break: break-word; }
.tpl-meta { font-size: 13px; color: var(--muted); }
.tpl-meta strong { color: var(--ink); }
.tpl-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.tpl-actions > .btn { flex: 1; height: 40px; font-size: 14px; }
.tpl-actions .btn-icon { width: 40px; height: 40px; flex: none; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: 500 14px var(--font-body); text-decoration: none; text-align: left; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--bg); }
.menu-list .menu-danger { color: var(--danger); }
.menu-note { font-size: 12px; color: var(--muted); padding: 6px 12px; }

/* ---------- Template editor ---------- */
.editor { display: flex; flex-direction: column; gap: 20px; margin: 0; }
.editor-heading { display: flex; flex-direction: column; gap: 4px; }
.breadcrumb { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.editor-title { font: 800 30px/1.15 var(--font-head); }
.editor-settings { padding: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px 20px; }
.editor-settings .wide { grid-column: span 2; }
.editor-settings-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding-top: 4px; }
@media (max-width: 600px) { .editor-settings .wide { grid-column: auto; } }
.editor-panes { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.code-pane { flex: 1 1 380px; min-width: 0; background: #1C1C1E; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #333338; color: var(--nav-dim); font-size: 13px; }
.code-tabs { display: flex; gap: 4px; }
.code-tabs button { height: 32px; padding: 0 12px; border-radius: 6px; border: 0; background: transparent; color: var(--nav-dim); font: 500 13px var(--font-body); cursor: pointer; }
.code-tabs button[aria-pressed="true"] { background: #333338; color: #fff; }
.code-tabs button:hover { color: #fff; }
.code-upload { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 6px; color: var(--nav-dim); cursor: pointer; }
.code-upload:hover { background: #333338; color: #fff; }
.code-upload.is-loading .spinner { display: inline-block; }
.code-upload .spinner { display: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
#tpl-upload:focus-visible + .code-upload { outline: 3px solid var(--hbl-yellow); }
.code-note { font-size: 12px; color: #8E8E96; text-align: right; }
.code { flex: 1; font: 400 13px/1.7 var(--font-mono); width: 100%; min-height: 360px; border: 0; padding: 16px; resize: vertical; background: transparent; color: var(--nav-ink); tab-size: 2; }
.code:focus-visible { outline: 3px solid var(--hbl-yellow); outline-offset: -3px; }
.code-foot { padding: 10px 16px 14px; border-top: 1px solid #333338; font-size: 12px; color: #8E8E96; line-height: 1.7; }
.code-foot code { font-family: var(--font-mono); color: var(--hbl-yellow); background: #2A2A2D; padding: 1px 6px; border-radius: 4px; }
.preview-pane { flex: 1 1 380px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }
.preview-label { font-weight: 600; color: var(--ink); }
.device-toggle { display: flex; gap: 4px; }
.device-toggle button { height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: 500 13px var(--font-body); cursor: pointer; }
.device-toggle button[aria-pressed="true"] { background: var(--charcoal-2); border-color: var(--charcoal-2); color: #fff; }
.preview-stage { flex: 1; background: var(--bg); padding: 16px; display: flex; justify-content: center; }
.preview-device { width: 100%; display: flex; flex-direction: column; transition: width .2s; }
.preview-stage.is-mobile .preview-device { width: 375px; max-width: 100%; }
.preview-bar { background: var(--charcoal); color: var(--nav-dim); font-size: 11px; padding: 8px 12px; border-radius: 8px 8px 0 0; display: flex; justify-content: space-between; gap: 8px; }
.preview-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-bar strong { color: var(--hbl-yellow); font-weight: 600; white-space: nowrap; }
.preview-frame { flex: 1; width: 100%; min-height: 400px; background: #fff; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; display: block; }

/* ---------- Admin settings ---------- */
.settings-card { overflow: hidden; }
.section-head { padding: 18px 24px; border-bottom: 1px solid var(--line-2); }
.section-head h2 { font: 700 18px var(--font-head); }
.section-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }
.settings-grid { padding: 20px 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 24px; }
.settings-grid .full { grid-column: 1 / -1; }
fieldset.choice { border: 1px solid var(--line-2); border-radius: 10px; padding: 14px 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset.choice legend { font-size: 14px; font-weight: 600; padding: 0 6px; }

/* ---------- QR dialog (My links) ---------- */
.qr-dialog { border: 0; border-radius: 16px; padding: 0; width: min(380px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.25); color: var(--ink); }
.qr-dialog::backdrop { background: rgba(35, 35, 37, .6); }
.qr-dialog-inner { margin: 0; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.qr-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qr-dialog-head h2 { font: 700 18px var(--font-head); }
.qr-dialog .qr-box { border: 1px solid var(--line); }
.qr-dialog-link { color: var(--ink); font-size: 16px; text-align: center; }
.qr-dialog-link:hover { color: var(--link); }
.qr-dialog-actions { display: flex; gap: 10px; }
.qr-dialog-actions .btn { flex: 1; }
.table-compact th, .table-compact td { padding-left: 12px; padding-right: 12px; }
.table-compact .cell-url { max-width: 160px; }
.table-compact .cell-actions > * + * { margin-left: 4px; }

/* ---------- Admin search / filter bar ---------- */
.filter-bar { padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin: 0; }
.filter-bar .field { flex: 0 1 150px; min-width: 130px; }
.filter-bar .filter-grow { flex: 1 1 220px; }
.filter-actions { display: flex; gap: 8px; }
.result-count { font-size: 14px; color: var(--muted); margin-top: -8px; }
.cell-owner { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Users & roles ---------- */
.role-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.role-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.role-card-title { font: 700 15px var(--font-head); }
.role-card-desc { font-size: 13px; color: var(--muted); }
.role-card-dark { background: var(--charcoal-2); border-color: var(--charcoal-2); color: #fff; }
.role-card-dark .role-card-desc, .role-card-dark .role-card-count { color: var(--nav-dim); }
.select-sm { height: 36px; font-size: 14px; padding: 0 8px; width: 150px; }

/* ---------- Template ownership ---------- */
.tag-mine { background: var(--hbl-yellow-soft); color: #5C4300; }
.editor-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.editor-fields:disabled .input { background: var(--surface-2); color: var(--ink-2); }
.readonly-note { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--hbl-yellow-tint); border: 1px solid #F3DE9A; font-size: 14px; }
.code[readonly] { cursor: default; }
.menu-list button[data-clone-template].is-loading { opacity: .6; }

/* ---------- Media library ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-grid-page { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.media-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; text-align: left; font: inherit; color: inherit; padding: 0; }
.media-card figcaption { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.media-card figcaption .btn { margin-top: 8px; }
.media-pick { cursor: pointer; padding-bottom: 8px; }
.media-pick:hover { border-color: var(--charcoal-2); box-shadow: 0 0 0 2px var(--hbl-yellow); }
.media-pick .media-name, .media-pick .media-meta { padding: 0 10px; }
.media-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; background:
  conic-gradient(#ECEAE4 25%, #fff 0 50%, #ECEAE4 0 75%, #fff 0) 0 0 / 16px 16px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.media-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.media-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-upload label { cursor: pointer; }
.media-upload label.is-loading .spinner { display: inline-block; }
#media-file:focus-visible + label { outline: 3px solid var(--hbl-yellow); outline-offset: 1px; }
.media-dialog { border: 0; border-radius: 16px; padding: 0; width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 60px rgba(0,0,0,.25); color: var(--ink); }
.media-dialog::backdrop { background: rgba(35, 35, 37, .6); }
.media-dialog-inner { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.media-dialog-head { display: flex; align-items: center; justify-content: space-between; }
.media-dialog-head h2 { font: 700 18px var(--font-head); }
.media-toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.media-toolbar .input { flex: 1 1 220px; }
.media-more { display: flex; justify-content: center; }
button.code-upload { border: 0; background: transparent; font: inherit; }
