/* ============================================================
   ClipDesk — a cutting room, not a dashboard.
   The one loud element is the colour-bar strip. Everything else
   stays quiet so thumbnails and metadata carry the page.
   ============================================================ */

:root {
  --bg:        #E9EBEF;
  --panel:     #FFFFFF;
  --panel-2:   #F4F5F8;
  --ink:       #191C23;
  --ink-2:     #4A5060;
  --muted:     #767D8C;
  --line:      #D5D9E0;
  --line-soft: #E6E9ED;
  --accent:    #C4005C;
  --accent-dk: #9C0049;
  --accent-sf: #FCE8F1;
  --ok:        #147A4A;
  --ok-sf:     #E3F5EC;
  --warn:      #8A5A00;
  --warn-sf:   #FDF2DC;
  --err:       #B3261E;
  --err-sf:    #FCE9E7;

  --bar-1: #E8E8E8; --bar-2: #D9D64A; --bar-3: #4CC9D6;
  --bar-4: #4FCB78; --bar-5: #D65BB4; --bar-6: #D64C4C; --bar-7: #4C6ED6;

  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-sm: 4px;
  --r:    7px;
  --r-lg: 12px;
  --sidebar: 216px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-soft);
}

/* ---------- Colour bars: the signature ---------- */

.bars { display: flex; }
.bars i { display: block; flex: 1; }
.bars i:nth-child(1) { background: var(--bar-1); }
.bars i:nth-child(2) { background: var(--bar-2); }
.bars i:nth-child(3) { background: var(--bar-3); }
.bars i:nth-child(4) { background: var(--bar-4); }
.bars i:nth-child(5) { background: var(--bar-5); }
.bars i:nth-child(6) { background: var(--bar-6); }
.bars i:nth-child(7) { background: var(--bar-7); }

.bars-h { height: 5px; width: 100%; }
.bars-v { flex-direction: column; width: 5px; height: 100%; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-bars { position: absolute; right: 0; top: 0; bottom: 0; }

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: block;
  color: var(--ink);
}
.brand-name:hover { text-decoration: none; }
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 1px;
}

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.nav a.on {
  background: var(--accent-sf);
  color: var(--accent-dk);
  font-weight: 600;
}
.nav .count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 20px;
  padding: 1px 7px;
}
.nav a.on .count { background: #fff; color: var(--accent-dk); }

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--muted);
}
.sidebar-foot .who { color: var(--ink-2); font-weight: 500; display: block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 21px; }
.topbar .sub { font-size: 13.5px; color: var(--muted); margin-top: 1px; }

