/* TGM Content OS — AI With Tom palette, dark.
 *
 * Dark on purpose: this screen is mostly video poster frames, and a dark ground
 * stops the UI competing with the footage. The palette is AI With Tom's own —
 * ink #0E1524 and accent #2F6BFF — lifted into surfaces rather than reinvented.
 *
 * The two businesses are told apart by an accent chip, never by layout. Scott
 * should be able to see which one he is uploading into from across a room. */

:root {
  --ink:        #0E1524;
  --surface:    #151E31;
  --surface-2:  #1C2740;
  --surface-3:  #24314D;
  --line:       #26334D;
  --line-soft:  #1E2940;

  --text:       #EAF1FF;
  --text-dim:   #9FB4D9;
  --text-faint: #6B7FA3;

  --accent:       #2F6BFF;
  --accent-light: #4D9CFF;
  --accent-tint:  rgba(47, 107, 255, 0.14);
  --highlight:    #E8952B;
  --highlight-tint: rgba(232, 149, 43, 0.14);
  --danger:       #FF5C5C;
  --good:         #3ECF8E;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 10px 30px rgba(0, 0, 0, 0.45);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* 🐛 The hidden attribute must beat every display rule in this file.
   .btn is display:inline-flex and .row is display:flex, and a bare
   [hidden] loses to both — so "Download selected" sat there permanently
   visible with nothing selected. This is the SAME bug that shipped in the
   gallery this was forked from, where a display:flex beat hidden and put the
   password panel, the closed notice and the gallery on screen at once.
   Toggle visibility with el.hidden and let this rule do the work. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.tiny  { font-size: 12px; }
.mono  { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.wrapflex { flex-wrap: wrap; }

/* ---------- masthead ---------- */

.masthead {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 21, 36, 0.92);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.masthead .wrap { display: flex; align-items: center; gap: 16px; height: 62px; }

.brandmark { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brandmark .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint);
}
.brandmark b { font-size: 15px; letter-spacing: -0.01em; }
.brandmark span { color: var(--text-faint); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }

.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.crumbs .sep { color: var(--text-faint); }
.crumbs .here { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.whoami { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }

/* ---------- role + space chips ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--text-dim); background: var(--surface-2);
  white-space: nowrap;
}
.chip.accent { color: var(--accent-light); border-color: rgba(47,107,255,.45); background: var(--accent-tint); }
.chip.warm   { color: var(--highlight);   border-color: rgba(232,149,43,.45); background: var(--highlight-tint); }
.chip.good   { color: var(--good);        border-color: rgba(62,207,142,.4);  background: rgba(62,207,142,.12); }
.chip.spacechip { color: #fff; border: none; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 40px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font: 600 14px/1 var(--font); cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #245BE0; border-color: #245BE0; }
.btn.warm { background: var(--highlight); border-color: var(--highlight); color: #2A1A05; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255,92,92,.4); background: rgba(255,92,92,.1); }
.btn.big { padding: 14px 22px; min-height: 48px; font-size: 15px; }
.btn.sm { padding: 6px 11px; min-height: 32px; font-size: 13px; }

/* ---------- forms ---------- */

label.field { display: block; }
label.field > span {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
}
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 11px 13px;
  background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 15px/1.4 var(--font);
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint);
}
::placeholder { color: var(--text-faint); }

/* ---------- panels ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 20px;
}
.panel.pad-lg { padding: 26px; }

.notice {
  border-left: 3px solid var(--accent); background: var(--accent-tint);
  padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
}
.notice.warm { border-left-color: var(--highlight); background: var(--highlight-tint); }
.notice.bad  { border-left-color: var(--danger); background: rgba(255,92,92,.1); }

.empty { text-align: center; padding: 64px 24px; color: var(--text-dim); }
.empty h2 { margin-bottom: 8px; color: var(--text); }

/* ---------- sign in ---------- */

.signin-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
/* #app sits between body and the card once the sign-in view renders into it. */
.signin-page > #app { display: flex; align-items: center; justify-content: center; width: 100%; }
.signin { width: 100%; max-width: 400px; }
.signin .lockup { text-align: center; margin-bottom: 26px; }
.signin .lockup .eyebrow {
  color: var(--accent-light); font-size: 11px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
}
.signin .lockup h1 { margin: 10px 0 6px; font-size: 26px; }

/* ---------- space cards (the home screen) ---------- */

.space-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

