:root {
  --bg: #0f1419;
  --bg-elev: #1a2330;
  --bg-card: #1e2832;
  --bg-card-hover: #243240;
  --border: #2a3744;
  --text: #ffffff;
  --text-dim: #b5bac1;
  --text-mute: #8a94a0;
  --accent: #f8991c;
  --accent-hover: #ffaa33;
  --accent-text: #1a1a1a;
  --danger: #ff5c5c;
  --success: #4ade80;
  --radius: 6px;
  --radius-lg: 10px;
  --max-w: 1280px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

img, audio, video, iframe { max-width: 100%; }

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

button, .btn {
  font: inherit;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease;
}
button:hover, .btn:hover { background: var(--accent-hover); color: var(--accent-text); }
button:disabled { background: #555; color: #999; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--accent); }

.btn-block { width: 100%; padding: 12px; }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }

/* ===== header ===== */
.site-header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}
.logo .accent { color: var(--accent); }
.search { flex: 1; max-width: 480px; }
.search input { background: #11161e; }
.cat-tabs { display: flex; gap: 4px; align-items: center; }
.cat-tabs a {
  padding: 8px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}
.cat-tabs a:hover { background: var(--bg-card); color: var(--text); }
.cat-tabs a.active {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
}
.nav { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.nav a {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-dim);
}
.nav a:hover, .nav a.active { background: var(--bg-card); color: var(--text); }
.nav .btn { margin-left: 8px; padding: 8px 16px; font-size: 14px; }

/* ===== main container ===== */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.section-title .more {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}
.section { margin-bottom: 48px; }

/* ===== card grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}
.card {
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.cover {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #2a3744, #1a2330);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 800;
  color: var(--accent);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease;
}
.card:hover .cover { transform: translateY(-2px); }
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4));
  pointer-events: none;
}
.cover .play-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 1;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
}
.card:hover .play-badge { opacity: 1; transform: translateY(0); }

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { font-size: 12px; color: var(--text-mute); }

/* ===== forms / auth pages ===== */
.auth-shell {
  max-width: 400px;
  margin: 80px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
}
.auth-shell h1 { font-size: 24px; margin: 0 0 6px; }
.auth-shell .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; }
.auth-shell .alt { margin-top: 16px; font-size: 13px; color: var(--text-dim); text-align: center; }
.auth-shell .alt a { color: var(--accent); }

/* ===== alerts ===== */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-size: 14px;
}
.alert.error { background: rgba(255,92,92,0.1); color: var(--danger); border: 1px solid rgba(255,92,92,0.3); }
.alert.success { background: rgba(74,222,128,0.1); color: var(--success); border: 1px solid rgba(74,222,128,0.3); }
.alert.info { background: rgba(248,153,28,0.1); color: var(--accent); border: 1px solid rgba(248,153,28,0.3); }

/* ===== story / player ===== */
.player-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 40px;
  margin-top: 24px;
}
.player-shell .cover { width: 320px; aspect-ratio: 1; font-size: 96px; }
.player-meta h1 { font-size: 32px; margin: 0 0 8px; }
.player-meta .meta-row { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }

.player-controls {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 24px;
}
.player-controls audio { width: 100%; margin: 8px 0; }
.player-controls .now-playing { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

/* ===== studio ===== */
.studio-shell { max-width: 820px; margin: 0 auto; }
.segment-editor {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 12px 0;
}
.segment-editor .seg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.segment-editor .seg-header strong { color: var(--text); }
.segment-editor .remove-btn {
  background: transparent;
  color: var(--text-mute);
  padding: 4px 8px;
  font-size: 12px;
}
.segment-editor .remove-btn:hover { color: var(--danger); background: transparent; }
.segment-editor textarea { min-height: 80px; resize: vertical; }

.studio-status {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  font-size: 14px;
  color: var(--text-dim);
}
.studio-status .status-row { display: flex; gap: 8px; align-items: center; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== account ===== */
.account-shell { max-width: 720px; margin: 0 auto; }
.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}
.account-card h2 { margin: 0 0 12px; font-size: 18px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14px; }
.kv .k { color: var(--text-dim); }

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.tier-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.tier-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tier-card.current { border-color: var(--accent); background: rgba(248,153,28,0.08); }
.tier-card h3 { margin: 0 0 4px; font-size: 16px; }
.tier-card .tier-price { color: var(--accent); font-weight: 700; margin: 4px 0 8px; }
.tier-card ul { padding-left: 18px; margin: 8px 0 0; font-size: 13px; color: var(--text-dim); }

/* ===== empty / loading ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== mobile ===== */
@media (max-width: 720px) {
  .header-inner { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .cat-tabs { order: 2; gap: 2px; }
  .cat-tabs a { padding: 6px 10px; font-size: 13px; }
  .nav { gap: 0; flex-wrap: wrap; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .container { padding: 20px 16px 60px; }
  .player-shell { grid-template-columns: 1fr; }
  .player-shell .cover { width: 100%; max-width: 320px; margin: 0 auto; }
  .player-meta h1 { font-size: 24px; word-break: break-word; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .cover { font-size: 36px; }
  .card-title { word-break: break-word; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv .k { margin-top: 8px; }
  .tier-grid { grid-template-columns: 1fr; }
  /* 가로로 늘어선 버튼 행이 좁은 화면에서 넘치지 않도록 줄바꿈 */
  .studio-shell [style*="display:flex"],
  .studio-shell [style*="display: flex"] { flex-wrap: wrap; }
  pre, code { white-space: pre-wrap; word-break: break-word; }
}
