:root {
  --bg: #f4f7fc;
  --bg-soft: #eef3fb;
  --card: #ffffff;
  --line: #dde5f2;
  --text: #121826;
  --muted: #5f6c84;
  --accent: #2a6bff;
  --accent-strong: #1752d5;
  --danger: #cf3f5e;
  --success: #0f9d7a;
  --shadow-lg: 0 24px 70px rgba(26, 44, 78, 0.14);
  --shadow-md: 0 14px 36px rgba(23, 37, 70, 0.1);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: 'Noto Sans KR', 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -4%, rgba(39, 113, 255, 0.18), transparent 25%),
    radial-gradient(circle at 87% 2%, rgba(0, 201, 168, 0.14), transparent 22%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 42%, var(--bg-soft) 100%);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  flex: 1 0 auto;
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #e7edf8;
  border-radius: 16px;
  backdrop-filter: blur(7px);
}

.topbar > div:last-child {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.brand {
  font-size: clamp(20px, 2.3vw, 26px);
  font-weight: 900;
  letter-spacing: -0.4px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.18s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(26, 49, 94, 0.14);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  border-color: var(--accent);
  color: #fff;
  background: linear-gradient(180deg, #3b7eff 0%, var(--accent) 100%);
}

.btn.primary:hover {
  border-color: var(--accent-strong);
  background: linear-gradient(180deg, #4b88ff 0%, var(--accent-strong) 100%);
}

.btn.danger {
  border-color: #f4d4de;
  color: var(--danger);
  background: linear-gradient(180deg, #fff8fa 0%, #fff0f4 100%);
}

.btn.mini {
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.story-grid {
  display: block;
  position: relative;
}

.story-side-trigger {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9;
  border: 1px solid #d4e3ff;
  border-right: 0;
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
  color: #214789;
  border-radius: 12px 0 0 12px;
  padding: 12px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(25, 45, 88, 0.16);
}

.story-side {
  position: absolute;
  right: 0;
  top: 0;
  width: 360px;
  height: 100%;
  max-height: 100%;
  overflow: auto;
  z-index: 8;
  transform: translateX(calc(100% - 14px));
  transition: transform 0.34s ease, box-shadow 0.34s ease;
}

.story-side-trigger:hover + .story-side,
.story-side:hover,
.story-grid:focus-within .story-side {
  transform: translateX(0);
  box-shadow: 0 20px 42px rgba(18, 32, 61, 0.2);
}

.stage-card {
  border-radius: var(--radius-xl);
  border: 1px solid #e4ebf7;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, #fbfdff 100%);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  min-height: 740px;
  position: relative;
  overflow: hidden;
}

.dynamic-bg {
  position: absolute;
  inset: -18% -16% auto -16%;
  height: 64%;
  background:
    radial-gradient(circle at 17% 30%, rgba(49, 109, 255, 0.34), transparent 36%),
    radial-gradient(circle at 76% 24%, rgba(0, 197, 170, 0.24), transparent 30%),
    radial-gradient(circle at 58% 74%, rgba(255, 169, 42, 0.2), transparent 27%);
  filter: blur(16px);
  z-index: 0;
  animation: drift 14s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-12px) scale(1.04); }
}

.script-box {
  position: relative;
  z-index: 2;
  min-height: 172px;
  margin-top: 12px;
  padding: 8px 8px 2px;
  max-width: 88%;
  margin-left: auto;
  margin-right: auto;
}

.script-line {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 40px);
  line-height: 1.15;
  font-family: 'Noto Sans KR', 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  letter-spacing: -0.7px;
  color: #16203a;
  opacity: 0;
  filter: blur(12px);
  transform: translateY(10px);
  text-shadow: 0 8px 32px rgba(53, 94, 176, 0.14);
  text-align: center;
  transition: opacity 0.78s ease, filter 0.78s ease, transform 0.78s ease;
}

.script-line + .script-line {
  margin-top: 10px;
}

.script-line.show {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

.quote-signature {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #dbe6fa;
  background: rgba(255, 255, 255, 0.82);
}

.quote-author {
  font-size: 12px;
  font-weight: 700;
  color: #5f6f8d;
  letter-spacing: 0.1px;
}

.quote-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eef4ff 0%, #dde9ff 100%);
  color: #2a58b8;
  font-size: 11px;
  line-height: 1;
}

.player-wrap {
  position: relative;
  z-index: 2;
  width: min(920px, 100%);
  margin: 0 auto;
  border-radius: 22px;
  border: 1px solid rgba(232, 239, 250, 0.95);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 26px 54px rgba(20, 42, 80, 0.2);
}

.player-ratio {
  position: relative;
  padding-top: 56.25%;
  background: #f0f4fd;
  border-radius: 22px;
  overflow: hidden;
}

.player-ratio iframe,
.player-ratio #yt-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 22px;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(13, 20, 38, 0.32), rgba(18, 29, 52, 0.26));
  backdrop-filter: blur(2px);
  z-index: 5;
}

.start-overlay button {
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  background: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.controls {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.side {
  border-radius: var(--radius-xl);
  border: 1px solid #e4ebf7;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
  padding: 18px;
  position: sticky;
  top: 14px;
}

.story-title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: -0.3px;
}

.meta {
  display: inline-block;
  color: #5a6a86;
  font-size: 12px;
  font-weight: 700;
  background: #f3f7ff;
  border: 1px solid #dbe6fb;
  border-radius: 999px;
  padding: 4px 10px;
  margin-right: 6px;
}

.side-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 0;
}

.admin-actions {
  margin: 8px 0 14px;
  padding: 12px;
  border: 1px dashed #cfe0ff;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbff 0%, #f0f6ff 100%);
}

.side > .side-buttons:not(.admin-actions) {
  padding-top: 12px;
  border-top: 1px solid #e8eefb;
}

.count-badge {
  font-weight: 900;
}

.comment-list {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #dbe6f9;
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, #fbfdff 0%, #f2f7ff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.comment-list::-webkit-scrollbar {
  width: 9px;
}

.comment-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cdd9ee;
}

