:root {
  --bg: #0b0d12;
  --panel: #121620;
  --panel-2: #171c28;
  --line: #252d3d;
  --text: #e9eef8;
  --muted: #8b96aa;
  --accent: #ffd60a;
  --accent-ink: #1b1600;
  --green: #39d98a;
  --blue: #59a7ff;
  --red: #ff5d6c;
  --orange: #ffab4a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(900px 500px at 50% -10%, #20263a 0, #0b0d12 60%); }
.auth-card { width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.auth-card h1 { margin: 10px 0 4px; font-size: 26px; }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 22px; font-weight: 900; }
.auth-card label { display: block; margin-top: 16px; font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; margin-top: 6px; background: #0d111a; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #4c5b78; }
input[type="checkbox"] { width: auto; margin: 0 8px 0 0; accent-color: var(--accent); }
.check-line { display: flex; align-items: center; gap: 2px; color: var(--text) !important; font-size: 13px !important; }
textarea { resize: vertical; }
.auth-switch { margin-top: 18px; color: var(--muted); font-size: 14px; }
.alert { background: #3a1a22; border: 1px solid #6c2b38; color: #ffc7cf; padding: 10px 12px; border-radius: 10px; margin-top: 16px; font-size: 14px; }

/* shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: #0e1119; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand span { display: block; font-size: 12px; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--muted); padding: 11px 12px; border-radius: 10px; text-align: left; cursor: pointer; font-weight: 600; }
.nav-item span { font-size: 15px; filter: grayscale(1); opacity: .8; }
.nav-item:hover { background: #151a25; color: var(--text); }
.nav-item.active { background: #1b2130; color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.autopilot { font-size: 12px; color: var(--green); background: #11251c; border: 1px solid #1e4937; border-radius: 999px; padding: 7px 10px; display: flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(57,217,138,.12); }
.autopilot.warn { color: var(--orange); background: #2a1e0d; border-color: #5c3f18; }
.autopilot.warn .dot { background: var(--orange); box-shadow: 0 0 0 4px rgba(255,171,74,.12); }
.autopilot.off { color: var(--red); background: #2a1218; border-color: #5a2230; }
.autopilot.off .dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255,93,108,.12); }
.user { color: var(--muted); font-size: 12px; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; }
.link-btn { border: 0; background: transparent; color: var(--muted); text-align: left; padding: 0 6px; cursor: pointer; font-size: 12px; }
.link-btn:hover { color: var(--text); }
.main { padding: 30px clamp(18px, 4vw, 48px) 60px; max-width: 1500px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: clamp(26px, 3vw, 36px); letter-spacing: -.04em; }
.topbar p { margin: 6px 0 0; }
.top-actions { display: flex; gap: 8px; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { border-color: #3d4a63; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.secondary { background: #1b2232; border-color: #2c3850; }
.btn.ghost { background: transparent; }
.btn.danger { background: #2a1218; border-color: #642332; color: #ffc7cf; }
.btn.small { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.btn.full { width: 100%; margin-top: 20px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.icon-btn:hover { background: #1a2030; color: var(--text); }

/* panels and cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.add-panel { margin-bottom: 18px; }
.add-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.add-form label { min-width: 160px; font-size: 12px; color: var(--muted); }
.add-form label.grow { flex: 1 1 380px; }
.add-form label.interval-field { flex: 0 0 138px; min-width: 128px; }
.add-form .btn { height: 42px; }
.link-kind-note { margin: 9px 0 0; }
.link-kind-note.video { color: var(--green); }
.link-kind-note.channel { color: var(--blue); }
.form-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.form-foot p { margin: 0; flex: 1 1 420px; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.connect-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 150px; }
.card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #222b3c; flex: none; }
.avatar.fallback { display: grid; place-items: center; color: var(--accent); font-weight: 900; }
.card-title { font-weight: 800; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-url { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.meta { color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.status.blue { background: #10233b; color: #9cc9ff; }
.status.green { background: #10281d; color: #8cf0bd; }
.status.yellow { background: #2a240c; color: #ffe27a; }
.status.red { background: #2c1118; color: #ffb3bd; }
.status.gray { background: #1a2030; color: #aab4c6; }
.progress { height: 7px; border-radius: 999px; background: #1c2331; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.progress-note { font-size: 12px; color: var(--muted); line-height: 1.45; }
.live-box { display: flex; align-items: flex-start; gap: 10px; background: #0f2a1e; border: 1px solid #1f5a3c; border-radius: 12px; padding: 10px 12px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(57,217,138,.14); margin-top: 5px; flex: none; animation: live-pulse 1.8s ease-in-out infinite; }
.live-title { font-weight: 800; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.live-sub { color: #9fe8c3; font-size: 11px; margin-top: 3px; }
.video-box { display: flex; align-items: flex-start; gap: 10px; background: #0f1a2b; border: 1px solid #1f3b5a; border-radius: 12px; padding: 10px 12px; }
.video-icon { color: var(--blue); font-size: 14px; line-height: 1.4; }
.video-title { font-weight: 800; font-size: 13px; line-height: 1.3; }
.video-sub { color: #9cc9ff; font-size: 11px; margin-top: 3px; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.source-card .card-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.channel-card { overflow: hidden; }
.channel-banner { height: 78px; margin: -16px -16px 12px; background-size: cover; background-position: center; border-bottom: 1px solid var(--line); }
.channel-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: #0f131c; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.channel-stats.demo { grid-template-columns: 1fr; }
.channel-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.channel-stats strong { font-size: 19px; letter-spacing: -.03em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-stats span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.channel-desc { color: var(--muted); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; padding: 50px 20px; border: 1px dashed #2a3346; border-radius: 18px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 12px 0 6px; }
.empty-icon { font-size: 28px; }

/* calendar */
.calendar-panel { padding: 18px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-nav strong { font-size: 17px; min-width: 150px; text-align: center; text-transform: capitalize; }
.calendar-tools { display: flex; align-items: center; gap: 10px; }
.calendar-tools select { width: auto; margin: 0; padding: 8px 10px; font-size: 12px; }
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; padding: 8px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.weekdays div { padding: 0 8px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.day { background: #0f131c; min-height: 132px; padding: 8px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; position: relative; }
.day:hover { background: #141a26; }
.day.outside { opacity: .38; }
.day.today { background: #171d29; }
.day-num { font-size: 22px; font-weight: 800; letter-spacing: -.04em; color: #dbe4f5; }
.day.today .day-num { color: var(--accent); }
.day-posts-mini { display: flex; flex-direction: column; gap: 4px; }
.chip { border-radius: 7px; padding: 5px 6px; font-size: 11px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid transparent; }
.chip.scheduled { background: #12251d; color: #b8f3d5; border-color: #1f4938; }
.chip.pending { background: #2a240c; color: #ffe8a3; border-color: #4a3e13; }
.chip.published { background: #10233b; color: #b6d8ff; border-color: #21456e; }
.chip.error { background: #2c1118; color: #ffc0c8; border-color: #5a2230; }
.chip .chip-time { font-weight: 800; margin-right: 4px; }
.day-more { color: var(--muted); font-size: 11px; }
.calendar-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 11px; color: var(--muted); }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.68); display: grid; place-items: center; padding: 18px; z-index: 50; backdrop-filter: blur(4px); }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: min(780px, 100%); max-height: calc(100vh - 36px); overflow: auto; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.day-box { width: min(560px, 100%); }
.channel-box { width: min(480px, 100%); }
.youtube-box { width: min(620px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 18px 20px 0; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.modal-head p { margin: 4px 0 0; font-size: 12px; }
.day-posts { padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.day-post { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); background: #0f131c; border-radius: 12px; cursor: pointer; }
.day-post:hover { border-color: #3b4a66; }
.day-post img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #202838; }
.day-post .dp-title { font-weight: 700; font-size: 13px; line-height: 1.25; }
.day-post .dp-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.post-box { width: min(980px, 100%); }
.post-body { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 22px; padding: 18px 20px 22px; }
.video-wrap { position: relative; background: #05070a; border-radius: 14px; overflow: hidden; aspect-ratio: 9/16; max-height: 70vh; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-label { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #dfe7f2; font-size: 9px; letter-spacing: .12em; padding: 4px 6px; border-radius: 5px; }
.post-fields { display: flex; flex-direction: column; gap: 12px; }
.post-fields label { font-size: 12px; color: var(--muted); }
.post-fields input, .post-fields select, .post-fields textarea { margin-top: 5px; }
.status-line { font-size: 12px; color: var(--muted); min-height: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.special-error { background: #2c1118; color: #ffc0c8; border: 1px solid #5a2230; padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #1b2232; border: 1px solid #33415a; color: var(--text); padding: 12px 16px; border-radius: 10px; z-index: 100; box-shadow: 0 10px 40px rgba(0,0,0,.5); font-size: 13px; max-width: 360px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .autopilot, .user { display: none; }
  .main { padding-top: 20px; }
  .post-body { grid-template-columns: 1fr; }
  .video-wrap { max-height: 50vh; }
}
@media (max-width: 720px) {
  .weekdays { display: none; }
  .calendar-grid { display: flex; flex-direction: column; background: transparent; border: 0; gap: 8px; }
  .day { min-height: 0; border-radius: 12px; border: 1px solid var(--line); }
  .day.outside { display: none; }
  .day-num { font-size: 18px; }
  .calendar-head { align-items: flex-start; }
  .calendar-nav strong { min-width: 120px; font-size: 15px; }
  .add-form { flex-direction: column; align-items: stretch; }
  .add-form .btn { width: 100%; }
  .add-form label.interval-field { flex: 1 1 auto; }
  .form-foot { align-items: stretch; flex-direction: column; }
  .form-foot .btn { width: 100%; }
}
