:root {
  --bg: #070b12;
  --surface: #0e1420;
  --surface-2: #131c2b;
  --line: #1f2b3d;
  --line-soft: #172231;
  --ink: #e8eef7;
  --ink-dim: #8496ae;
  --accent: #38bdf8;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.dim {
  color: var(--ink-dim);
}

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

/* --- top bar ----------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0b111b 0%, #080d15 100%);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
}

.brand strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-sub,
.topbar-meta {
  font-size: 13px;
  color: var(--ink-dim);
}

/* --- layout ------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 470px;
  height: calc(100% - 61px);
}

.gallery {
  overflow-y: auto;
  padding: 22px 28px 60px;
}

.editor {
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}

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

  .editor {
    border-left: none;
    border-top: 1px solid var(--line);
  }
}

/* --- filters ----------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 13px;
}

.chip:hover {
  border-color: #2b3b52;
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #05121c;
  font-weight: 600;
}

/* --- gallery grid ------------------------------------------------------ */

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

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.card:hover {
  border-color: #2f4763;
  transform: translateY(-2px);
}

.card[aria-current="true"] {
  border-color: var(--accent);
}

.card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(150deg, #101a28 0%, #0a121c 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-media .placeholder {
  font-size: 13px;
  color: #47597a;
  letter-spacing: 0.1em;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(7, 11, 18, 0.82);
  border: 1px solid var(--line);
  color: var(--ink-dim);
}

.badge.ready {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.35);
}

.duration {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(7, 11, 18, 0.82);
  color: var(--ink-dim);
}

.card-body {
  padding: 13px 15px 15px;
}

.card-title {
  font-weight: 600;
  margin-bottom: 5px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card.planned .card-media,
.card.planned .card-body {
  opacity: 0.62;
}

/* --- editor ------------------------------------------------------------ */

.empty {
  padding: 90px 34px;
  text-align: center;
}

.empty-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: #33455f;
}

.empty p {
  margin: 0 0 8px;
  font-size: 14px;
}

.panel {
  padding: 22px 24px 60px;
}

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

.panel-head h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.panel-head p {
  margin: 0;
  font-size: 13px;
}

.icon-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-button:hover {
  color: var(--ink);
  border-color: #2f4763;
}

.panel-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #05090f;
  display: block;
}

.panel-spec {
  font-size: 12.5px;
  margin: 9px 0 20px;
}

/* --- ai row ------------------------------------------------------------ */

.ai {
  padding: 14px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-2);
  margin-bottom: 20px;
}

.ai-row {
  display: flex;
  gap: 8px;
}

.ai-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.hint {
  font-size: 12px;
  margin: 8px 0 0;
}

/* --- form -------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.counter {
  font-size: 11.5px;
  color: #5c718d;
  font-variant-numeric: tabular-nums;
}

.counter.over {
  color: var(--danger);
  font-weight: 600;
}

.required {
  color: var(--accent);
  margin-left: 3px;
}

input[type="text"],
select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0a1018;
  outline: none;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent);
}

input.over {
  border-color: var(--danger);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  width: 46px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0a1018;
  cursor: pointer;
}

/* --- actions ----------------------------------------------------------- */

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.quality {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex: 0 0 auto;
}

.quality select {
  width: auto;
  padding: 8px 10px;
}

.primary-button {
  flex: 1 1 auto;
  padding: 11px 18px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #04121c;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-button {
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
}

.ghost-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.ghost-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- messages and jobs -------------------------------------------------- */

.messages {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.message {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.message.error {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.07);
}

.message.warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.06);
}

.jobs {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 14px;
  background: var(--surface-2);
}

.job-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 9px;
}

.job-stage {
  color: var(--ink-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 4px;
  border-radius: 2px;
  background: #1b2637;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

.job.error .bar-fill {
  background: var(--danger);
}

.job video {
  width: 100%;
  border-radius: 8px;
  margin-top: 11px;
  display: block;
  background: #05090f;
}

.job-links {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
}

.job-links a {
  color: var(--accent);
  text-decoration: none;
}

.job-links a:hover {
  text-decoration: underline;
}

.job-error {
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 9px;
  white-space: pre-wrap;
}