.comment-item {
  border: 1px solid #e2eafa;
  border-radius: 10px;
  background: #fff;
  padding: 10px 9px;
  margin-bottom: 8px;
}

.comment-item:last-child {
  margin-bottom: 0;
}

.comment-author {
  font-size: 12px;
  font-weight: 900;
}

.comment-time {
  color: var(--muted);
  font-size: 11px;
}

.comment-text {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.comment-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.form-block {
  margin-top: 10px;
}

.side .form-block form {
  padding-top: 12px;
  border-top: 1px solid #e8eefb;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #2f3a52;
  font-weight: 800;
  font-size: 13px;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: #8ab0ff;
  box-shadow: 0 0 0 4px rgba(61, 123, 255, 0.14);
}

.textarea {
  min-height: 170px;
  resize: vertical;
}

.side .textarea {
  min-height: 120px;
}

.dashboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #dfe8f7;
  box-shadow: var(--shadow-md);
}

.dashboard-table th,
.dashboard-table td {
  border-bottom: 1px solid #e7eefb;
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.dashboard-table th {
  background: linear-gradient(180deg, #f7faff 0%, #edf4ff 100%);
  color: #2d3a54;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.dashboard-table tr:last-child td {
  border-bottom: 0;
}

.inline-form {
  display: inline;
}

.notice {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 10px;
  background: linear-gradient(180deg, #f4f9ff 0%, #edf6ff 100%);
  border: 1px solid #d6e7ff;
  font-size: 14px;
}

.site-footer {
  margin-top: auto;
  width: 100%;
  padding: 14px 10px;
  text-align: center;
  color: #6f7e98;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
  background: rgba(255, 255, 255, 0.86);
  border-top: 1px solid #dfe8f7;
}

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

  .stage-card {
    min-height: 650px;
  }

  .side {
    position: static;
    top: auto;
  }

  .story-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .story-side-trigger {
    display: none;
  }

  .story-side {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    transform: none;
    transition: none;
    box-shadow: var(--shadow-md);
  }
}

@media (max-width: 820px) {
  .page {
    padding: 14px;
  }

  .topbar {
    padding: 12px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar > div:last-child {
    width: 100%;
    justify-content: flex-start;
  }

  .brand {
    font-size: 20px;
  }

  .stage-card,
  .side {
    border-radius: 18px;
    padding: 14px;
  }

  .script-box {
    min-height: 150px;
  }

  .script-line {
    font-size: clamp(26px, 7vw, 34px);
  }

  .controls {
    justify-content: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .controls .btn {
    width: 100%;
  }

  .dashboard-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}


.btn.google {
  border-color: #d7e3ff;
  background: linear-gradient(180deg, #ffffff 0%, #f2f6ff 100%);
  color: #21488d;
}

.btn.google:hover {
  border-color: #aac2ff;
}
