:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-soft: #FBFAF8;
  --surface-dim: #EFEDE8;
  --ink: #1A1815;
  --ink-strong: #0E0C0A;
  --ink-soft: #6F675A;
  --line: #EAE7E0;
  --accent: #FF5C38;
  --accent-strong: #F04E2B;
  --accent-soft: #FFEDE7;
  --accent-text: #C43A12;
  --on-accent: #2A1006;
  --on-ink: #F7F6F3;

  --idea: #8F5E17;
  --idea-bg: #FAF1DF;
  --shoot: #C93A20;
  --shoot-bg: #FDE9E3;
  --edit: #3059C4;
  --edit-bg: #E9EFFC;
  --live: #25794D;
  --live-bg: #E3F4EA;

  --font-body: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 24, 21, 0.05), 0 4px 14px rgba(26, 24, 21, 0.05);
  --shadow-lift: 0 2px 4px rgba(26, 24, 21, 0.06), 0 10px 28px rgba(26, 24, 21, 0.1);
}

* { box-sizing: border-box; }

html, body { overflow-x: clip; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
  flex-wrap: wrap;
}

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

.brand h1 {
  font-size: 21px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

.brand h1 .dot { color: var(--accent); }

.brand-sub {
  font-size: 13px;
  color: var(--ink-soft);
}

.tabs {
  display: flex;
  gap: 2px;
  margin-left: 12px;
  background: var(--surface-dim);
  padding: 4px;
  border-radius: 12px;
}

.tab {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  padding: 7px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.tab:hover { color: var(--ink); }

.tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(26, 24, 21, 0.1);
}

.btn-new {
  margin-left: auto;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  min-height: 44px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 92, 56, 0.28);
  transition: background 0.15s ease;
}
.btn-new:hover {
  background: var(--accent-strong);
}

.btn-icon {
  font-size: 16px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 11px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.btn-icon:hover { color: var(--ink); border-color: var(--ink-soft); }

/* ---------- Views ---------- */

#app { padding: 28px 28px 60px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 16px;
}

.column {
  background: rgba(26, 24, 21, 0.035);
  border-radius: 16px;
  padding: 12px;
  min-height: 300px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  padding: 2px 6px;
}

.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.idea { background: var(--idea); }
.status-dot.shoot { background: var(--shoot); box-shadow: 0 0 0 3px var(--shoot-bg); animation: pulse 1.6s infinite; }
.status-dot.edit { background: var(--edit); }
.status-dot.live { background: var(--live); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--shoot-bg); }
  50% { box-shadow: 0 0 0 6px var(--shoot-bg); }
}

.column-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 400;
  background: var(--surface);
  padding: 1px 8px;
  border-radius: 100px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 10px;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
.card:active { cursor: grabbing; }

.card-title {
  font-weight: 650;
  font-size: 14.5px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
}

.avatar {
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--edit-bg);
  color: var(--edit);
  font-size: 9.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body);
}

.column.drag-over {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---------- Calendar ---------- */

.calendar-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.calendar-head h2 {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0;
}
.cal-nav {
  font-family: var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  width: 32px; height: 32px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.cal-nav:hover { color: var(--ink); border-color: var(--ink-soft); }

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

.cal-dow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-align: center;
  padding-bottom: 4px;
}
.cal-dow:first-child { color: var(--shoot); }
.cal-dow:nth-child(7) { color: var(--edit); }

.cal-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 96px;
  padding: 7px;
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.cal-item {
  font-size: 11.5px;
  padding: 3px 7px;
  border-radius: 6px;
  margin-bottom: 3px;
  cursor: pointer;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-item.idea { background: var(--idea-bg); color: var(--idea); }
.cal-item.shoot { background: var(--shoot-bg); color: var(--shoot); }
.cal-item.edit { background: var(--edit-bg); color: var(--edit); }
.cal-item.live { background: var(--live-bg); color: var(--live); }

/* ---------- Stats table ---------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.stats-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--surface);
}
.stats-table th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: left;
  background: var(--surface-soft);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.stats-table td {
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.stats-table td.title-cell { font-weight: 650; }
.stats-table th.num, .stats-table td.num { text-align: right; font-family: var(--font-mono); font-size: 12.5px; }
.stats-table tr:hover td { background: var(--surface-soft); cursor: pointer; }

.status-pill {
  font-size: 11px;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: 100px;
}
.status-pill.idea { background: var(--idea-bg); color: var(--idea); }
.status-pill.shoot { background: var(--shoot-bg); color: var(--shoot); }
.status-pill.edit { background: var(--edit-bg); color: var(--edit); }
.status-pill.live { background: var(--live-bg); color: var(--live); }

/* ---------- Detail (영상 분석) ---------- */

.detail-wrap { max-width: 760px; }

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.detail-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
#detailBack { white-space: nowrap; }
#d-youtube-open {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

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

@media (max-width: 640px) {
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .detail-head { flex-wrap: wrap; }
}

/* ---------- Modal ---------- */

.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(20, 18, 14, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}
.modal-backdrop.open .modal {
  animation: modalIn 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

.modal-head {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}
.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent-text);
}
.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--ink-soft);
  line-height: 1;
  border-radius: 8px;
  padding: 2px 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover { background: var(--surface-soft); color: var(--ink); }

.field {
  display: block;
  margin-bottom: 13px;
}
.field span {
  display: block;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  background: var(--surface-soft);
  color: var(--ink);
  resize: vertical;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field input, .field select { min-height: 44px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
  background: var(--surface);
  border-color: var(--accent);
}

.btn-ai {
  float: right;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--accent-text);
  background: transparent;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  padding: 2px 9px;
  margin-top: -3px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-ai:hover { background: var(--accent-soft); }
.btn-ai:disabled { opacity: 0.55; cursor: default; }

.idea-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: -4px 0 13px;
}
.idea-suggestions:empty { display: none; }
.idea-item {
  text-align: left;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color 0.15s ease;
}
.idea-item:hover { border-color: var(--accent); }
.idea-title {
  display: block;
  font-weight: 650;
  font-size: 13.5px;
  color: var(--ink);
}
.idea-why {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.field-row.stats-fields { grid-template-columns: repeat(4, 1fr); }

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.spacer { flex: 1; }

.btn-primary, .btn-ghost, .btn-danger {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13.5px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease;
}
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink-strong); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-soft); }
.btn-danger { background: transparent; color: var(--shoot); border-color: var(--shoot-bg); }
.btn-danger:hover { background: var(--shoot-bg); }

/* ---------- Responsive ---------- */

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

@media (max-width: 640px) {
  .board { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .field-row.stats-fields { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot.shoot { animation: none; }
  .card, .btn-new, .btn-primary { transition: none; }
  .modal-backdrop.open .modal { animation: none; }
}
