:root {
  color-scheme: dark;
  --bg: #090812;
  --surface: rgba(24, 21, 40, .9);
  --surface-2: #211d36;
  --line: rgba(255,255,255,.09);
  --text: #f7f5ff;
  --muted: #a8a2bc;
  --violet: #8b6cff;
  --violet-2: #6d4cf2;
  --cyan: #4de0e8;
  --green: #45d69a;
  --red: #ff6b84;
  --amber: #ffca68;
  --radius: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 92% 2%, rgba(110,76,242,.22), transparent 32rem),
    radial-gradient(circle at 0 24%, rgba(77,224,232,.08), transparent 27rem),
    var(--bg);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(9,8,18,.78);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .button { min-height: 44px; white-space: nowrap; }
.topbar-actions [aria-current="page"] { background: rgba(139,108,255,.24); }
.brand-logo { display: block; width: 64px; height: 64px; flex: 0 0 auto; border-radius: 12px; object-fit: contain; }
.brand small { display: block; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.shell { width: min(1120px, 100%); margin: 0 auto; padding: 38px 24px max(70px, env(safe-area-inset-bottom)); }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 5px 0 28px; }
.hero.small { align-items: start; margin-bottom: 22px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(32px, 6vw, 54px); line-height: 1; letter-spacing: -.045em; }
h2 { margin-bottom: 4px; font-size: 22px; letter-spacing: -.025em; }
h3 { margin: 12px 0 5px; font-size: 20px; }
.muted, .help { color: var(--muted); }
.eyebrow { margin-bottom: 12px; color: var(--cyan); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); text-decoration: none; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 18px 45px rgba(0,0,0,.18); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 42px; }
.stat { padding: 18px; }
.stat span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }
.stat strong { font-size: 24px; }
.ok { color: var(--green); }
.bad { color: var(--red); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 0 0 15px; }
.section-head p { margin-bottom: 0; font-size: 13px; }
.search-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.search-card { padding: 20px; transition: border-color .2s, opacity .2s; }
.search-card.disabled { opacity: .67; }
.card-top { display: flex; justify-content: space-between; gap: 16px; }
.card-top code { color: var(--muted); }
.icon-link { color: #c9bdff; font-size: 13px; text-decoration: none; }
.pill { display: inline-flex; border: 1px solid rgba(255,255,255,.11); border-radius: 100px; padding: 5px 9px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.pill.active { border-color: rgba(69,214,154,.28); color: var(--green); background: rgba(69,214,154,.08); }
.details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 22px 0; }
.details div { min-width: 0; }
.details dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.details dd { margin: 5px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-error { margin-bottom: 15px; padding: 11px 13px; border-radius: 12px; color: #ffd6dd; background: rgba(255,107,132,.11); font-size: 12px; overflow-wrap: anywhere; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 45px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0 17px;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 750;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.button:disabled { opacity: .4; cursor: not-allowed; }
.button.primary { background: linear-gradient(135deg, var(--violet), var(--violet-2)); box-shadow: 0 10px 28px rgba(109,76,242,.25); }
.button.secondary { border-color: rgba(139,108,255,.35); background: rgba(139,108,255,.1); }
.button.ghost { border-color: var(--line); background: transparent; }
.button.danger { color: #ffb6c2; background: rgba(255,107,132,.08); }
.button.compact { min-height: 37px; padding: 0 12px; font-size: 12px; }
.button.full { width: 100%; }

.alert { margin-bottom: 20px; border: 1px solid; border-radius: 15px; padding: 14px 16px; line-height: 1.45; }
.alert ul { margin-bottom: 0; padding-left: 20px; }
.alert.error { border-color: rgba(255,107,132,.3); color: #ffd6dd; background: rgba(255,107,132,.1); }
.alert.success { border-color: rgba(69,214,154,.3); color: #c8ffe8; background: rgba(69,214,154,.09); }
.empty { padding: 60px 24px; text-align: center; }
.empty-icon { color: var(--violet); font-size: 52px; }

.push-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 42px; padding: 22px; }
.push-copy { min-width: 0; }
.push-copy .eyebrow { margin-bottom: 8px; }
.push-copy h2 { margin-bottom: 8px; }
.push-copy p { margin-bottom: 0; }
.push-copy .help { max-width: 660px; margin-top: 10px; }
.push-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; flex: 0 0 auto; }

.logs-head { margin-top: 44px; }
.history-list { padding: 6px 18px; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.history-item:last-child { border-bottom: 0; }
.history-copy { min-width: 0; }
.history-copy strong, .history-copy small { display: block; }
.history-copy strong { margin-bottom: 5px; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.history-copy small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.history-search { margin: 0 0 7px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.history-search span { color: #d7ceff; font-weight: 700; }
.history-action { display: grid; flex: 0 0 auto; gap: 5px; text-align: right; }
.history-action span { color: var(--text); font-size: 13px; font-weight: 750; }
.history-empty { margin: 0; padding: 18px 0; font-size: 13px; }
.event-list { padding: 8px 18px; }
.event { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event p { margin: 0 0 4px; font-size: 13px; line-height: 1.45; }
.event small { color: var(--muted); font-size: 11px; }
.event-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--violet); }
.event-dot.success { background: var(--green); }
.event-dot.error { background: var(--red); }

.auth-card, .form-card { width: min(590px, 100%); margin: 9vh auto 0; padding: 28px; }
.form-card { margin-top: 0; }
.stack { display: grid; gap: 20px; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; }
input, textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  outline: none;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(7,6,14,.55);
  font-weight: 500;
}
textarea { resize: vertical; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,108,255,.12); }
.help { font-size: 12px; font-weight: 450; line-height: 1.45; }
.field-group { display: grid; gap: 8px; }
.accent-group { margin: 0 -10px; padding: 18px 10px; border-radius: 16px; background: rgba(139,108,255,.07); }
.accent-group p { margin: 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 85px; }
.input-suffix span { position: absolute; right: 14px; top: 16px; color: var(--muted); font-size: 12px; }
.check-row { grid-template-columns: 24px 1fr; align-items: start; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 15px; cursor: pointer; }
.check-row input { width: 20px; min-height: 20px; accent-color: var(--violet); }
.check-row strong, .check-row small { display: block; }
.check-row small { margin-top: 4px; color: var(--muted); font-weight: 450; line-height: 1.4; }
.warning-check { border-color: rgba(255,202,104,.2); }

@media (max-width: 760px) {
  .shell { padding: 26px 16px 60px; }
  .hero { align-items: stretch; flex-direction: column; }
  .hero > .button { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); margin-bottom: 34px; }
  .search-grid { grid-template-columns: 1fr; }
  .push-card { align-items: stretch; flex-direction: column; }
  .push-actions { justify-content: stretch; }
  .push-actions > *, .push-actions .button { width: 100%; }
  .section-head { align-items: end; }
  .history-item { align-items: stretch; flex-direction: column; gap: 12px; }
  .history-action { display: flex; align-items: center; justify-content: space-between; text-align: left; }
  .history-action .button { min-height: 44px; }
  .auth-card, .form-card { margin-top: 4vh; padding: 20px; }
}

@media (max-width: 410px) {
  .topbar { padding-left: 14px; padding-right: 14px; }
  .brand-logo { width: 56px; height: 56px; }
  .brand small { display: none; }
  .details { grid-template-columns: 1fr 1fr; }
  .actions form { flex: 1 1 auto; }
  .actions .button { width: 100%; }
}

.watch-table-wrap { overflow: hidden; }
.watch-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.watch-table th, .watch-table td { padding: 16px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.watch-table th { color: var(--muted); font-size: 12px; }
.watch-table td { font-size: 14px; line-height: 1.5; }
.watch-table th:first-child { width: 22%; }
.watch-table th:last-child { width: 20%; }
.watch-table small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.watch-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.watch-purchase { padding: 22px; margin-bottom: 22px; }
.category-links { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,260px),1fr)); gap: 12px; margin-bottom: 32px; }
.category-link { min-width: 0; padding: 18px; display: flex; flex-direction: column; gap: 16px; justify-content: space-between; }
.category-link h3 { margin: 0 0 7px; overflow-wrap: anywhere; }
.category-link p { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.category-link .button { gap: 12px; min-height: 44px; }
.saved-links-list { display: grid; gap: 14px; }
.saved-link { padding: 22px; min-width: 0; }
.saved-link-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.saved-link-heading h2 { font-size: 20px; overflow-wrap: anywhere; min-width: 0; }
.saved-link-heading .pill { flex-shrink: 0; }
.saved-link-url { padding: 14px; border-radius: 12px; background: rgba(7,6,14,.55); font: 12px/1.7 ui-monospace,monospace; overflow-wrap: anywhere; word-break: break-word; }
.saved-link-actions, .saved-links-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.saved-link-actions .button { min-height: 44px; }
.saved-links-pagination { margin-top: 24px; justify-content: center; }
.history-copy { min-width: 0; overflow-wrap: anywhere; }
.history-action { flex-shrink: 0; }
.hero.small h1 { overflow-wrap: anywhere; }
.actions > a.button { min-height: 44px; }
@media(max-width: 500px) { .saved-link { padding: 17px; } .saved-link-heading { flex-wrap: wrap; } .saved-link-actions .button { width: 100%; } }
@media (max-width: 900px) {
  .watch-table, .watch-table tbody, .watch-table tr, .watch-table td { display: block; width: 100%; }
  .watch-table thead { display: none; }
  .watch-table tr { padding: 12px; border-bottom: 1px solid var(--line); }
  .watch-table td { border: 0; padding: 10px; }
  .watch-table td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topbar-actions { flex-wrap: wrap; }
}
