:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #111722;
  --panel-2: #151d2b;
  --line: #263244;
  --text: #eef3ff;
  --muted: #96a3b8;
  --accent: #31d0aa;
  --accent-2: #f0b94c;
  --danger: #ff6b6b;
  --youtube: #ff4d4f;
  --instagram: #c77dff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #06110f;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

.button-link, .download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: #06110f;
  font-weight: 800;
  text-decoration: none;
}

.secondary-link, .download-link {
  background: #243548;
  color: var(--text);
  border: 1px solid #38506b;
}

button.secondary {
  background: #243548;
  color: var(--text);
  border: 1px solid #38506b;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

button.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: wait; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1018;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

textarea { resize: vertical; }

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: #0b0f17;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(22px, 3vw, 34px); }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.top-actions, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: #0d131d;
  color: var(--muted);
  border: 1px solid var(--line);
  min-height: 38px;
  padding: 0 10px;
}

.tab.active {
  background: #1a2a36;
  color: var(--text);
  border-color: var(--accent);
}

.tab-view { display: none; }
.tab-view.active { display: block; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel-head, .editor-head, .list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head p, .editor-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-name, .day {
  min-height: 42px;
  border-radius: 8px;
}

.day-name {
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.day {
  border: 1px solid var(--line);
  background: #0d131d;
  padding: 7px;
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 72px;
}

.day.muted { opacity: .35; }
.day.today { border-color: var(--accent); }
.day strong { font-size: 12px; }

.pill {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  padding: 3px 6px;
  font-size: 11px;
  color: white;
  cursor: pointer;
}

.pill.instagram, .dot.instagram { background: var(--instagram); }
.pill.youtube, .dot.youtube { background: var(--youtube); }
.pill.both, .dot.both { background: var(--accent-2); color: #111; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 6px;
}

.content-list {
  display: grid;
  gap: 8px;
  max-height: 48vh;
  overflow: auto;
}

.content-item {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 12px;
  min-height: auto;
}

.content-item.active { border-color: var(--accent); }
.content-item small { color: var(--muted); display: block; margin-top: 6px; }

.archive-list, .stats-list {
  display: grid;
  gap: 12px;
}

.archive-card, .stats-row {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.archive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.archive-head small, .stats-row small, .muted-text {
  color: var(--muted);
}

.small-btn {
  min-height: 34px;
  padding: 0 10px;
}

.video-grid {
  display: grid;
  gap: 10px;
}

.video-preview {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.video-preview video {
  width: 100%;
  max-height: 320px;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-summary div {
  background: #0d131d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.stats-summary strong {
  display: block;
  font-size: 22px;
}

.stats-summary span, .stats-row span {
  color: var(--muted);
  font-size: 12px;
}

.stats-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) repeat(4, minmax(44px, auto)) auto;
  align-items: center;
  gap: 10px;
}

.stats-row > div:not(:first-child) {
  display: grid;
  gap: 2px;
  justify-items: end;
}

form, .stack {
  display: grid;
  gap: 16px;
}

.settings-form small {
  color: var(--accent);
}

.export-box {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.export-box h2 {
  margin-bottom: 10px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.media-section {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.media-section h3, .outputs h3, .media-preview-section h3 { margin-bottom: 12px; }

.file-box {
  background: #0d131d;
  border: 1px dashed #334359;
  border-radius: 8px;
  padding: 12px;
}

.file-box small {
  color: var(--accent);
  min-height: 16px;
}

.media-preview-section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.media-preview-card {
  display: grid;
  gap: 8px;
  background: #0d131d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.media-preview-card small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-preview-card audio,
.media-preview-card video {
  width: 100%;
}

.media-preview-card video {
  max-height: 320px;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.media-image-link {
  display: block;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.media-image-link img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
}

.outputs {
  margin-top: 18px;
  background: #0d131d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.output-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  margin: 0 8px 8px 0;
  background: #223246;
  color: var(--text);
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #152235;
  border: 1px solid #38506b;
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.error { color: var(--danger); min-height: 20px; }

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(430px, 100%);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .content-list { max-height: none; }
}

@media (max-width: 640px) {
  .topbar, .panel-head, .editor-head, .list-head {
    align-items: stretch;
    flex-direction: column;
  }
  .grid.two { grid-template-columns: 1fr; }
  .media-preview-grid { grid-template-columns: 1fr; }
  .stats-summary { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stats-row > div:not(:first-child) { justify-items: start; }
  .layout { padding: 10px; }
  .panel { padding: 12px; }
}
