:root {
  --bg: #f6f1ea;
  --sidebar-bg: #1b1a17;
  --sidebar-border: #302c28;
  --sidebar-text: #f5efe6;
  --sidebar-muted: #bcb4a7;
  --accent: #d97706;
  --card-bg: #fff8f0;
  --card-border: #e5dccf;
  --danger: #b91c1c;
  --success: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  background: linear-gradient(135deg, #f6f1ea 0%, #efe6da 60%, #f4ede4 100%);
  color: #1d1b16;
}

.app-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 24px 16px;
  border-right: 1px solid var(--sidebar-border);
  width: 240px;
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar .logo {
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
}

.sidebar .logo img {
  display: block;
  width: 160px;
  max-width: 100%;
  height: auto;
}

.sidebar.collapsed .logo img {
  width: 36px;
}

.sidebar button.toggle {
  background: transparent;
  color: var(--sidebar-muted);
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}

.sidebar nav {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar a {
  color: var(--sidebar-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(217, 119, 6, 0.2);
}

.sidebar.collapsed .label {
  display: none;
}

.main {
  padding: 32px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
}

.content-header h3 {
  margin: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.content-table {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--card-border);
  text-align: left;
}

.content-table thead th {
  background: #f5ede3;
  font-weight: 600;
}

.content-input {
  display: block;
}

.content-input + .content-input {
  margin-top: 6px;
}

.content-url input {
  width: 100%;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.asset-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 6px 12px rgba(20, 20, 20, 0.04);
}

.asset-thumb {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: #f4ede4;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
}

.asset-thumb img,
.asset-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-icon {
  font-weight: 700;
  color: #a16a19;
  background: #fff2df;
  border: 1px dashed rgba(217, 119, 6, 0.4);
  padding: 12px 16px;
  border-radius: 12px;
}

.asset-icon.video {
  color: #0f766e;
  background: #d1fae5;
  border-color: rgba(13, 148, 136, 0.4);
}

.asset-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asset-name {
  font-weight: 600;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-size {
  font-size: 12px;
  color: #6f675c;
}

.asset-actions {
  display: flex;
  gap: 8px;
}

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

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.preview-modal.is-open {
  display: flex;
}

.preview-content {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  width: min(900px, 90vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-title {
  font-weight: 700;
}

.preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 70vh;
}

.playlist-preview {
  display: grid;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.preview-subtitle {
  color: #6f675c;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.preview-frame {
  background: #11100d;
  border-radius: 24px;
  padding: 24px;
  border: 1px solid rgba(217, 119, 6, 0.3);
  box-shadow: 0 24px 50px rgba(20, 14, 4, 0.3);
  display: flex;
  justify-content: center;
}

.preview-screen {
  width: min(1100px, 100%);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: top left;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.preview-loading {
  color: #e7dfd4;
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: #fff;
  color: #1d1b16;
  cursor: pointer;
  font-weight: 600;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn.add {
  border-color: rgba(217, 119, 6, 0.4);
  color: var(--accent);
}

.icon-btn.remove {
  border-color: rgba(185, 28, 28, 0.3);
  color: var(--danger);
  padding: 6px;
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success { background: #dcfce7; color: var(--success); }
.badge.warning { background: #fef3c7; color: #a16207; }
.badge.danger { background: #fee2e2; color: var(--danger); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-hint {
  font-size: 12px;
  color: #6f675c;
}

input, select, textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  font-family: inherit;
}

.schedule-module {
  margin: 16px 0 20px;
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(217, 119, 6, 0.35);
  background: rgba(255, 248, 240, 0.6);
}

.schedule-mode {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.radio-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: #fff;
  cursor: pointer;
}

.radio-card input {
  margin-top: 4px;
}

.radio-title {
  font-weight: 700;
}

.schedule-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.weekday-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weekday-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

.weekday-pill input {
  margin: 0;
}

.schedule-windows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.schedule-days {
  display: grid;
  gap: 12px;
}

.schedule-day {
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: #fff;
  padding: 12px;
}

.schedule-day-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: none;
  background: transparent;
  padding: 0;
}

.schedule-day-toggle {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  border: none;
  background: transparent;
  cursor: pointer;
}

.schedule-day-label {
  font-weight: 700;
}

.schedule-day-body {
  display: none;
  margin-top: 10px;
}

.schedule-day.is-open .schedule-day-body {
  display: block;
}

.schedule-day-ranges {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.schedule-range {
  margin: 12px 0 16px;
}

.schedule-window {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: #fff;
}

.schedule-divider {
  color: #9a9185;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: #fff7ed;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--sidebar-bg);
  border: 1px solid var(--card-border);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

button.danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.notice {
  padding: 12px;
  border-radius: 10px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
  }

  .sidebar.collapsed {
    width: 100%;
  }

  .main {
    padding: 20px;
  }
}
