/* ============================================================ foundations */
:root {
  /* Mid-gray surfaces with near-black text. Deliberately not white: the page
     should not glare. Every pairing below still clears WCAG AA on --panel. */
  --bg:        #9aa4b1;
  --bg-soft:   #b9c1cb;
  --panel:     #ccd3db;
  --panel-2:   #bcc4ce;
  --line:      #8b96a4;
  --line-soft: #a7b1bd;

  --text:      #0a0e13;   /* 12:1 on --panel */
  --muted:     #2c343e;   /*  8:1 */
  --faint:     #4a535f;   /*  5.4:1 */

  --accent:    #0d5f9f;
  --accent-dim:#4a90c8;
  --good:      #0a5c3c;
  --warn:      #7a4100;
  --bad:       #9c101c;
  --gold:      #755300;

  --radius:    14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;

  --shadow: 0 1px 2px rgba(10,14,19,.12), 0 4px 14px -8px rgba(10,14,19,.4);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(13,95,159,.10), transparent 60%),
    radial-gradient(700px 420px at 92% 0%, rgba(70,50,140,.07), transparent 62%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
p  { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .84rem; }
.tiny  { font-size: .76rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =================================================================== shell */
.shell { max-width: 1080px; margin: 0 auto; padding: 0 20px 72px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(154,164,177,.9);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 11px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  color: var(--text); font-weight: 700; letter-spacing: -.03em; font-size: .98rem;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), #7856ff);
  color: #fff; font-size: .8rem; font-weight: 800;
}
.nav { display: flex; gap: 3px; margin-left: auto; align-items: center; }
.nav a {
  color: var(--muted); font-size: .885rem; font-weight: 600;
  padding: 7px 12px; border-radius: 999px;
}
.nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }

.avatar {
  border-radius: 50%; object-fit: cover; flex: none;
  background: var(--panel-2); border: 1px solid var(--line);
}
.avatar-28 { width: 28px; height: 28px; }
.avatar-40 { width: 40px; height: 40px; }
.avatar-64 { width: 64px; height: 64px; }

/* =================================================================== cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-tight { padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-main { grid-template-columns: minmax(0,1.65fr) minmax(0,1fr); align-items: start; }

/* ================================================================== stats */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: .73rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.stat-value { font-family: var(--mono); font-size: 1.55rem; font-weight: 600; letter-spacing: -.03em; margin-top: 4px; }
.stat-sub { font-size: .79rem; color: var(--faint); margin-top: 2px; }
.stat-value.good { color: var(--good); }
.stat-value.gold { color: var(--gold); }
.stat-value.accent { color: var(--accent); }

/* ================================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: .89rem; font-weight: 600;
  padding: 10px 17px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  transition: filter .12s ease, background .12s ease, border-color .12s ease, opacity .12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.94); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-good    { background: var(--good); color: #fff; }
.btn-danger  { background: rgba(156,16,28,.13); color: var(--bad); border-color: rgba(211,33,44,.28); }
.btn-ghost   { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--faint); background: var(--panel-2); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 13px 26px; font-size: .96rem; }
.btn-block { width: 100%; }

/* ================================================================== forms */
label.field { display: block; }
.field-label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=url], input[type=password], input[type=email], select, textarea {
  width: 100%;
  font-family: inherit; font-size: .92rem; color: var(--text);
  background: #e6eaef;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(13,95,159,.22);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select option { background: var(--panel); }

.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: .95rem; pointer-events: none; font-family: var(--mono);
}
.input-prefix > input { padding-left: 28px; }

.form-error { color: var(--bad); font-size: .84rem; margin-top: 8px; min-height: 1.1em; }
.form-hint  { color: var(--faint); font-size: .8rem; margin-top: 7px; }

/* ================================================================= badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 650; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-approved { background: rgba(10,92,60,.16); color: var(--good); border-color: rgba(0,135,90,.26); }
.badge-pending  { background: rgba(122,65,0,.16); color: var(--warn); border-color: rgba(178,94,0,.24); }
.badge-rejected { background: rgba(156,16,28,.15);  color: var(--bad); border-color: rgba(211,33,44,.24); }
.badge-neutral  { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.badge-sent     { background: rgba(13,95,159,.16); color: var(--accent); border-color: rgba(15,111,188,.32); }
.badge-requested{ background: rgba(122,65,0,.16); color: var(--warn); border-color: rgba(178,94,0,.24); }

/* =========================================================== quota slots */
.slots { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.slot {
  border: 1px dashed var(--faint);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-height: 92px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-soft);
}
.slot-empty { align-items: center; justify-content: center; text-align: center; color: var(--faint); }
.slot-filled { border-style: solid; background: var(--panel-2); }
.slot-filled.slot-approved { border-color: rgba(0,186,124,.32); }
.slot-filled.slot-pending  { border-color: rgba(247,185,85,.32); }
.slot-num { font-family: var(--mono); font-size: .72rem; color: var(--faint); letter-spacing: .08em; }
.slot-text { font-size: .84rem; color: var(--muted); line-height: 1.4; max-height: 2.8em; overflow: hidden; }

.progress-track { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--good)); transition: width .4s cubic-bezier(.4,0,.2,1); }

/* ============================================================= post rows */
.post {
  display: flex; gap: 12px; padding: 13px 0;
  border-top: 1px solid var(--line);
}
.post:first-child { border-top: 0; padding-top: 0; }
.post-body { min-width: 0; flex: 1; }
.post-text { font-size: .88rem; color: var(--text); line-height: 1.45; word-break: break-word; }
.post-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: .76rem; color: var(--faint); }
.post-meta .mono { color: var(--muted); }
.post-thumb {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex: none;
  display: grid; place-items: center; font-size: 1rem;
  background: var(--panel-2); border: 1px solid var(--line);
}

.checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: .73rem; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line-soft); color: var(--muted); }
.check-ok   { color: var(--good); }
.check-bad  { color: var(--bad); }
.check-idk  { color: var(--warn); }

/* ================================================================= table */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left; font-size: .73rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 0 12px 9px 0; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
tr.me td { background: rgba(13,95,159,.11); }
.rank { font-family: var(--mono); color: var(--faint); width: 34px; }
.rank-1 { color: var(--gold); font-weight: 700; }
.rank-2 { color: #464f5b; font-weight: 700; }
.rank-3 { color: #74451c; font-weight: 700; }

.steplist {
  margin: 0 0 14px; padding-left: 20px;
  font-size: .87rem; color: var(--muted); line-height: 1.55;
}
.steplist li { margin-bottom: 5px; }
.steplist li::marker { color: var(--faint); font-weight: 700; }
.steplist b { color: var(--text); }

/* ================================================================= misc */
.caption-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-family: var(--mono); font-size: .87rem; color: var(--accent);
}
.caption-box .grow { overflow-x: auto; white-space: nowrap; }
.caption-box { background: #e6eaef; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty-icon { font-size: 1.7rem; opacity: .5; display: block; margin-bottom: 8px; }

.callout {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: .87rem;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
}
.callout-good { border-color: rgba(10,107,69,.35); background: rgba(10,92,60,.14); color: #05392a; }
.callout-warn { border-color: rgba(138,74,0,.35); background: rgba(122,65,0,.14); color: #5a3000; }
.callout-bad  { border-color: rgba(179,18,32,.35); background: rgba(156,16,28,.13); color: #7d0a15; }

.divider { height: 1px; background: var(--line-soft); border: 0; margin: 16px 0; }

.pill-group { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line-soft); }
.pill-group button {
  font-family: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
  padding: 5px 13px; border-radius: 999px; border: 0;
  background: transparent; color: var(--muted);
}
.pill-group button.active { background: var(--panel-2); color: var(--text); }

/* ================================================================= modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10,14,19,.62);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 18px;
  animation: fade-in .15s ease;
  overflow-y: auto;
}
@keyframes fade-in { from { opacity: 0 } }

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px -20px rgba(10,14,19,.75);
  animation: modal-in .18s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98) } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal-title { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-close {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--panel-2); color: var(--muted);
  font-size: 1.1rem; line-height: 1; cursor: pointer; font-family: inherit;
}
.modal-close:hover { color: var(--text); background: var(--bg-soft); }

/* --------------------------------------------------------- clip preview */
.clip-frame {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.clip-frame img { display: block; width: 100%; height: 240px; object-fit: contain; }
.clip-frame .clip-missing { height: 240px; display: grid; place-items: center; font-size: 2rem; }

/* The whole picture is the download button. */
.clip-dl {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(10,14,19,.15), rgba(10,14,19,.42));
  color: #fff; text-decoration: none;
  transition: background .15s ease;
}
.clip-dl:hover { background: linear-gradient(180deg, rgba(10,14,19,.3), rgba(10,14,19,.58)); text-decoration: none; }
.clip-dl:hover .clip-dl-icon { transform: scale(1.06); }
.clip-dl-icon {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.96); color: #0a0e13;
  box-shadow: 0 6px 20px -6px rgba(10,14,19,.7);
  transition: transform .15s ease;
}
.clip-dl-icon svg { width: 28px; height: 28px; }
.clip-dl-label {
  position: absolute; left: 0; right: 0; bottom: 10px;
  text-align: center; font-size: .82rem; font-weight: 650;
  text-shadow: 0 1px 4px rgba(10,14,19,.9);
}

@media (max-width: 620px) {
  .modal-backdrop { padding: 0; }
  .modal { max-height: 100vh; height: 100%; border-radius: 0; border: 0; width: 100%; }
  .clip-frame img, .clip-frame .clip-missing { height: 200px; }
}

/* =============================================================== toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: .87rem;
  box-shadow: var(--shadow);
  animation: toast-in .22s cubic-bezier(.2,.9,.3,1.2);
}
.toast-good { border-color: rgba(0,186,124,.4); }
.toast-bad  { border-color: rgba(244,33,46,.4); }
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(16px); } }

/* ============================================================== spinner */
.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid rgba(10,14,19,.3); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, var(--panel-2) 25%, var(--line) 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; color: transparent; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================== landing */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px 60px; }
.landing-inner { width: 100%; max-width: 480px; }
.landing-logo {
  width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 20px;
  display: grid; place-items: center; font-size: 1.5rem;
  background: linear-gradient(150deg, var(--accent), #7856ff);
  box-shadow: 0 10px 30px -14px rgba(29,155,240,.55);
}
.landing h1 { font-size: 2rem; text-align: center; }
.landing-sub { text-align: center; color: var(--muted); margin: 10px 0 26px; font-size: .96rem; }

.steps { display: grid; gap: 10px; margin-top: 22px; }
.step { display: flex; gap: 12px; align-items: flex-start; font-size: .87rem; color: var(--muted); }
.step-n {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
  font-family: var(--mono);
}
.step b { color: var(--text); font-weight: 600; }

.preview-card { margin-top: 14px; animation: toast-in .22s ease; }

/* =========================================================== responsive */
@media (max-width: 880px) {
  .grid-main, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .shell { padding: 0 14px 60px; }
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .nav a { padding: 6px 9px; font-size: .82rem; }
  .grid-main, .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0,1fr); }
  .card { padding: 15px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
  h1 { font-size: 1.45rem; }
  .landing h1 { font-size: 1.65rem; }
  .hide-sm { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
