:root {
  --bg: #08111f;
  --bg-accent: #0f1b31;
  --panel: rgba(15, 27, 49, 0.86);
  --panel-solid: #101c33;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f8fafc;
  --muted: #b4c1d4;
  --accent: #f59e0b;
  --accent-2: #38bdf8;
  --success: #22c55e;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.42);
  --radius: 24px;
  --radius-sm: 16px;
  --max-width: 1320px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.12), transparent 30%),
    linear-gradient(180deg, #08111f 0%, #0b1324 100%);
  overflow-x: hidden;
}

body.editor-mode {
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.28), transparent 26%),
    radial-gradient(circle at top right, rgba(186, 230, 253, 0.2), transparent 30%),
    linear-gradient(180deg, #dff4ff 0%, #cfeeff 38%, #bfe6fb 100%);
  color: #10233b;
}

body.editor-mode .page-bg {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.4), rgba(0,0,0,0.1));
}

body.editor-mode .brand-subtitle,
body.editor-mode .lead,
body.editor-mode .goal-callout,
body.editor-mode .lesson-body p,
body.editor-mode .lesson-body li,
body.editor-mode .lesson-card p,
body.editor-mode .asset-card p,
body.editor-mode .detail-meta,
body.editor-mode .delete-checkbox,
body.editor-mode .form-errors,
body.editor-mode .errorlist {
  color: #36506b;
}

body.editor-mode .hero-copy,
body.editor-mode .searchbar,
body.editor-mode .lesson-card,
body.editor-mode .panel,
body.editor-mode .empty-state,
body.editor-mode .editor-panel,
body.editor-mode .auth-card,
body.editor-mode .preview-surface,
body.editor-mode .asset-editor-card {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(120, 170, 210, 0.28);
  box-shadow: 0 20px 46px rgba(74, 144, 184, 0.16);
  backdrop-filter: blur(12px);
}

body.editor-mode .editor-tip-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(221, 241, 255, 0.88));
  border-color: rgba(120, 170, 210, 0.28);
  box-shadow: 0 20px 46px rgba(74, 144, 184, 0.16);
}

body.editor-mode .lesson-hero,
body.editor-mode .preview-hero {
  background: linear-gradient(180deg, rgba(241, 249, 255, 0.96), rgba(225, 243, 255, 0.94));
  border-color: rgba(120, 170, 210, 0.28);
}

body.editor-mode .editor-input,
body.editor-mode .editor-textarea,
body.editor-mode .editor-select,
body.editor-mode .auth-form input,
body.editor-mode .searchbar input {
  background: rgba(244, 251, 255, 0.96);
  border-color: rgba(120, 170, 210, 0.34);
  color: #10233b;
}

body.editor-mode .editor-body-input {
  background:
    linear-gradient(180deg, rgba(125, 211, 252, 0.12), rgba(191, 230, 251, 0.08)),
    rgba(244, 251, 255, 0.98);
}

body.editor-mode .topnav a,
body.editor-mode .searchbar button,
body.editor-mode .video-link,
body.editor-mode .topnav-button,
body.editor-mode .primary-button,
body.editor-mode .secondary-button {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(120, 170, 210, 0.34);
  color: #12314d;
}

body.editor-mode .secondary-button,
body.editor-mode .video-link {
  background: rgba(237, 248, 255, 0.9);
}

body.editor-mode .primary-button {
  background: linear-gradient(135deg, #7dd3fc, #bae6fd);
  color: #0b2a42;
}

body.editor-mode .panel-label,
body.editor-mode .brand-mark {
  background: linear-gradient(135deg, #7dd3fc, #dbeafe);
  color: #0b2a42;
}

body.editor-mode .video-placeholder {
  border-color: rgba(125, 211, 252, 0.45);
  background: linear-gradient(180deg, rgba(219, 234, 254, 0.8), rgba(224, 242, 254, 0.86));
}

body.editor-mode .goal-callout {
  border-left-color: #38bdf8;
  background: rgba(125, 211, 252, 0.12);
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0.12));
}

a { color: inherit; text-decoration: none; }

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

.topbar,
.site-main {
  width: min(var(--max-width), calc(100vw - 48px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #fb7185);
  color: #08111f;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(245, 158, 11, 0.2);
}

.brand-title {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
}

.topnav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.topnav a,
.searchbar button,
.video-link,
.topnav-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  background: rgba(16, 28, 51, 0.78);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.topnav a:hover,
.searchbar button:hover,
.lesson-card:hover,
.video-link:hover,
.topnav-button:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 158, 11, 0.5);
}

.inline-form {
  margin: 0;
}

.topnav-button,
.primary-button,
.secondary-button {
  cursor: pointer;
}

.site-main {
  padding-bottom: 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: end;
  margin-bottom: 28px;
}

.hero-copy,
.searchbar,
.lesson-card,
.panel,
.empty-state {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-copy {
  border-radius: var(--radius);
  padding: 28px 30px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

h1, h2, h3, p {
  margin-top: 0;
}

.hero h1,
.lesson-hero h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.lead,
.goal-callout,
.lesson-body p,
.lesson-body li,
.lesson-card p,
.asset-card p,
.detail-meta {
  color: var(--muted);
}

.searchbar {
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.searchbar input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.35);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

.editor-tip-card {
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), rgba(56, 189, 248, 0.08));
  box-shadow: var(--shadow);
}

.editor-tip-card strong {
  display: block;
  margin-bottom: 10px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.lesson-card {
  display: block;
  padding: 22px;
  border-radius: var(--radius);
}

.lesson-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 0.84rem;
  color: var(--muted);
}

