/* terra — cozy theme: warm cocoa, amber light, soft edges */
:root {
  --bg: #17110d;
  --bg-2: #1d1611;
  --surface: #241b15;
  --surface-2: #2c211a;
  --surface-3: #37291f;
  --border: #463429;
  --border-soft: rgba(233, 168, 106, .14);
  --text: #f6ece1;
  --muted: #bda992;
  --muted-2: #8f7c69;
  --accent: #e9a86a;
  --accent-hi: #f5c193;
  --accent-soft: rgba(233, 168, 106, .13);
  --terracotta: #d98466;
  --success: #9dc79d;
  --danger: #e89494;
  --radius: 14px;
  --shadow: 0 16px 38px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(820px 520px at 8% -8%, rgba(233, 168, 106, .13), transparent 62%),
    radial-gradient(720px 460px at 100% 2%, rgba(217, 132, 102, .09), transparent 58%),
    radial-gradient(900px 600px at 70% 110%, rgba(233, 168, 106, .05), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(233, 168, 106, .3); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 780px; display: grid; grid-template-columns: .9fr 1.1fr;
  border: 1px solid var(--border); border-radius: 20px; overflow: hidden;
  background: linear-gradient(145deg, rgba(44, 33, 26, .98), rgba(29, 22, 17, .98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.login-side {
  position: relative; padding: 34px 30px;
  background:
    radial-gradient(420px 300px at 20% 0%, rgba(233, 168, 106, .22), transparent 65%),
    linear-gradient(165deg, #3b2a1f, #251a14);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 380px;
}
.login-side .brand-line { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.02em; }
.login-side h2 { margin: auto 0 6px; font-size: 27px; line-height: 1.22; letter-spacing: -.03em; }
.login-side p { margin: 0; color: var(--muted); font-size: 13px; max-width: 250px; }
.login-feature { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 16px; }
.login-feature b { color: var(--accent); font-weight: 600; }
.shelf { display: flex; align-items: flex-end; gap: 5px; height: 56px; margin-top: 26px; opacity: .85; }
.shelf i { display: block; width: 15px; border-radius: 4px 4px 2px 2px; border: 1px solid rgba(255,255,255,.08); }
.shelf i:nth-child(1) { height: 30px; background: #8a5b43; }
.shelf i:nth-child(2) { height: 46px; background: #b67b52; }
.shelf i:nth-child(3) { height: 38px; background: #6f8a6f; }
.shelf i:nth-child(4) { height: 52px; background: #c98f5d; }
.shelf i:nth-child(5) { height: 34px; background: #9c6b7b; }
.shelf i:nth-child(6) { height: 44px; background: #7c6650; }
.login-form { padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.login-form .sub { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.brand-dot {
  width: 11px; height: 11px; border-radius: 4px; display: inline-block; margin-right: 8px;
  background: linear-gradient(135deg, var(--accent-hi), var(--terracotta));
  box-shadow: 0 0 14px rgba(233, 168, 106, .5);
}
.login-form input {
  width: 100%; padding: 10px 12px; background: rgba(23, 17, 13, .7);
}
.login-form .btn.primary { width: 100%; margin-top: 18px; padding: 10px; font-size: 13px; }
.login-note { margin: 18px 0 0; font-size: 11px; color: var(--muted-2); text-align: center; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); padding: 20px 14px 16px;
  background: linear-gradient(180deg, rgba(36, 27, 21, .9), rgba(23, 17, 13, .86));
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 0 8px 22px; letter-spacing: -.02em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--terracotta));
  color: #2a1a10; font-size: 14px; font-weight: 800;
  box-shadow: 0 4px 14px rgba(233, 168, 106, .25);
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: 9px;
  color: var(--muted); font-size: 13px; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active {
  background: var(--accent-soft); color: var(--accent-hi); border-color: var(--border-soft);
}
.nav .ico { width: 17px; text-align: center; opacity: .95; font-size: 14px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 13px; }
.sidebar-foot .who { display: flex; align-items: center; gap: 8px; padding: 0 4px 11px; font-size: 12px; color: var(--muted); }
.avatar {
  width: 25px; height: 25px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--accent); font-weight: 700; font-size: 12px;
}
.sidebar-foot .who b { color: var(--text); font-weight: 600; }
.sidebar-foot .btn { width: 100%; }

.main { min-width: 0; }
.topbar {
  min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(29, 22, 17, .84), rgba(23, 17, 13, .7));
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 5;
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.crumb { font-size: 10px; color: var(--muted-2); letter-spacing: .04em; }
.topbar h2 { margin: 0; font-size: 15px; font-weight: 650; }
.topbar .spacer { flex: 1; }
.content { padding: 22px 24px 60px; max-width: 1400px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border: 1px solid var(--border-soft); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px;
  background:
    radial-gradient(500px 260px at 88% -30%, rgba(233, 168, 106, .2), transparent 70%),
    linear-gradient(120deg, #2d2119, #241a14);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.hero .kicker { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 700; }
.hero h1 { margin: 5px 0 4px; font-size: 22px; letter-spacing: -.025em; font-weight: 700; }
.hero p { margin: 0; color: var(--muted); font-size: 12px; }
.hero .hero-mark {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  font-size: 46px; opacity: .16; line-height: 1;
}

/* ---------- Controls ---------- */
input, select {
  background: rgba(23, 17, 13, .72); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 10px; outline: none; min-width: 0;
}
input:hover, select:hover { border-color: #5b4334; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted-2); }
.btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 11px; font-size: 12px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, color .15s;
}
.btn:hover { background: var(--surface-3); border-color: #5b4334; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--terracotta));
  border-color: transparent; color: #2a1a10; font-weight: 750;
  box-shadow: 0 4px 14px rgba(233, 168, 106, .2);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 4px 8px; font-size: 11px; border-radius: 7px; }
.btn.sm.active { border-color: var(--accent); color: var(--accent-hi); background: var(--accent-soft); }
.search { width: 240px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { font-size: 12px; }

/* ---------- Cards & rows ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, rgba(44, 33, 26, .94), rgba(29, 22, 17, .94));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .16), inset 0 1px 0 rgba(255, 255, 255, .03);
}
.stat::after {
  content: ''; position: absolute; width: 90px; height: 90px; right: -32px; bottom: -46px;
  border-radius: 50%; background: rgba(233, 168, 106, .07);
}
.stat .label { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; line-height: 1.15; }
.stat .value.warm { color: var(--accent); }

.panel {
  background: linear-gradient(160deg, rgba(36, 27, 21, .92), rgba(29, 22, 17, .92));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); overflow: hidden; margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 15px;
  border-bottom: 1px solid var(--border); background: rgba(55, 41, 31, .38);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 15px; }
.list { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 46px minmax(0,1fr) auto; gap: 12px; align-items: center;
  padding: 10px 15px; border-bottom: 1px solid rgba(70, 52, 41, .68);
  transition: background .14s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(233, 168, 106, .05); }
.thumb {
  width: 46px; height: 34px; border-radius: 8px; background: var(--surface-3);
  display: grid; place-items: center; font-size: 14px; color: var(--muted-2); overflow: hidden;
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .title { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: flex; align-items: center; gap: 6px; color: var(--muted-2); font-size: 11px; margin-top: 3px; flex-wrap: wrap; }
.row .actions { display: flex; gap: 6px; align-items: center; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}
.chip.genre { background: rgba(233, 168, 106, .10); color: var(--accent-hi); border-color: rgba(233, 168, 106, .22); }
.chip.dup { background: rgba(217, 132, 102, .13); color: var(--terracotta); border-color: rgba(217, 132, 102, .28); }
.chip.ok { background: rgba(157, 199, 157, .12); color: var(--success); border-color: rgba(157, 199, 157, .24); }
.chip.err { background: rgba(232, 148, 148, .12); color: var(--danger); border-color: rgba(232, 148, 148, .26); }
.bar { height: 4px; background: var(--surface-3); border-radius: 3px; width: 70px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-mark { display: block; font-size: 24px; color: var(--accent); opacity: .55; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12px; margin: 7px 0 0; }

.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-row input[type=text], .form-row input[type=password] { flex: 1; min-width: 200px; }
label.field { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.genre-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---------- Player ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 20px;
  background: rgba(10, 7, 5, .82); backdrop-filter: blur(6px);
}
.player-shell {
  width: min(900px, 96vw); border: 1px solid var(--border); border-radius: 16px;
  background: linear-gradient(160deg, #2c211a, #1d1611); overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.player-shell .panel-head { background: rgba(55, 41, 31, .5); }
.player-shell .panel-head h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-video { display: block; width: 100%; max-height: 76vh; background: #0b0806; }
.player-foot {
  padding: 9px 14px; font-size: 11px; color: var(--muted-2);
  border-top: 1px solid var(--border); text-align: center;
}

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 360px;
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; font-size: 12px; box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
}
.toast.err { border-color: var(--danger); border-left-color: var(--danger); color: #ffc9c9; }

@media (max-width: 780px) {
  .login-card { grid-template-columns: 1fr; max-width: 440px; }
  .login-side { min-height: auto; padding: 24px 26px; border-right: 0; border-bottom: 1px solid var(--border); }
  .login-side h2 { margin: 14px 0 6px; font-size: 22px; }
  .shelf { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; gap: 8px; }
  .brand { padding: 0 12px 0 0; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .sidebar-foot .who { display: none; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 0 14px; }
  .search { width: 150px; }
  .hero .hero-mark { display: none; }
}
