:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --text: #15131a;
  --muted: #6d6875;
  --line: #e5e2e8;
  --brand: #7c3aed;
  --brand-2: #a855f7;
  --brand-soft: #f2eafe;
  --danger: #dc2626;
  --success: #16803c;
  --shadow: 0 10px 30px rgba(32, 22, 52, .08);
  --header-h: 64px;
  --sidebar-w: 232px;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); min-width: 320px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { border: 0; }

.shell-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--header-h);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(240px, 680px) 1fr;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: -.04em; font-size: 20px; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 7px 18px rgba(124,58,237,.28); }
.brand-mark svg { width: 20px; }

.search-form { display: flex; min-width: 0; }
.search-input { width: 100%; height: 42px; border: 1px solid #d9d5df; background: white; border-radius: 999px 0 0 999px; padding: 0 18px; outline: none; transition: border-color .2s, box-shadow .2s; }
.search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.search-button { width: 56px; border: 1px solid #d9d5df; border-left: 0; border-radius: 0 999px 999px 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; }
.search-button svg { width: 20px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.icon-button { width: 42px; height: 42px; border-radius: 999px; display: grid; place-items: center; background: transparent; cursor: pointer; color: var(--text); }
.icon-button:hover { background: var(--surface-2); }
.icon-button svg { width: 22px; }
.primary-button, .secondary-button, .ghost-button, .danger-button {
  min-height: 42px; padding: 0 17px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 800; transition: transform .15s, background .15s, opacity .15s;
}
.primary-button { color: white; background: var(--brand); }
.primary-button:hover { background: #6d28d9; transform: translateY(-1px); }
.secondary-button { color: var(--text); background: var(--surface-2); }
.secondary-button:hover { background: #e9e6ed; }
.ghost-button { color: var(--brand); background: transparent; }
.danger-button { color: white; background: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.sidebar {
  position: fixed; z-index: 40; inset: var(--header-h) auto 0 0; width: var(--sidebar-w); overflow-y: auto; padding: 16px 12px 24px; background: var(--surface); border-right: 1px solid var(--line);
}
.nav-group { padding: 7px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.nav-link { height: 46px; padding: 0 15px; border-radius: 13px; display: flex; align-items: center; gap: 15px; font-size: 14px; font-weight: 700; }
.nav-link:hover, .nav-link[aria-current="page"] { background: var(--surface-2); }
.nav-link[aria-current="page"] { color: var(--brand); }
.nav-link svg { width: 21px; flex: 0 0 auto; }
.sidebar-note { margin: 18px 12px 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

.page-shell { min-height: 100vh; padding: calc(var(--header-h) + 28px) 32px 64px calc(var(--sidebar-w) + 32px); }
.content { width: min(1480px, 100%); margin: 0 auto; }
.page-title { margin: 0 0 6px; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.05em; }
.page-description { margin: 0; color: var(--muted); line-height: 1.7; }

.hero {
  position: relative; min-height: 380px; overflow: hidden; border-radius: 26px; display: grid; align-items: end; padding: clamp(26px, 5vw, 58px); color: white; background: radial-gradient(circle at 80% 15%, rgba(255,255,255,.23), transparent 32%), linear-gradient(135deg, #2e1065, #7c3aed 55%, #c026d3); box-shadow: var(--shadow);
}
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(9,5,17,.82), rgba(9,5,17,.28) 62%, transparent); }
.hero-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .58; }
.hero-content { position: relative; z-index: 1; width: min(670px, 100%); }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.hero-title { margin: 0 0 16px; font-size: clamp(32px, 6vw, 64px); line-height: 1.08; letter-spacing: -.06em; }
.hero-summary { max-width: 60ch; margin: 0 0 22px; line-height: 1.8; color: rgba(255,255,255,.88); }
.hero-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; font-size: 13px; font-weight: 700; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero .primary-button { color: var(--text); background: white; }
.hero .secondary-button { color: white; background: rgba(255,255,255,.18); backdrop-filter: blur(8px); }

.section { margin-top: 42px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.section-title { margin: 0; font-size: clamp(20px, 2vw, 28px); letter-spacing: -.04em; }
.section-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 20px; }
.work-card { min-width: 0; }
.work-thumb { position: relative; display: block; overflow: hidden; border-radius: 16px; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--card-accent, #7c3aed), #17111f); box-shadow: 0 7px 22px rgba(33,22,48,.11); }
.work-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.64), transparent 60%); }
.work-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.work-card:hover .work-thumb img { transform: scale(1.035); }
.thumb-placeholder { height: 100%; padding: 18px; display: flex; align-items: end; color: white; font-size: clamp(17px, 2vw, 24px); font-weight: 900; line-height: 1.25; letter-spacing: -.04em; }
.thumb-badge { position: absolute; z-index: 2; right: 9px; bottom: 9px; padding: 4px 7px; border-radius: 7px; color: white; background: rgba(0,0,0,.72); font-size: 11px; font-weight: 800; }
.work-info { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 11px; padding-top: 12px; }
.author-avatar { width: 42px; height: 42px; border-radius: 999px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--card-accent, #7c3aed), #17111f); font-size: 13px; font-weight: 900; }
.work-title { margin: 0 0 6px; display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 15px; line-height: 1.45; }
.work-meta { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.status-chip, .tag-chip { display: inline-flex; align-items: center; min-height: 27px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 800; }
.status-chip { color: var(--brand); background: var(--brand-soft); }
.tag-row { display: flex; flex-wrap: wrap; gap: 7px; }

.skeleton { position: relative; overflow: hidden; background: #e8e5eb; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.filter-bar { position: sticky; top: var(--header-h); z-index: 20; margin: -12px 0 24px; padding: 12px 0; display: flex; gap: 9px; overflow-x: auto; background: var(--bg); scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip { white-space: nowrap; min-height: 36px; padding: 0 14px; border-radius: 10px; background: #e9e7eb; cursor: pointer; font-size: 13px; font-weight: 800; }
.filter-chip.active { color: white; background: var(--text); }

.empty-state, .error-state { padding: 50px 24px; border: 1px dashed #cbc6d1; border-radius: var(--radius); text-align: center; color: var(--muted); background: rgba(255,255,255,.55); }
.error-state { color: #9f1239; border-color: #fecdd3; background: #fff1f2; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 20px); min-width: min(90vw, 340px); padding: 13px 18px; border-radius: 13px; color: white; background: rgba(24,20,29,.94); box-shadow: var(--shadow); text-align: center; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.work-header { display: grid; grid-template-columns: minmax(260px, 460px) minmax(0, 1fr); gap: clamp(26px, 5vw, 66px); align-items: center; }
.work-cover { aspect-ratio: 16/10; border-radius: 24px; overflow: hidden; color: white; background: linear-gradient(135deg, var(--work-accent, #7c3aed), #17111f); box-shadow: var(--shadow); }
.work-cover img { width: 100%; height: 100%; object-fit: cover; }
.work-cover-placeholder { height: 100%; padding: 30px; display: flex; align-items: end; font-size: clamp(24px, 4vw, 43px); font-weight: 900; line-height: 1.16; letter-spacing: -.055em; }
.work-heading h1 { margin: 0 0 18px; font-size: clamp(32px, 5vw, 58px); line-height: 1.12; letter-spacing: -.06em; }
.work-synopsis { margin: 22px 0; white-space: pre-line; color: #4f4956; line-height: 1.9; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.author-strip { margin: 25px 0; display: flex; align-items: center; gap: 13px; }
.author-strip .author-avatar { width: 48px; height: 48px; }
.author-name { font-weight: 900; }
.author-caption { color: var(--muted); font-size: 13px; }
.episode-list { display: grid; gap: 10px; }
.episode-row { display: grid; grid-template-columns: 70px minmax(0,1fr) auto; align-items: center; gap: 14px; min-height: 74px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); transition: border .15s, transform .15s; }
.episode-row:hover { border-color: #bca7dc; transform: translateY(-1px); }
.episode-number { color: var(--muted); font-size: 13px; font-weight: 800; }
.episode-title { font-weight: 850; }
.episode-meta { color: var(--muted); font-size: 12px; }

.reader-shell { padding-right: 24px; }
.reader-layout { display: grid; grid-template-columns: minmax(0, 850px) minmax(260px, 350px); gap: 30px; align-items: start; justify-content: center; }
.reader-main { min-width: 0; }
.reader-toolbar { position: sticky; top: calc(var(--header-h) + 8px); z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 9px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(14px); box-shadow: 0 8px 24px rgba(30,22,40,.06); }
.toolbar-group { display: flex; align-items: center; gap: 5px; }
.reader-card { --reader-size: 18px; --reader-line: 2.05; min-height: 70vh; padding: clamp(25px, 6vw, 76px); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 14px 40px rgba(31,24,41,.055); }
.reader-card.dark { color: #ece8f2; background: #17151a; border-color: #2d2931; }
.reader-card.sepia { color: #3e3428; background: #f4ecd8; border-color: #ddcfaf; }
.reader-card.vertical { writing-mode: vertical-rl; max-height: 78vh; overflow-x: auto; width: 100%; }
.reader-eyebrow { color: var(--brand); font-size: 13px; font-weight: 900; }
.reader-title { margin: 12px 0 42px; font-size: clamp(26px, 4vw, 40px); line-height: 1.4; letter-spacing: -.04em; }
.reader-body { white-space: pre-wrap; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: var(--reader-size); line-height: var(--reader-line); letter-spacing: .04em; }
.reader-body p { margin: 0 0 1.75em; }
.reader-side { position: sticky; top: calc(var(--header-h) + 18px); }
.up-next { padding: 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.up-next h2 { margin: 0 0 14px; font-size: 18px; }
.next-row { display: block; padding: 12px 0; border-top: 1px solid var(--line); }
.next-row:first-of-type { border-top: 0; }
.next-row strong { display: block; margin-bottom: 4px; font-size: 14px; }
.next-row span { color: var(--muted); font-size: 12px; }
.reader-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

.library-section { margin-top: 32px; }
.progress-grid { display: grid; gap: 12px; }
.progress-card { display: grid; grid-template-columns: 180px minmax(0,1fr) auto; gap: 18px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.progress-thumb { aspect-ratio: 16/9; border-radius: 12px; background: linear-gradient(135deg, var(--card-accent, #7c3aed), #17111f); overflow: hidden; }
.progress-thumb img { width: 100%; height: 100%; object-fit: cover; }

.studio-wrap { width: min(1260px, 100%); margin: 0 auto; }
.login-card { width: min(460px, 100%); margin: 10vh auto 0; padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 10px; letter-spacing: -.045em; }
.login-card p { color: var(--muted); line-height: 1.7; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 850; }
.input, .textarea, .select { width: 100%; border: 1px solid #d6d1db; border-radius: 12px; background: white; color: var(--text); outline: none; }
.input, .select { height: 44px; padding: 0 13px; }
.textarea { min-height: 128px; padding: 12px 13px; resize: vertical; line-height: 1.7; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,58,237,.11); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.field.full { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 9px; min-height: 44px; font-weight: 750; }
.check-field input { width: 18px; height: 18px; accent-color: var(--brand); }
.studio-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 28px; }
.metric-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 800; }
.metric-value { margin-top: 7px; font-size: 26px; font-weight: 950; letter-spacing: -.04em; }
.studio-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); overflow: hidden; }
.panel-head { min-height: 62px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-body { padding: 18px; }
.work-list { max-height: 70vh; overflow-y: auto; }
.admin-work-row { width: 100%; padding: 13px 15px; display: block; text-align: left; background: transparent; border-bottom: 1px solid var(--line); cursor: pointer; }
.admin-work-row:hover, .admin-work-row.active { background: var(--brand-soft); }
.admin-work-row strong { display: block; margin-bottom: 4px; }
.admin-work-row span { color: var(--muted); font-size: 12px; }
.studio-tabs { display: flex; gap: 8px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); }
.studio-tab { padding: 10px 13px; border-radius: 10px 10px 0 0; background: transparent; cursor: pointer; color: var(--muted); font-weight: 800; }
.studio-tab.active { color: var(--brand); background: var(--brand-soft); }
.episode-admin-list { display: grid; gap: 8px; margin-bottom: 18px; }
.episode-admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.episode-admin-row:hover, .episode-admin-row.active { border-color: #bca7dc; background: var(--brand-soft); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.help-text { color: var(--muted); font-size: 12px; line-height: 1.6; }

.mobile-menu { display: none; }
.mobile-only { display: none; }

@media (max-width: 1180px) {
  :root { --sidebar-w: 86px; }
  .shell-header { grid-template-columns: var(--sidebar-w) minmax(220px, 620px) 1fr; }
  .brand-text, .nav-link span, .sidebar-note { display: none; }
  .brand { justify-content: center; }
  .nav-link { justify-content: center; padding: 0; }
  .card-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .reader-layout { grid-template-columns: minmax(0, 760px) 290px; }
  .metrics { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 880px) {
  :root { --sidebar-w: 0px; --header-h: 58px; }
  .shell-header { grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; padding: 0 12px; }
  .brand-text { display: none; }
  .sidebar { display: none; }
  .page-shell { padding: calc(var(--header-h) + 20px) 18px 84px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .desktop-studio-link { display: none; }
  .mobile-only { display: grid; }
  .hero { min-height: 330px; }
  .work-header { grid-template-columns: 1fr; }
  .reader-layout { grid-template-columns: 1fr; }
  .reader-side { position: static; }
  .reader-shell { padding-right: 18px; }
  .studio-grid { grid-template-columns: 1fr; }
  .work-list { max-height: 300px; }
  .progress-card { grid-template-columns: 140px minmax(0,1fr); }
  .progress-card > :last-child { grid-column: 2; justify-self: start; }
}

@media (max-width: 620px) {
  .shell-header { grid-template-columns: auto minmax(0,1fr) auto; }
  .search-form { grid-column: 1 / -1; order: 4; position: absolute; top: 58px; left: 0; right: 0; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); display: none; }
  .search-form.open { display: flex; }
  .page-shell { padding-top: calc(var(--header-h) + 16px); }
  body.search-open .page-shell { padding-top: calc(var(--header-h) + 72px); }
  .mobile-menu { display: grid; }
  .card-grid { grid-template-columns: 1fr; gap: 24px; }
  .work-thumb { border-radius: 14px; }
  .hero { min-height: 430px; margin-inline: -18px; border-radius: 0; padding: 30px 20px; }
  .hero-title { font-size: 38px; }
  .section { margin-top: 34px; }
  .section-head { align-items: center; }
  .work-info { grid-template-columns: 38px minmax(0,1fr); }
  .author-avatar { width: 38px; height: 38px; }
  .work-cover { margin-inline: -18px; border-radius: 0; }
  .work-heading h1 { font-size: 35px; }
  .episode-row { grid-template-columns: 52px minmax(0,1fr); }
  .episode-row .secondary-button { grid-column: 2; justify-self: start; min-height: 34px; }
  .reader-toolbar { overflow-x: auto; justify-content: flex-start; }
  .reader-card { margin-inline: -18px; border-inline: 0; border-radius: 0; padding: 32px 20px; }
  .reader-title { margin-bottom: 30px; }
  .reader-nav { flex-direction: column; }
  .progress-card { grid-template-columns: 1fr; }
  .progress-card > :last-child { grid-column: 1; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .login-card { margin-top: 4vh; padding: 26px 20px; }
  .studio-head { align-items: flex-start; flex-direction: column; }
}
