/* AshClipr — one stylesheet for every page. Arial, light/dark, phone-friendly. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --fg: #16181d;
  --muted: #6b7080;
  --line: #e2e4e9;
  --accent: #6c4cf5;
  --accent-fg: #ffffff;
  --accent-soft: #efeafe;
  --ok: #17a34a;
  --ok-soft: #e3f6ea;
  --warn: #d98a06;
  --warn-soft: #fdf1dc;
  --bad: #dc3545;
  --bad-soft: #fde7e9;
  --nav: #14141c;
  --nav-fg: #c9cad3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 27, .05), 0 2px 8px rgba(16, 18, 27, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1015;
    --card: #181a21;
    --fg: #e9eaee;
    --muted: #9095a3;
    --line: #2a2d37;
    --accent: #8b72ff;
    --accent-soft: #241f3d;
    --ok-soft: #12301f;
    --warn-soft: #33270f;
    --bad-soft: #3a1a1f;
    --nav: #0a0a0f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

a { color: var(--accent); }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- Top bar -------------------------------------------------------- */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--nav);
  color: var(--nav-fg);
}
.brand { color: #fff; font-weight: bold; text-decoration: none; font-size: 17px; padding: 14px 0; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a {
  color: var(--nav-fg);
  text-decoration: none;
  padding: 7px 11px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 14px;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav .count { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.topbar form { margin: 0; }
.topbar .link-btn { color: var(--nav-fg); }

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

/* --- Cards & layout ------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { display: block; font-size: 30px; font-weight: bold; margin: 2px 0; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* --- Buttons -------------------------------------------------------- */
.btn, button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: bold;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, background .15s;
}
.btn:hover, button:hover { filter: brightness(1.08); }
.btn.secondary, button.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.secondary:hover, button.secondary:hover { background: var(--accent-soft); filter: none; }
.btn.ok, button.ok { background: var(--ok); }
.btn.danger, button.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.danger:hover, button.danger:hover { background: var(--bad-soft); filter: none; }
.btn.sm, button.sm { padding: 5px 10px; font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font-weight: normal; }
.link-btn:hover { text-decoration: underline; filter: none; }
.inline { display: inline; margin: 0; }

/* --- Forms ---------------------------------------------------------- */
label { display: block; font-weight: bold; font-size: 13px; margin-bottom: 5px; }
input[type=text], input[type=url], input[type=number], input[type=password], input[type=search], select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--fg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 120px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
.field { margin-bottom: 14px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field .errors, .form-errors { color: var(--bad); font-size: 13px; margin: 4px 0 0; padding: 0; list-style: none; }
.check label { display: inline; margin-left: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font-weight: bold; padding: 0 6px; }

/* --- Tables --------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Badges & progress ---------------------------------------------- */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.badge.ok, .badge.done, .badge.rendered, .badge.kept, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.queued, .badge.review, .badge.rerender, .badge.paused { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.error, .badge.discarded, .badge.spoiler { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: var(--line); color: var(--muted); }

.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--accent); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

/* --- Messages ------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 9px; margin-bottom: 8px; background: var(--accent-soft); color: var(--fg); }
.messages li.success { background: var(--ok-soft); }
.messages li.error { background: var(--bad-soft); }

/* --- Clips ---------------------------------------------------------- */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.clip { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.clip .video {
  aspect-ratio: 9 / 16;
  max-height: 420px;
  width: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #777;
  font-size: 13px;
}
.clip video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.clip .body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.clip .hook { font-weight: bold; font-size: 16px; }
.clip .caption { font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.score { font-weight: bold; font-size: 13px; padding: 2px 9px; border-radius: 20px; background: var(--line); }
.score.high { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.low { background: var(--bad-soft); color: var(--bad); }
.clip .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details[open] summary { margin-bottom: 8px; }

/* --- Login ---------------------------------------------------------- */
.login { max-width: 380px; margin: 12vh auto 0; }
.login .brand-big { font-size: 28px; font-weight: bold; margin: 0 0 4px; }
.login .brand-big span { color: var(--accent); }
.login .version { position: absolute; top: 18px; right: 18px; margin: 0; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 2px 9px; }
.login { position: relative; }

@media (max-width: 560px) {
  main { padding-top: 16px; }
  h1 { font-size: 21px; }
  .topbar { gap: 10px; }
}

/* --- Template preview (mini 9:16 phone) ----------------------------- */
.phone {
  position: relative;
  aspect-ratio: 9 / 16;
  max-height: 300px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #22242c;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: rgba(255, 255, 255, .55);
}
.ph-cam { background: #3b3360; display: flex; align-items: center; justify-content: center; border-bottom: 2px solid #14141c; }
.ph-game { flex: 1; background: linear-gradient(160deg, #2c5364, #203a43 60%, #0f2027); display: flex; align-items: center; justify-content: center; }
.ph-game.blur { margin: 30% 0; box-shadow: 0 0 0 999px rgba(44, 83, 100, .45); }
.ph-hook { position: absolute; top: 4%; left: 8%; right: 8%; text-align: center; background: #fff; color: #111; font-weight: bold; border-radius: 6px; padding: 3px; }
.ph-cap { position: absolute; left: 0; right: 0; transform: translateY(-50%); text-align: center; font-weight: bold; font-size: 15px; text-shadow: 0 1px 3px #000; }
input[type=color] { padding: 3px; height: 40px; }

/* --- Tabs ----------------------------------------------------------- */
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; overflow-x: auto; }
.tabs a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--fg); font-size: 14px; white-space: nowrap; }
.tabs a:hover { background: var(--accent-soft); }
.tabs a.active { background: var(--accent); color: #fff; }
.tabs a.active .muted { color: rgba(255, 255, 255, .75); }

/* --- Dashboard ------------------------------------------------------ */
.quick-add { display: flex; gap: 8px; padding: 12px; }
.quick-add input { flex: 1; min-width: 0; }
a.card.stat { color: inherit; text-decoration: none; transition: border-color .15s; }
a.card.stat:hover { border-color: var(--accent); }

/* --- Polish --------------------------------------------------------- */
.grid > .card { margin-bottom: 0; }
.grid { margin-bottom: 16px; }
.form-grid .check { padding-top: 30px; }
.check label { font-size: 14px; }
.clip .video.none {
  aspect-ratio: auto;
  height: 180px;
  background: repeating-linear-gradient(135deg, var(--bg), var(--bg) 10px, var(--line) 10px, var(--line) 20px);
  color: var(--muted);
  padding: 0 24px;
  text-align: center;
}
.ph-game { align-items: flex-end; padding-bottom: 8px; }
.ph-cam { align-items: flex-end; padding-bottom: 6px; }
td.when { white-space: nowrap; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 0; padding-bottom: 8px; }
  .brand { padding: 12px 0 6px; flex: 1; }
  .nav { order: 3; flex-basis: 100%; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 24px; }
  .truncate { max-width: 180px; }
}
.clip-grid > .card, .grid-2 > .card { margin-bottom: 0; }
.clip-grid, .grid-2 { margin-bottom: 16px; }
