:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --border: #e3e5ea;
  --text: #16181d;
  --muted: #646a76;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #eef0ff;
  --ok: #157f3b;
  --ok-soft: #e7f6ec;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --danger: #c0262d;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e8eaef;
    --muted: #9aa1ae;
    --primary: #7c74ff;
    --primary-ink: #0e1015;
    --primary-soft: #23224a;
    --ok: #4ccb7a;
    --ok-soft: #13301f;
    --warn: #f0b44c;
    --warn-soft: #34270f;
    --danger: #ff6b70;
    --danger-soft: #3a1618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { margin: .25rem 0 .5rem; font-size: 1.02rem; max-width: 70ch; }
.hidden { display: none !important; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 420px; margin-left: auto; }
.search input { width: 100%; }
.topnav { display: flex; align-items: center; gap: 8px; }
.topnav form { margin: 0; }

.container { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }

/* ---------- formulários ---------- */
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=datetime-local], select, textarea {
  width: 100%;
  font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.stack { display: grid; gap: 14px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; color: var(--primary); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.danger { color: var(--danger) !important; }

.alert { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 9px; margin: 0 0 14px; font-size: .9rem; }
.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 20px; font-size: .9rem; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.auth-card.center { text-align: center; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 12px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.2rem; margin-bottom: 24px; }
.otp { text-align: center; font-size: 1.6rem !important; letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.steps { padding-left: 1.2rem; margin: 0 0 16px; color: var(--muted); font-size: .9rem; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 12px; margin: 0 auto 12px; width: 220px; }
.qr svg { width: 196px; height: 196px; display: block; }
.secret { margin-bottom: 16px; font-size: .85rem; color: var(--muted); }
.secret code { display: block; margin-top: 8px; padding: 8px; background: var(--surface-2); border-radius: 8px; word-break: break-all; color: var(--text); }

/* ---------- lista ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.thumb iframe {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px; border: 0;
  transform-origin: 0 0; pointer-events: none; background: #fff;
}
.thumb::after { content: ""; position: absolute; inset: 0; } /* o clique vai para o link, não para o iframe */
.card-body { padding: 14px 16px 6px; flex: 1; }
.card-body h2 { margin: 0 0 4px; font-size: 1.02rem; }
.card-body h2 a { color: var(--text); }
.desc {
  margin: 0 0 10px; color: var(--muted); font-size: .88rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--muted); font-size: .78rem; }
.badge { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.badge-on { background: var(--ok-soft); color: var(--ok); }
.card-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px 14px; }

.empty {
  text-align: center; padding: 64px 24px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty p { max-width: 46ch; margin: 0 auto 16px; }

/* ---------- detalhe ---------- */
.back { display: inline-block; margin-bottom: 16px; font-size: .9rem; color: var(--muted); }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.frame {
  aspect-ratio: 16 / 10; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: #fff; box-shadow: var(--shadow);
}
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.detail-side { display: grid; gap: 16px; position: sticky; top: 76px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 640px; }
.newlink { background: var(--primary-soft); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.newlink p { margin: 0 0 8px; }
.copy { display: flex; gap: 6px; margin-top: 8px; }
.copy input { font-size: .82rem; padding: 6px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.link { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.link-expired, .link-revoked { opacity: .65; }
.link-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 2px; }
.link-actions { display: flex; gap: 14px; margin-top: 8px; }
.link-actions form { margin: 0; }
.status { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.status-active { background: var(--ok-soft); color: var(--ok); }
.status-expired { background: var(--warn-soft); color: var(--warn); }
.status-revoked { background: var(--surface-2); color: var(--muted); }
.danger-zone { text-align: center; padding: 4px; }

/* ---------- upload ---------- */
.drop {
  position: relative; display: grid; gap: 4px; text-align: center;
  padding: 26px 16px; border: 1.5px dashed var(--border); border-radius: 12px;
  background: var(--surface-2); cursor: pointer; font-weight: 400;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop-title { font-weight: 600; }
.drop-hint { color: var(--muted); font-size: .85rem; }
.drop-file { font-size: .85rem; font-weight: 600; color: var(--primary); min-height: 1.2em; }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .detail-side { position: static; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .topnav { margin-left: auto; }
  .container { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; }
  .auth-card { padding: 24px; }
}
