:root {
  --bg: #0f1117; --panel: #171a23; --panel-2: #1e2230; --line: #2a2f3d; --text: #e6e8ef; --muted: #8b91a3;
  --accent: #6366f1; --accent-2: #4f46e5; --danger: #ef4444; --ok: #22c55e; --warn: #f59e0b; --rec: #ff3b5c;
  --radius: 12px; --shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin: 6px 0; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; -webkit-app-region: drag; }
.sidebar button, .sidebar .account { -webkit-app-region: no-drag; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; line-height: 1.15; padding: 4px 8px 18px; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 500; }
.nav-btn .ico { width: 18px; text-align: center; font-size: 12px; }
.nav-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.account { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--panel-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #a855f7); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.account-text { min-width: 0; }
.account-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.server-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.server-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.server-status.ok .dot { background: var(--ok); }
.server-status.bad .dot { background: var(--danger); }

.content { overflow: auto; padding: 28px 32px; }
.view { max-width: 1100px; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.view-head h1 { font-size: 24px; margin: 0; }
.view-head .sub { color: var(--muted); margin: 2px 0 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #3b4152; background: #252a3a; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: #fca5a5; }
.btn.danger:hover { background: rgba(239, 68, 68, .15); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.icon { padding: 6px 8px; }
.btn.rec { background: var(--rec); border-color: var(--rec); color: #fff; font-size: 16px; padding: 14px 28px; border-radius: 14px; font-weight: 600; }
.btn.rec:hover { background: #e3294a; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 70px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 0; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.hint { font-size: 12px; color: var(--muted); }
kbd { font: 11px ui-monospace, Menlo, monospace; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }

/* Record view */
.record-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.segmented { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.segmented button.active { background: var(--accent); color: #fff; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 300px; overflow: auto; padding: 2px; }
.source { border: 2px solid transparent; background: var(--panel-2); border-radius: 10px; padding: 6px; cursor: pointer; text-align: left; }
.source:hover { border-color: #3b4152; }
.source.active { border-color: var(--accent); }
.source img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 6px; display: block; }
.source .name { font-size: 12px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-tabs { display: flex; gap: 6px; margin-bottom: 10px; align-items: center; }
.source-tabs .grow { flex: 1; }
.preview-cam { width: 100%; aspect-ratio: 1; max-width: 220px; margin: 0 auto 12px; border-radius: 50%; overflow: hidden; background: #000; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.preview-cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-cam.square { border-radius: 12px; aspect-ratio: 16 / 9; max-width: 100%; }
.preview-cam.square video { transform: none; }
.meter { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn)); transition: width .08s linear; }
.start-area { text-align: center; padding: 8px 0 2px; }
.start-area .hint { margin-top: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }

/* Library */
.lib-tabs { display: flex; gap: 6px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.vcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; display: flex; flex-direction: column; }
.vcard:hover { border-color: #3b4152; transform: translateY(-2px); }
.vthumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.vthumb .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.vbody { padding: 12px 14px; display: grid; gap: 6px; }
.vtitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vmeta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.status.done { color: #86efac; border-color: rgba(34,197,94,.4); }
.status.uploading, .status.processing, .status.queued { color: #c7d2fe; border-color: rgba(99,102,241,.5); }
.status.failed { color: #fca5a5; border-color: rgba(239,68,68,.5); }
.progress { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.vactions { display: flex; gap: 6px; padding: 0 14px 12px; flex-wrap: wrap; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Detail */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.player { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.player video { width: 100%; height: 100%; display: block; }
.title-input { font-size: 20px; font-weight: 600; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; width: 100%; color: var(--text); }
.title-input:hover, .title-input:focus { border-color: var(--line); background: var(--panel); outline: none; }
.share-box { display: flex; gap: 8px; align-items: center; }
.share-box input { flex: 1; min-width: 0; }
.trim { display: grid; gap: 8px; }
.trim .range { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 6px; align-items: center; }
.comments-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 300px; overflow: auto; }
.comments-list li { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.comments-list .who { color: var(--muted); font-size: 12px; display: flex; gap: 8px; justify-content: space-between; }
.stat { font-size: 13px; color: var(--muted); }
.stat b { color: var(--text); }

/* Settings */
.settings-grid { display: grid; gap: 16px; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; font-size: 13px; }

/* Recording panel & countdown (in-page) */
.rec-panel { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; }
.rec-panel-inner { display: flex; align-items: center; gap: 16px; background: rgba(23, 26, 35, .96); border: 1px solid var(--line); border-radius: 16px; padding: 10px 16px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.rec-status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: pulse 1.2s ease-in-out infinite; }
.rec-panel.paused .rec-dot { animation: none; background: var(--warn); }
.rec-actions { display: flex; gap: 6px; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.countdown { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; text-align: center; }
.countdown-num { font-size: 140px; font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 10px 40px rgba(0,0,0,.6); }
.countdown-hint { color: rgba(255,255,255,.7); margin-top: 12px; }

/* Modal + toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 70; }
.modal-card { position: relative; width: min(440px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 4px; }
.modal-card p { margin: 0 0 16px; }
.modal-close { position: absolute; right: 12px; top: 10px; background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px); background: #262b3a; color: #fff; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 80; max-width: 80vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin-left: auto; grid-auto-flow: column; }
  .server-status .label { display: none; }
  .record-layout, .detail-layout, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* Google Drive setup */
.drive-setup { margin: 8px 0 12px; }
.drive-setup summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.drive-setup code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; font: 12px ui-monospace, Menlo, monospace; word-break: break-all; }

/* web teleprompter */
.web-prompter { position: fixed; left: 50%; top: 24px; transform: translateX(-50%); width: min(760px, 80vw); height: 200px; z-index: 65; background: rgba(12,14,20,.94); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.web-prompter .wp-scroll { height: 100%; overflow: hidden; padding: 10px 26px; -webkit-mask-image: linear-gradient(180deg, transparent, #000 12%, #000 84%, transparent); }
.web-prompter .wp-text { font-size: 28px; line-height: 1.5; font-weight: 600; white-space: pre-wrap; will-change: transform; }

/* combine selection */
.vcard.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.vcard.dim { opacity: .45; }
.vthumb .selbadge { position: absolute; left: 8px; top: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* analytics */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stat-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; text-align: center; }
.stat-box b { display: block; font-size: 20px; }
.stat-box span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.heatbars { display: flex; align-items: flex-end; gap: 1px; height: 52px; background: var(--panel-2); border-radius: 8px; padding: 4px; }
.heatbars span { flex: 1; background: var(--accent); border-radius: 1px; min-height: 2px; }
.heatbars.drop span { background: #22c55e; }
.an-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.an-recent li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: 13px; padding: 6px 8px; background: var(--panel-2); border-radius: 8px; }

/* admin panel */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table td:last-child { text-align: right; }
.au-name { font-weight: 600; }
.au-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cred-box { background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px; padding: 14px; }
.cred-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.cred-row span { width: 90px; color: var(--muted); font-size: 13px; }
.cred-row code { background: var(--bg); padding: 5px 9px; border-radius: 6px; font: 13px ui-monospace, Menlo, monospace; user-select: all; }
@media (max-width: 640px) { .admin-table thead { display: none; } .admin-table td { display: block; text-align: left !important; border: 0; padding: 3px 8px; } .admin-table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; } .au-actions { justify-content: flex-start; } }
