:root {
  --bg: #e8ecf1;
  --rail: #12171e;
  --rail-text: #9aa6b5;
  --rail-active: #b8f000;
  --surface: #ffffff;
  --surface-soft: #f3f6f9;
  --border: #d3dae3;
  --accent: #9fd40f;
  --accent-deep: #6f9800;
  --accent-text: #142000;
  --muted: #667584;
  --text: #15202b;
  --danger: #c0392b;
  --ok: #1f8a4c;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

.shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.rail {
  background: var(--rail);
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  padding: 14px 10px 12px;
  gap: 14px;
}

.rail-brand {
  display: grid;
  place-items: center;
  padding-bottom: 6px;
}
.mark {
  border-radius: 9px;
  display: block;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--rail-text);
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: rgba(255, 255, 255, 0.06); color: #e8eef5; }
.tab.is-active {
  background: rgba(184, 240, 0, 0.14);
  color: var(--rail-active);
}
.tab-ico {
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}
.tab-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.tab-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--rail-active);
  color: #12171e;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.rail-foot {
  margin-top: auto;
  flex-shrink: 0;
}
.rail-foot .btn {
  width: 100%;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--rail-text);
}
.rail-foot .btn:hover:not(:disabled) {
  border-color: var(--rail-active);
  color: var(--rail-active);
  background: rgba(184, 240, 0, 0.08);
}
.rail-pro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 10px;
  background: linear-gradient(180deg, #2a3310 0%, #1a220c 100%);
  border: 1px solid #6f9800;
  color: var(--rail-active);
}
.rail-pro[hidden] { display: none !important; }
.rail-pro-mark {
  font-size: 14px;
  line-height: 1;
}
.rail-pro-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 16px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.back-home {
  display: inline-block;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.back-home:hover { border-color: var(--accent-deep); }
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.plan-line {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}
.page-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.pro-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #142000;
  border: 1px solid #8ec20a;
  color: #c8f03a;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  line-height: 1.4;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-chip {
  font-size: 12px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.is-pro .user-chip {
  color: #4a6a00;
  font-weight: 600;
}
body.is-pro .stage {
  background:
    radial-gradient(1200px 280px at 100% -40%, rgba(184, 240, 0, 0.12), transparent 55%),
    var(--bg);
}

.quota-bar {
  flex-shrink: 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: #eef8d0;
  border: 1px solid #cfe48a;
  color: #3d5a00;
  font-size: 12px;
  font-weight: 600;
}
.quota-bar.is-pro {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}
.quota-bar.is-warn {
  background: #fff4e5;
  border-color: #f5c27a;
  color: #8a4b08;
}
.quota-bar.is-empty {
  background: #fdecec;
  border-color: #f3b4b4;
  color: #8a1f1f;
}

.panels {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: none;
  flex-direction: column;
  gap: 12px;
}
.panel.is-active { display: flex; }
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.panel-toolbar[hidden] { display: none !important; }
.panel-toolbar-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(21, 32, 43, 0.04);
}

.media-card {
  flex-shrink: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.media-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.media-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.format-block {
  flex: 1 0 auto;
  min-height: min-content;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(21, 32, 43, 0.04);
}
.format-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.format-hint {
  font-size: 11px;
  color: var(--muted);
}
.quality-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  flex-shrink: 0;
}
.quality-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.quality-chip span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--muted);
}
.quality-chip:hover {
  border-color: #b7c4d4;
  background: #eef3f8;
}
.quality-chip.is-selected {
  border-color: var(--accent-deep);
  background: #f3fad8;
  box-shadow: inset 0 0 0 1px rgba(111, 152, 0, 0.25);
}
.quality-chip.is-selected span {
  color: #3d5a00;
}
.quality-list.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.quality-list.is-disabled .quality-chip {
  cursor: default;
}
.format-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: visible;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}
.format-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.format-row:hover {
  border-color: #b7c4d4;
  background: #eef3f8;
}
.format-row.is-selected {
  border-color: var(--accent-deep);
  background: #f3fad8;
  box-shadow: inset 0 0 0 1px rgba(111, 152, 0, 0.25);
}
.format-radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #9aabbc;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.format-row.is-selected .format-radio {
  border-color: var(--accent-deep);
  background: radial-gradient(circle at center, var(--accent-deep) 0 40%, transparent 42%);
}
.format-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.format-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.format-detail {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.format-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}
.format-row.is-selected .format-badge {
  color: #3d5a00;
  border-color: #c5dd70;
  background: #eef8d0;
}
.format-actions {
  flex-shrink: 0;
  margin-top: 4px;
}
.format-actions .btn {
  min-width: 140px;
}

.composer-row { display: flex; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.grow { flex: 1; min-width: 0; }

.label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  font-family: var(--sans);
  transition: border-color 0.15s, background 0.15s;
}
.input.lg { padding: 12px 14px; font-size: 15px; }
.input:focus {
  border-color: var(--accent-deep);
  background: var(--surface);
}

