@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── TOKENS — Cursor dashboard language, ice light ─── */
:root {
  --canvas:          #f7f8fa;
  --surface-1:       #ffffff;
  --surface-2:       #f3f5f8;
  --surface-3:       #eef1f5;
  --hairline:        #e3e7ec;
  --hairline-soft:   #eceff3;
  --border:          #e3e7ec;
  --border-hover:    #c5ccd4;
  --ink:             #12151a;
  --ink-secondary:   #5c646d;
  --ink-muted:       #7b838c;
  --ink-faint:       #9aa3ad;
  --accent:          #f54e00;
  --accent-ink:      #ffffff;
  --success:         #3f6b4a;
  --warning:         #9a7a2a;
  --danger:          #b42318;
  --error:           #b42318;
  --on-primary:      #ffffff;
  --primary:         #12151a;

  --r-xs:   2px;
  --r-sm:   2px;
  --r-md:   2px;
  --r-lg:   2px;
  --r-xl:   2px;
  --r-xxl:  2px;
  --r-pill: 2px;
  --r-full: 999px;

  --sp-xxs: 4px;
  --sp-xs:  8px;
  --sp-sm:  12px;
  --sp-md:  16px;
  --sp-lg:  20px;
  --sp-xl:  28px;
  --sp-xxl: 40px;

  --font-display: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-body:    'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --ot-body: 'ss01' on;

  --topnav-h: 52px;
  --page-max: 1120px;
}

/* ─── BASE ────────────────────────────────────────────── */
html { font-size: 16px; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: -0.011em;
  font-feature-settings: var(--ot-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}

[hidden] { display: none !important; }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--ink); opacity: 0.82; }

::selection { background: rgba(245,78,0,.22); }

:focus { outline: none; }
:focus-visible { outline: 1px solid var(--border-hover); outline-offset: 2px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--canvas); }
::-webkit-scrollbar-thumb { background: var(--hairline); border: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
}

/* ─── TOP NAV ─────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topnav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-xl);
  padding: 0 24px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-transform: none;
  color: var(--ink);
  flex-shrink: 0;
}

.topnav-brand span {
  font-size: .6em;
}

.topnav-brand svg {
  height: 24px;
  transform: translateY(-10%);
}

.topnav-brand-mark {
  display: none;
}

.topnav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
  min-width: 0;
  overflow-x: auto;
}
.topnav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.011em;
  color: var(--ink-muted);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}
.topnav-tab:hover { color: var(--ink); text-decoration: none; }
.topnav-tab.active { color: var(--ink); }
.topnav-tab.active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: 0;
  height: 1px;
  background: var(--ink);
}
.topnav-tab-divider {
  width: 1px; height: 12px;
  background: var(--hairline);
  margin: 0 8px;
  flex-shrink: 0;
}
.topnav-tab-dot {
  width: 5px; height: 5px;
  background: var(--accent);
  margin-left: 6px;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  flex-shrink: 0;
}
.topnav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-secondary);
}
.topnav-user strong { color: var(--ink); font-weight: 500; letter-spacing: -0.02em; }
.topnav-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  color: var(--ink-muted);
  border: none;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.topnav-logout:hover { color: var(--ink); text-decoration: none; }
.topnav-logout svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ─── PAGE SHELL ──────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; min-width: 0; }

.page-header {
  padding: 28px 24px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-lg);
  max-width: var(--page-max);
  margin: 0 auto;
  width: 100%;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.page-header-sub {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 4px;
  font-weight: 400;
}

.page-body {
  padding: 0 24px 48px;
  max-width: var(--page-max);
  margin: 0 auto;
  width: 100%;
}

/* ─── TOOLBAR ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline-soft);
}
.toolbar .field { margin: 0; width: auto; min-width: 160px; }
.toolbar select.field,
.toolbar .field select { min-width: 160px; }

/* ─── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--sp-lg);
}

.card-featured { background: var(--surface-1); }

/* ─── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.011em;
  font-family: var(--font-body);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.btn[disabled] {
  opacity: .4;
  cursor: default;
  pointer-events: none;
}

.btn-primary   { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: #2a3038; border-color: #2a3038; color: var(--on-primary); }
.btn-accent    { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-accent:hover { background: #2a3038; border-color: #2a3038; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--hairline); }
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-2); }
.btn-ghost     { background: transparent; color: var(--ink-secondary); border-color: var(--hairline); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); border-color: var(--border-hover); }
.btn-danger    { background: transparent; color: var(--danger); border-color: var(--hairline); }
.btn-danger:hover { border-color: var(--danger); background: rgba(180,35,24,.08); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-icon {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--hairline);
  width: 28px; height: 28px;
  padding: 0;
  border-radius: var(--r-sm);
}
.btn-icon:hover { color: var(--ink); border-color: var(--border-hover); background: var(--surface-2); }
.btn-copy.is-copied { color: var(--success); }

.btn-upload {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.011em;
}
.btn-upload:hover { background: #2a3038; border-color: #2a3038; }

/* ─── AVATAR ──────────────────────────────────────────── */
.avatar {
  position: relative;
  display: inline-block;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  flex-shrink: 0;
  overflow: hidden;
  vertical-align: middle;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-sm { width: 20px; height: 20px; font-size: 8px; line-height: 20px; }
.avatar-md { width: 24px; height: 24px; font-size: 9px; line-height: 24px; }
.avatar-lg { width: 32px; height: 32px; font-size: 11px; line-height: 32px; }

/* ─── FORMS ───────────────────────────────────────────── */
.field { margin-bottom: var(--sp-md); }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.011em;
  text-transform: none;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}