.quota {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--muted);
}
.quota-bar {
  width: 92px; height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.quota-bar span { display: block; height: 100%; background: var(--ok); }
.quota-bar span.hot { background: var(--accent); }
.quota b { font-family: var(--mono); font-weight: 500; color: var(--ink-2); }

.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; }

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel + .panel { margin-top: 20px; }
.panel-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 15.5px; }
.panel-head .hint { font-size: 12.5px; color: var(--muted); }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.stat .n {
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  display: block;
}
.stat .k { font-size: 13px; color: var(--muted); margin-top: 3px; display: block; }
.stat.hero { background: var(--ink); border-color: var(--ink); }
.stat.hero .n { color: #fff; }
.stat.hero .k { color: #9AA1B0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-sf); border-color: #F0BDB9; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */

.stack { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.field small { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

input[type=text], input[type=password], input[type=number], input[type=url],
input[type=search], select, textarea {
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 11px;
  width: 100%;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-sf);
}
input[type=file] { font-size: 14px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 15px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 130px; }

.radio-set { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-set label {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 7px 13px;
  font-size: 14px;
  cursor: pointer;
  background: var(--panel);
}
.radio-set input { position: absolute; opacity: 0; pointer-events: none; }
.radio-set label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-sf);
  color: var(--accent-dk);
  font-weight: 500;
}

/* ---------- Notices ---------- */

.notice {
  padding: 11px 14px;
  border-radius: var(--r);
  font-size: 14px;
  border: 1px solid;
  line-height: 1.5;
}
.notice + .notice, .notice + .panel, .notice + form { margin-top: 15px; }
.notice-ok    { background: var(--ok-sf);   border-color: #B9E2CC; color: var(--ok); }
.notice-warn  { background: var(--warn-sf); border-color: #EDD6A3; color: var(--warn); }
.notice-error { background: var(--err-sf);  border-color: #F0BDB9; color: var(--err); }
.notice-info  { background: var(--panel-2); border-color: var(--line); color: var(--ink-2); }
.notice code { background: rgba(0,0,0,.05); border-color: transparent; }

.page-notice { margin-bottom: 20px; }

/* ---------- Video grid ---------- */

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

.vcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.vthumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  display: block;
  overflow: hidden;
}
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .len {
  position: absolute;
  right: 7px; bottom: 7px;
  background: rgba(10,12,16,.86);
  color: #fff;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: var(--r-sm);
}
.vthumb .pill {
  position: absolute;
  left: 7px; top: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.vthumb .pill.cc { background: var(--ok); color: #fff; }
.vthumb .pill.part { background: var(--accent); color: #fff; font-family: var(--mono); }

.vbody { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.vtitle {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
}
a.vtitle:hover { color: var(--accent); text-decoration: none; }
.vmeta { font-size: 12.5px; color: var(--muted); }
.vstats {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.vfoot { margin-top: auto; padding-top: 10px; display: flex; gap: 7px; }
.vfoot > .btn { flex: 1; }

/* ---------- Clip cards ---------- */

.clip-card { border-color: var(--line); }
.clip-card.is-published { border-color: #B9E2CC; }

.meta-block { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.meta-row .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}
.meta-row p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.meta-row .caption-text {
  color: var(--ink);
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.4;
}
.tag-line {
  font-size: 12.5px;
  color: var(--ink-2);
  word-break: break-word;
  line-height: 1.6;
}
.tag-line.hash { color: var(--accent-dk); }

.copy-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
  float: right;
}
.copy-btn:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Tables ---------- */

.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  white-space: nowrap;
}
.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-family: var(--mono); font-size: 13px; text-align: right; white-space: nowrap; }
.tbl .thumb-cell img { width: 92px; border-radius: var(--r-sm); display: block; }
.tbl-scroll { overflow-x: auto; }

/* ---------- Bits ---------- */

.chip {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.chip-ok   { background: var(--ok-sf);   color: var(--ok);     border-color: #B9E2CC; }
.chip-work { background: var(--warn-sf); color: var(--warn);   border-color: #EDD6A3; }
.chip-err  { background: var(--err-sf);  color: var(--err);    border-color: #F0BDB9; }
.chip-acc  { background: var(--accent-sf); color: var(--accent-dk); border-color: #F2C4D8; }

.empty {
  text-align: center;
  padding: 52px 24px;
  color: var(--muted);
}
.empty h3 { font-size: 16.5px; color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 auto 18px; max-width: 420px; font-size: 14px; line-height: 1.55; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}
.filters .tab {
  padding: 6px 13px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13.5px;
  color: var(--ink-2);
}
.filters .tab:hover { background: var(--panel-2); text-decoration: none; }
.filters .tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters form { display: flex; gap: 8px; margin-left: auto; }
.filters input[type=search] { width: 210px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 26px 0 12px;
}
.section-title:first-child { margin-top: 0; }

.divide { height: 1px; background: var(--line-soft); margin: 18px 0; }

/* ---------- Progress ---------- */

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .3s ease;
}
.progress-note { font-size: 13px; color: var(--muted); }
.progress-note .n { font-family: var(--mono); color: var(--ink-2); }

/* ---------- Modal ---------- */

.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(15,18,24,.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal-wrap.open { display: flex; }
.modal {
  background: var(--panel);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 470px;
  overflow: hidden;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-head { padding: 18px 20px 0; }
.modal-head h3 { font-size: 17px; }
.modal-head p { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--panel-2);
}

/* ---------- Auth ---------- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.auth-inner { padding: 28px; }
.auth-title { font-size: 23px; letter-spacing: -0.03em; }
.auth-lead { color: var(--muted); font-size: 14px; margin: 6px 0 20px; line-height: 1.55; }
.install-check {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--muted);
}
.install-check p { margin: 0 0 8px; }
.install-check ul { margin: 0; padding-left: 18px; }
.install-check li { margin-bottom: 6px; line-height: 1.5; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-bars { display: none; }
  .brand { border-bottom: none; padding-bottom: 12px; }
  .nav { display: flex; gap: 4px; overflow-x: auto; padding: 0 10px 12px; }
  .nav a { white-space: nowrap; margin: 0; }
  .sidebar-foot { display: none; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .filters form { margin-left: 0; width: 100%; }
  .filters input[type=search] { flex: 1; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