.space-card {
  position: relative; display: block; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 26px 26px 22px;
  color: inherit; text-decoration: none;
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.space-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.space-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--sp, var(--accent));
}
.space-card h2 { margin-bottom: 6px; }
.space-card .stats { display: flex; gap: 22px; margin-top: 22px; }
.space-card .stat b { display: block; font-size: 22px; line-height: 1.1; }
.space-card .stat span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }

/* ---------- event cards ---------- */

.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

.event-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); color: inherit; text-decoration: none;
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.event-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line); }
.event-card .cover {
  aspect-ratio: 16 / 9; background: var(--surface-2) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}
.event-card .body { padding: 16px 18px 18px; }
.event-card h3 { margin-bottom: 5px; }
.event-card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ---------- the asset grid ---------- */

.toolbar {
  position: sticky; top: 62px; z-index: 40;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 0; margin-bottom: 4px;
  /* Solid, NOT a backdrop-filter. The masthead above it already has one, and
     two stacked blurred sticky layers is a cost paid on every scroll frame of a
     long grid for an effect nobody sees twice. One blur is the budget.
     ⚠️ NOT measured on Scott's Mac — this is a precaution, not a finding. */
  background: var(--ink);
  border-bottom: 1px solid var(--line-soft);
}
.toolbar .seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.toolbar .seg button {
  padding: 8px 14px; min-height: 36px; border: none; background: transparent;
  color: var(--text-dim); font: 600 13px/1 var(--font); cursor: pointer;
}
.toolbar .seg button + button { border-left: 1px solid var(--line); }
.toolbar .seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.toolbar input[type=search] { width: 220px; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; padding: 20px 0 60px; }

.asset {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color .12s ease, transform .12s ease;
}
.asset:hover { transform: translateY(-2px); border-color: var(--line); }
.asset.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.asset.is-pick::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--highlight);
}

.asset .thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-2) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
}
.asset .thumb .placeholder { color: var(--text-faint); font-size: 26px; }
.asset .thumb .dur {
  position: absolute; right: 8px; bottom: 8px;
  padding: 2px 6px; border-radius: 5px;
  background: rgba(0,0,0,.72); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.asset .thumb .kind {
  position: absolute; left: 8px; top: 8px;
  padding: 2px 7px; border-radius: 5px;
  background: rgba(0,0,0,.6); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.asset .thumb .tick {
  position: absolute; right: 8px; top: 8px;
  width: 24px; height: 24px; border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.5); background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: transparent;
}
.asset.selected .thumb .tick { background: var(--accent); border-color: var(--accent); color: #fff; }

.asset .info { padding: 11px 13px 13px; }
.asset .name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset .sub { margin-top: 4px; font-size: 11.5px; color: var(--text-faint); }
.asset .note { margin-top: 7px; font-size: 12px; color: var(--text-dim); }
.asset .star {
  position: absolute; left: 8px; bottom: 8px;
  width: 28px; height: 28px; border-radius: 7px; border: none;
  background: rgba(0,0,0,.55); color: rgba(255,255,255,.5);
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.asset .star:hover { background: rgba(0,0,0,.8); color: #fff; }
.asset.is-pick .star { color: var(--highlight); }

/* ---------- drop zone ---------- */

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; color: var(--text-dim);
  transition: border-color .12s ease, background .12s ease;
}
.drop.over { border-color: var(--accent); background: var(--accent-tint); color: var(--text); }
.drop .big { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* ---------- progress ---------- */

.progress { margin-top: 16px; }
.progress .bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.progress .label { margin-top: 9px; font-size: 13px; color: var(--text-dim); }
.progress .sub { margin-top: 3px; font-size: 12px; color: var(--text-faint); }

/* ---------- modal (not <dialog> — showModal() needs Safari 15.4) ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 9, 17, 0.82);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.overlay[hidden] { display: none !important; }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.modal.wide { max-width: 880px; }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---------- the player ---------- */

.player { width: 100%; max-height: 62vh; background: #000; border-radius: var(--radius-sm); display: block; }
.player-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- tables ---------- */

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); }
table.grid th {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); font-weight: 700;
}

/* ---------- phone ---------- */

@media (max-width: 700px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 24px; }
  .masthead .wrap { height: 56px; gap: 10px; }
  .whoami .name { display: none; }
  .toolbar { top: 56px; }
  .toolbar input[type=search] { width: 100%; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .space-card .stats { gap: 16px; }
}