.field label.field-check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--ink);
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 6px;
}
.field input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 14px;
  height: 14px;
  min-width: 14px;
  margin: 2px 0 0;
  padding: 0;
  border: none;
  background: none;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
  color-scheme: light;
}
.field input:not([type="checkbox"]):not([type="file"]),
.field select,
.field textarea,
select.field,
input.field {
  width: 100%;
  height: 36px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font-body);
  letter-spacing: -0.011em;
  padding: 0 12px;
  outline: none;
  -webkit-appearance: none;
}
.field textarea {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
}
.field input:not([type="checkbox"]):focus,
.field select:focus,
.field textarea:focus,
select.field:focus,
input.field:focus {
  border-color: var(--border-hover);
  box-shadow: none;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--ink-faint); }
.field select option { background: var(--surface-1); }
.field-hint { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; line-height: 1.4; }

/* ─── TABLE ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.011em;
  text-transform: none;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 1px solid var(--hairline-soft); }
tbody tr:hover td { background: var(--surface-1); }

td.col-num, th.col-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
a.lib-title {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
a.lib-title:hover { color: var(--accent); }

td.col-actions, th.col-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

/* ─── BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.011em;
  text-transform: none;
  color: var(--ink-muted);
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 1px;
  background: currentColor;
  flex-shrink: 0;
}
.badge-ready,
.badge-done,
.badge-active     { color: var(--success); }
.badge-uploading,
.badge-processing { color: var(--accent); }
.badge-pending    { color: var(--warning); }
.badge-error,
.badge-inactive   { color: var(--danger); }
.badge-cancelled,
.badge-deleted    { color: var(--ink-faint); }

.badge-processing .badge-pulse,
.badge-uploading .badge-pulse { animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ─── ALERTS ──────────────────────────────────────────── */
.alert {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: var(--sp-md);
  border: 1px solid var(--hairline);
}
.alert-error   { border-color: var(--danger); color: var(--danger); background: transparent; }
.alert-success { border-color: var(--success); color: var(--success); background: transparent; }

