:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #192230;
  --muted: #5a6676;
  --primary: #2f6cb6;
  --primary-soft: #dfeafb;
  --border: #d7e0ea;
  --danger: #b43737;
  --warning: #8a5a11;
  --radius: 12px;
  --shadow: 0 10px 24px rgba(12, 31, 58, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef4fb 0%, var(--bg) 100%);
  color: var(--text);
  padding-top: 84px;
  padding-bottom: 100px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

code {
  font-family: "Cascadia Mono", "Consolas", monospace;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
}

.topbar-brand {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

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

.topbar-indicators {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  width: min(1200px, calc(100% - 32px));
  margin: 20px auto 0;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px;
}

.library-panel{
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.section-hint{
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
}


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

.panel-header h2 {
  font-size: 1.1rem;
}

.library-group + .library-group {
  margin-top: 14px;
}

.library-group h3 {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.library-list,
.drop-list,
.issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-list {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 90px;
  max-height: 260px;
  overflow: auto;
}

.library-item,
.empty-item,
.block-item {
  padding: 10px 12px;
  border-bottom: 1px solid #e6edf5;
}

.library-item:last-child,
.block-item:last-child,
.empty-item:last-child {
  border-bottom: 0;
}

.library-item {
  cursor: grab;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.library-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-item {
  color: var(--muted);
  font-size: 0.9rem;
}

.block-form {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 10px;
  margin-bottom: 8px;
}

.block-form label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}

.hint {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 12px;
  line-height: 1.45;
}

.inline-error {
  margin-bottom: 8px;
  color: var(--danger);
  background: #fdeced;
  border: 1px solid #f2c5c7;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.blocks-container {
  display: grid;
  gap: 12px;
}

.block-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.block-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #e9eff6;
}

.block-header-left {
  display: grid;
  gap: 8px;
}

.block-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.block-controls {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 8px;
}

.block-content {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.block-section {
  border: 1px solid #e3ebf5;
  border-radius: 8px;
  background: var(--surface-soft);
}

.block-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #e3ebf5;
}

.block-section-header strong {
  font-size: 0.9rem;
}

.section-tools {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}

.section-tools select {
  width: min(300px, 100%);
}

.drop-list {
  min-height: 58px;
}

.drop-list.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: -3px;
}

.block-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: grab;
}

.item-actions {
  display: flex;
  gap: 6px;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.item-tag {
  font-size: 0.78rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e9f0fb;
  color: #2a4b73;
}

.notice {
  background: #fff8e7;
  border: 1px solid #f0ddb1;
  color: var(--warning);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.footer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.destination-status {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.mobile-warning {
  font-size: 0.84rem;
  color: var(--warning);
  background: #fff7e6;
  border: 1px solid #f1daaa;
  border-radius: 8px;
  padding: 6px 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: 0.15s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(0.95);
}

.btn-secondary {
  background: #fff;
  color: #2f3a48;
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #f2f6fb;
}

.btn-sm {
  padding: 5px 8px;
  font-size: 0.8rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 27, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(920px, 100%);
  max-height: 86vh;
  overflow: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(5, 20, 39, 0.24);
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.modal-issues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-issues h4 {
  margin-bottom: 8px;
}

.issue-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 60px;
  font-size: 0.9rem;
  background: var(--surface-soft);
}

.tree-view {
  margin: 0;
  background: #0f1724;
  color: #e7edf8;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  min-height: 200px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 80;
  pointer-events: none;
}

.toast {
  min-width: min(92vw, 420px);
  max-width: min(92vw, 520px);
  background: rgba(24, 33, 47, 0.95);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.35;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 8px;
  }

  body {
    padding-top: 136px;
  }
}

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

  .block-form,
  .block-controls {
    grid-template-columns: 1fr;
  }

  .footer-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-actions {
    width: 100%;
  }

  .footer-actions .btn {
    flex: 1;
  }

  .modal-issues {
    grid-template-columns: 1fr;
  }

  body {
    padding-bottom: 124px;
  }

  .library-panel{ position: static; max-height: none; overflow: visible; }
}


.schedule-fields{display:flex;flex-direction:column;gap:10px}
.schedule-row{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end}
label.inline{display:flex;flex-direction:column;gap:6px;min-width:180px}

.schedule-inline{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end}


.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.library-item {
  list-style: none;
}

.thumb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 6px 16px rgba(12, 31, 58, 0.06);
  cursor: grab;
  user-select: none;
}

.thumb-card:active {
  cursor: grabbing;
}

.thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--surface-soft);
}

.thumb-sm {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  flex: 0 0 auto;
}

.thumb-audio {
  display: grid;
  place-items: center;
  font-size: 26px;
  color: var(--primary);
  border: 1px dashed var(--border);
}

.thumb-unknown {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--muted);
  border: 1px dashed var(--border);
}

.thumb-name {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.block-thumb .thumb-card-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.thumb-row-info {
  min-width: 0;
  flex: 1 1 auto;
}

.drop-list {
  min-height: 84px;
  padding: 8px;
  border-radius: 12px;
}

.drop-list.drag-over {
  outline: 2px solid var(--primary);
  background: rgba(47, 108, 182, 0.06);
}

.media-preview-img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.modal-card-media {
  max-width: 900px;
}

.modal-body-media {
  display: grid;
  gap: 12px;
}

.modal-body-media video,
.modal-body-media audio {
  width: 100%;
}