.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }

.actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); }
.btn.sm { padding: 7px 10px; font-size: 10px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:not(:disabled):hover { background: #b6e812; }
.btn.ghost {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--border);
}
.btn.ghost:hover:not(:disabled) {
  color: var(--accent-text);
  border-color: var(--accent-deep);
  background: #f4fadb;
}

.live-card {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.live-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.live-title {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-status {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  flex-shrink: 0;
}
.live-status.is-run { color: var(--accent-deep); }
.live-status.is-ok { color: var(--ok); }
.live-status.is-err { color: var(--danger); }

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width 0.2s ease;
}

.log {
  margin: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.job {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: default;
  user-select: none;
}
.job.is-active {
  border-color: #c5e06a;
  box-shadow: 0 0 0 1px rgba(159, 212, 15, 0.18);
}
.job.is-done {
  cursor: pointer;
}
.job.is-done:hover {
  border-color: #b7c3d1;
}
.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.job-index {
  flex-shrink: 0;
  width: 1.6em;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-deep);
}
.playlist-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid #c5d48a;
  border-radius: 14px;
  list-style: none;
}
.playlist-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.playlist-group-copy {
  min-width: 0;
}
.playlist-group-title {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.playlist-group-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.playlist-rows {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.playlist-group .job {
  background: var(--surface);
}
.job-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.job-stop {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.job-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
}
.job-remove:hover:not(:disabled) {
  color: var(--danger);
  border-color: #f0c4c4;
  background: #fff5f5;
}
.job-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.job-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-state {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--muted);
  min-width: 3.2em;
  text-align: right;
}
.job-state.is-run { color: var(--accent-deep); }
.job-state.is-ok { color: var(--ok); }
.job-state.is-err { color: var(--danger); }
.job-state.is-stop { color: var(--muted); }

.job-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  overflow: hidden;
}
.job-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width 0.18s ease;
}
.job-progress.is-busy {
  background: linear-gradient(
    90deg,
    var(--surface-soft) 0%,
    #e7f3b0 45%,
    var(--surface-soft) 90%
  );
  background-size: 220% 100%;
  animation: job-shimmer 1.2s linear infinite;
}
.job-progress.is-busy .job-progress-bar {
  width: 0% !important;
  opacity: 0;
}
@keyframes job-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.empty {
  margin: auto;
  color: var(--muted);
  font-size: 13px;
}

.ctx-menu {
  position: fixed;
  z-index: 80;
  min-width: 196px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 32, 0.16);
}
.ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 8px 10px;
  font: 500 13px/1.2 var(--sans);
  color: var(--text);
  cursor: pointer;
}
.ctx-item:hover:not(:disabled) {
  background: var(--surface-soft);
}
.ctx-item:disabled {
  color: #a0aab4;
  cursor: default;
}
.ctx-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--border);
}

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  max-width: 520px;
}
.account-card.is-pro {
  background:
    linear-gradient(135deg, rgba(184, 240, 0, 0.14) 0%, rgba(255, 255, 255, 0.96) 42%),
    var(--surface);
  border-color: #b0d84a;
  box-shadow: 0 0 0 1px rgba(184, 240, 0, 0.18);
}
.account-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.account-card h2 {
  font-size: 18px;
  margin: 0;
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 12px;
}
.account-card.is-pro .account-actions {
  margin-bottom: 8px;
}
.fine {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.pro-perk {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #3d5a00;
  line-height: 1.4;
}
.pro-perk[hidden],
.pro-badge[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(18, 23, 30, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal[hidden] { display: none !important; }

.modal-card {
  position: relative;
  width: min(400px, 100%);
  padding: 22px 20px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(18, 23, 30, 0.22);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.modal-lead {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.4;
}
#email-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#email-form .label { margin-top: 6px; }
.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.auth-actions .btn { flex: 1; }
.playlist-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.playlist-choices .btn {
  width: 100%;
  min-height: 46px;
  font-size: 12px;
}
#playlist-modal .modal-card {
  width: min(440px, 100%);
}

.modal-hint {
  min-height: 18px;
  margin: 10px 0 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.modal-hint.is-error { color: var(--danger); }
.modal-fine {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 4px;
}
.plan-card.plan-web { grid-column: 1 / -1; }
.plan-card {
  text-align: left;
  padding: 14px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.plan-card:hover,
.plan-card.is-featured {
  border-color: var(--accent-deep);
  background: #f4fadb;
}
.plan-name {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.plan-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 6px;
}
.plan-price .plan-period {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.plan-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

[hidden] { display: none !important; }
a.btn, a.plan-card { text-decoration: none; color: inherit; }
a.plan-card { display: block; }
a.btn { display: inline-block; }