.lesson-number {
  color: var(--accent);
  font-weight: 800;
}

.lesson-card h2 {
  margin-bottom: 10px;
  font-size: 1.22rem;
}

.editor-link-text {
  display: inline-flex;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 700;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.85fr);
  gap: 22px;
  align-items: start;
}

.lesson-article,
.lesson-sidebar {
  min-width: 0;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 180px);
}

.auth-card {
  width: min(520px, 100%);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field label {
  color: var(--text);
  font-weight: 700;
}

.form-errors,
.errorlist {
  color: #fecaca;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.92rem;
}

.editor-input,
.editor-textarea,
.editor-select,
.auth-form input {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.42);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

.editor-textarea {
  resize: vertical;
  line-height: 1.8;
}

.editor-textarea-short {
  min-height: 96px;
}

.editor-body-input {
  min-height: 520px;
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.06), rgba(56, 189, 248, 0.03)),
    rgba(2, 6, 23, 0.65);
}

.editor-shell {
  display: grid;
  gap: 18px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #fb7185);
  color: #08111f;
  border-color: transparent;
  font-weight: 800;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1.2fr) minmax(420px, 0.8fr);
  gap: 22px;
  align-items: start;
}

.editor-pane {
  min-width: 0;
}

.editor-pane-form {
  display: grid;
  gap: 16px;
}

.editor-panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 28, 51, 0.92), rgba(10, 18, 32, 0.92));
  box-shadow: var(--shadow);
  padding: 18px;
}

.asset-editor-list {
  display: grid;
  gap: 14px;
}

.asset-editor-card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(2, 6, 23, 0.34);
  padding: 16px;
}

.asset-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
}

.editor-input-small {
  max-width: 120px;
}

.delete-row {
  margin-top: 8px;
}

.delete-checkbox {
  color: var(--muted);
  font-size: 0.92rem;
}

.editor-submit-row {
  display: flex;
  justify-content: flex-start;
}

.preview-sticky {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
}

.preview-surface {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 26, 40, 0.98), rgba(10, 18, 32, 0.98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-hero {
  margin-bottom: 0;
  border-radius: 0;
  box-shadow: none;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.preview-video-card {
  margin-top: 0;
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.flash-message {
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.flash-message.success {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.35);
}

.flash-message.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(248, 113, 113, 0.34);
}

.lesson-article {
  padding-bottom: 18px;
}

.lesson-hero {
  padding: 28px 30px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 35, 61, 0.94), rgba(15, 27, 49, 0.94));
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.goal-callout {
  margin: 0;
  font-size: 1rem;
  line-height: 1.8;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  background: rgba(245, 158, 11, 0.08);
  border-radius: 0 16px 16px 0;
}

.lesson-body {
  padding: 8px 6px 0;
}

.lesson-body h2 {
  margin: 26px 0 12px;
  font-size: 1.45rem;
}

.lesson-body h3 {
  margin: 22px 0 10px;
  font-size: 1.15rem;
}

.lesson-body p,
.lesson-body li {
  line-height: 1.95;
  font-size: 1rem;
}

.lesson-body ol,
.lesson-body ul {
  padding-left: 1.4rem;
  color: var(--muted);
}

.lesson-body li + li {
  margin-top: 8px;
}

.lesson-body pre {
  overflow-x: auto;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  background: #07101d;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.lesson-body code {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
  background: rgba(255,255,255,0.06);
  padding: 0.15em 0.35em;
  border-radius: 8px;
}

.lesson-body pre code {
  display: block;
  padding: 0;
  background: transparent;
  color: #d6e4ff;
}

.table-wrap {
  overflow-x: auto;
  margin: 14px 0 18px;
}

.lesson-body table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 18px;
  overflow: hidden;
}

.lesson-body th,
.lesson-body td {
  border: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  background: rgba(16, 28, 51, 0.72);
}

.lesson-body th {
  color: var(--text);
  background: rgba(20, 35, 61, 0.95);
}

.lesson-sidebar {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.panel {
  border-radius: var(--radius);
  padding: 18px;
}

.panel-label {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: #0b1324;
  background: linear-gradient(135deg, var(--accent), #fbbf24);
  font-weight: 800;
}

.video-placeholder {
  min-height: 240px;
  border-radius: 20px;
  border: 1px dashed rgba(245, 158, 11, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), rgba(56, 189, 248, 0.06));
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.video-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.asset-list {
  display: grid;
  gap: 12px;
}

.asset-card {
  border-radius: 18px;
  padding: 14px;
  background: rgba(2, 6, 23, 0.34);
  border: 1px solid var(--line);
}

.asset-kind {
  color: var(--accent-2);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.detail-meta {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.empty-state {
  border-radius: var(--radius);
  padding: 20px;
  color: var(--muted);
}

.empty-state.compact {
  padding: 16px;
}

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

  .lesson-sidebar {
    position: static;
  }

  .preview-sticky {
    position: static;
  }
}

@media (max-width: 1180px) {
  .editor-layout {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  }
}

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

  .preview-sticky {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .site-main {
    width: min(var(--max-width), calc(100vw - 28px));
  }

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

  .searchbar {
    flex-direction: column;
    align-items: stretch;
  }

  .lesson-hero,
  .hero-copy,
  .panel,
  .auth-card,
  .editor-panel {
    padding: 20px;
  }

  .editor-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .asset-grid {
    grid-template-columns: 1fr;
  }
}