/* ─── PROGRESS ────────────────────────────────────────── */
.progress-bar {
  height: 2px;
  background: var(--hairline);
  border-radius: 1px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--ink-muted);
  border-radius: 1px;
  transition: width .35s ease;
}
.progress-bar-fill.is-error   { background: var(--danger); }
.progress-bar-fill.is-done    { background: var(--success); }
.progress-bar-fill.is-indeterminate {
  width: 32% !important;
  animation: indeterminate 1.1s linear infinite;
}
@keyframes indeterminate {
  0%   { margin-left: -32%; }
  100% { margin-left: 100%; }
}

/* ─── EMPTY STATE ─────────────────────────────────────── */
.empty {
  text-align: left;
  padding: 48px 4px;
  color: var(--ink-muted);
  font-size: 13px;
}
.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 500;
}
.empty svg { display: none; }
td.empty, .empty:has(+ *) { text-align: left; }

/* ─── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18,21,26,.28);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: none;
}
.modal-box.wide { max-width: 560px; }
.modal-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline-soft);
}

/* ─── LOGIN PAGE ──────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 340px;
}
.login-logo {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-transform: none;
  color: var(--ink);
  margin-bottom: 40px;
}
.login-box h1 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 8px;
}
.login-box p {
  color: var(--ink-muted);
  font-size: 13px;
  margin-bottom: 32px;
}

/* ─── VIDEO PLAYER ────────────────────────────────────── */
video {
  width: 100%;
  max-height: 520px;
  background: #000;
  border-radius: var(--r-sm);
  display: block;
}

/* ─── URL COPY ROW ────────────────────────────────────── */
.url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.url-row:last-child { border-bottom: none; }
.url-key {
  min-width: 64px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.011em;
  text-transform: none;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}
.url-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── META GRID ───────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px 24px;
}
.meta-item label {
  display: block;
  font-size: 12px;
  letter-spacing: -0.011em;
  text-transform: none;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.meta-item span  { font-size: 13px; font-weight: 400; }

/* ─── LOG BOX ─────────────────────────────────────────── */
.log-box {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 10px;
  line-height: 1.5;
}

/* ─── SECTION TITLE ───────────────────────────────────── */
.section-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.011em;
  text-transform: none;
  color: var(--ink-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline-soft);
}

/* ─── STORAGE METER ───────────────────────────────────── */
.storage-meter { min-width: 120px; }
.storage-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.storage-meter-track {
  height: 2px;
  background: var(--hairline);
}
.storage-meter-fill { height: 100%; background: var(--ink-muted); }
.storage-meter-fill.is-warn { background: var(--warning); }
.storage-meter-fill.is-full { background: var(--danger); }

.cdn-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
}
.cdn-status-dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  flex-shrink: 0;
}
.cdn-status.is-synced { color: var(--success); }
.cdn-status.is-failed,
.cdn-status.is-error { color: var(--danger); }
.cdn-status.is-disabled,
.cdn-status.is-missing { color: var(--warning); }

/* ─── PAGINATION ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ─── TAB PANELS ──────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 720px) {
  .topnav { gap: 12px; padding: 0 16px; }
  .topnav-user strong { display: none; }
  .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
  .toolbar .field { min-width: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .badge-processing .badge-pulse,
  .badge-uploading .badge-pulse,
  .progress-bar-fill,
  .progress-bar-fill.is-indeterminate {
    animation: none;
    transition: none;
  }
}

/* ─── USER CELL ───────────────────────────────────────── */
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-cell-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.user-cell-name {
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-cell-email {
  font-size: 12px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-check-list {
  border-radius: var(--r-sm);
}

/* ─── AVATAR PICKER ───────────────────────────────────── */
.avatar-current {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.avatar-current .avatar { width: 40px; height: 40px; font-size: 12px; line-height: 40px; }
.avatar-library {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.avatar-option {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  margin: 0;
  border: 2px solid var(--hairline);
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
}
.avatar-option img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.avatar-option:hover { border-color: var(--border-hover); }
.avatar-option.is-selected {
  border-color: var(--accent);
}
.avatar-option.is-selected::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 1px;
}
.avatar-option:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .avatar-library { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
}
