:root {
  --sidebar-width: 300px;
  --bg: #ffffff;
  --border: #e6e8ee;
  --text: #1f2937;
  --muted: #6b7280;
  --active-bg: #eef2ff;
  --active-color: #3730a3;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #f8f9fd 0%, #f5f7fb 100%);
  color: var(--text);
}

.docs-layout {
  display: flex;
  min-height: 100vh;
}

.mobile-menu-toggle,
.mobile-menu-backdrop {
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px 10px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.brand-logo {
  width: auto;
  max-width: 210px;
  max-height: 56px;
  height: auto;
  object-fit: contain;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: #4f46e5;
}

.menu {
  margin-top: 4px;
  flex: 1;
}

.docs-search {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.docs-search input {
  width: 100%;
  border: 1px solid #d6dbe6;
  border-radius: 10px;
  padding: 9px 10px;
}

.clear-search {
  font-size: 12px;
  color: #4b5563;
  text-decoration: none;
}

.menu-level {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-level .menu-level {
  padding-left: 8px;
  border-left: 1px solid #eef1f6;
  margin-left: 6px;
  margin-top: 2px;
}

.menu a {
  text-decoration: none;
  color: var(--text);
  padding: 7px 9px;
  border-radius: 7px;
  border-left: 2px solid transparent;
  display: block;
  margin: 2px 0;
  font-size: 13px;
  line-height: 1.35;
}

.menu a:hover {
  background: #f4f6ff;
}

.menu a.active {
  background: var(--active-bg);
  color: var(--active-color);
  border-left-color: #4f46e5;
  font-weight: 600;
}

.category-title {
  display: flex;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  margin-top: 7px;
  padding: 6px 8px;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 700;
}

.menu-level.depth-0 > .menu-category {
  margin-top: 8px;
}

.menu-level.depth-0 > .menu-category > .category-title {
  font-size: 10px;
  color: #6b7280;
  letter-spacing: 0.08em;
  border-top: 1px solid #eef1f6;
  padding-top: 9px;
}

.menu-category .category-title::after {
  content: "▾";
  margin-left: auto;
  transform: rotate(-90deg);
  transition: transform 0.2s ease;
  font-size: 10px;
  color: #9ca3af;
}

.menu-category.open .category-title::after {
  transform: rotate(0deg);
}

.category-children {
  display: none;
}

.menu-category.open > .category-children {
  display: block;
}

.admin-link {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #cfd7ff;
  border-radius: 10px;
  text-decoration: none;
  color: #3730a3;
  background: #eef2ff;
  font-weight: 600;
  font-size: 13px;
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.sidebar-credit {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafbff;
}

.sidebar-credit strong {
  display: block;
  font-size: 13px;
}

.sidebar-credit a {
  display: inline-block;
  margin-top: 2px;
  color: #3730a3;
  text-decoration: none;
  font-size: 13px;
}

.sidebar-credit small {
  display: block;
  margin-top: 6px;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.4;
}

.admin-link:hover {
  background: #e3e9ff;
}

.content {
  flex: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px;
}

.docs-layout.docs-layout-scribe .content.content-scribe {
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.doc-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.doc-prerequisite-badge {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #fda4af;
  border-left: 4px solid #e11d48;
  border-radius: 10px;
  background: #fff1f2;
  color: #881337;
  font-size: 14px;
  line-height: 1.45;
}

.doc-prerequisite-badge strong {
  color: #be123c;
}

.doc-prerequisite-badge a {
  color: #be123c;
  font-weight: 700;
  text-decoration: underline;
}

.doc-prerequisite-badge a:hover {
  color: #9f1239;
}

.scribe-fullpage .doc-prerequisite-badge-float {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 6;
  margin: 0;
  max-width: min(620px, calc(100% - 180px));
  background: rgba(255, 241, 242, 0.94);
  backdrop-filter: blur(2px);
  box-shadow: 0 8px 20px rgba(190, 24, 93, 0.18);
}

.doc-card-embed-only {
  padding-bottom: 16px;
}

.embed-stack-full .iframe-wrap,
.embed-stack-full video {
  width: 100%;
  max-width: 100%;
}

.scribe-fullpage .iframe-wrap {
  margin-top: 0;
  border: 0;
  padding: 0;
  background: transparent;
  height: 100vh;
  overflow: hidden;
}

.scribe-fullpage iframe {
  width: 100%;
  min-height: calc(100vh + 56px) !important;
  height: calc(100vh + 56px) !important;
  transform: translateY(-56px);
  border-radius: 0;
  display: block;
}

body.scribe-page-mode,
body.scribe-page-mode .docs-layout.docs-layout-scribe {
  overflow: hidden;
  height: 100vh;
}

.scribe-fullpage {
  position: relative;
  background: #fff;
}

.scribe-video-chip {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 5;
  border: 1px solid #86efac;
  background: rgba(22, 101, 52, 0.94);
  color: #fff;
  border-radius: 16px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(22, 101, 52, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(2px);
}

.chip-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.8);
  animation: pulse-live 1.5s infinite;
}

.chip-text {
  display: grid;
  line-height: 1.1;
  gap: 2px;
}

.chip-text strong {
  font-size: 13px;
  font-weight: 700;
}

.chip-text small {
  font-size: 11px;
  color: #bbf7d0;
}

@keyframes pulse-live {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.8); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.scribe-video-preview {
  position: absolute;
  top: 58px;
  left: 14px;
  z-index: 5;
  width: 180px;
  height: 92px;
  border-radius: 10px;
  border: 1px solid #86efac;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}

.preview-play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.9);
  color: #052e16;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
}

.preview-lines {
  display: grid;
  gap: 6px;
  width: 88px;
}

.preview-lines i {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: rgba(187, 247, 208, 0.9);
}

.doc-video-modal {
  display: none;
}

.doc-video-modal.open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.doc-video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.doc-video-modal-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(980px, 92vw);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.35);
}

.doc-video-modal-close {
  position: absolute;
  right: 10px;
  top: 6px;
  border: 0;
  background: transparent;
  font-size: 26px;
  color: #111827;
  cursor: pointer;
}

.doc-video-modal-content .iframe-wrap {
  margin-top: 18px;
  border: 0;
  padding: 0;
  background: #000;
  height: 82vh;
  overflow: hidden;
}

.doc-video-modal-content .iframe-wrap iframe {
  width: 100%;
  height: calc(82vh + 56px);
  transform: translateY(-22px);
  border: 0;
  display: block;
}

body.video-modal-open {
  overflow: hidden;
}

.video-feature {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) 1fr;
  gap: 18px;
  align-items: start;
}

.video-feature-media .iframe-wrap,
.video-feature-media video {
  margin-top: 0;
}

.video-feature-info {
  border-left: 3px solid #dbeafe;
  padding-left: 14px;
  background: #fafcff;
  border-radius: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-right: 10px;
  position: relative;
}

.video-feature-info h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.video-feature-lines {
  height: 6px;
  background: linear-gradient(90deg, #3b82f6 0 22%, #93c5fd 22% 55%, #dbeafe 55% 100%);
  border-radius: 999px;
  margin-bottom: 10px;
}

.video-feature-info::after {
  content: "➜ ➜";
  position: absolute;
  top: 10px;
  right: 12px;
  color: #60a5fa;
  font-size: 14px;
  letter-spacing: 2px;
  font-weight: 700;
}

h1, h2, h3 {
  color: #111827;
}

p, li {
  line-height: 1.65;
}

.muted {
  color: var(--muted);
}

.iframe-wrap {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.doc-content {
  line-height: 1.7;
}

/* Admin */
.admin-wrap {
  min-height: 100vh;
  padding: 24px;
}

.admin-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
}

.admin-sidebar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 20px;
  height: fit-content;
}

.admin-sidebar h2 {
  font-size: 16px;
  margin: 0 0 10px;
}

.admin-nav-btn,
.admin-nav-link {
  display: block;
  width: 100%;
  text-align: left;
  margin: 6px 0;
  border: 1px solid #d6dbe6;
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  color: #1f2937;
  text-decoration: none;
  cursor: pointer;
}

.admin-nav-btn.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #312e81;
  font-weight: 700;
}

.admin-card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.admin-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-form {
  display: grid;
  gap: 10px;
}

.admin-form label {
  margin-top: 6px;
  font-weight: 600;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  border: 1px solid #d6dbe6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.admin-form textarea {
  resize: vertical;
}

.admin-actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-actions button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #4f46e5;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.admin-actions .danger-btn {
  background: #dc2626;
}

.admin-actions .danger-btn:hover {
  background: #b91c1c;
}

.admin-actions .warn-btn {
  background: #d97706;
}

.admin-actions .warn-btn:hover {
  background: #b45309;
}

.admin-actions form {
  margin: 0;
}

.top-gap {
  margin-top: 12px;
}

.menu-search {
  width: 100%;
  border: 1px solid #d6dbe6;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.category-cascader {
  display: grid;
  gap: 8px;
}

.rich-editor {
  background: #fff;
}

.rich-editor .toastui-editor-defaultUI {
  border-radius: 12px;
  border-color: #d6dbe6;
}

.trash-list {
  display: grid;
  gap: 10px;
}

.trash-item {
  border: 1px solid #dce2ef;
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.trash-item small {
  display: block;
  color: #6b7280;
  margin-top: 4px;
}

.page-list {
  display: grid;
  gap: 8px;
}

.page-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #dce2ef;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
}

.page-row.active {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.page-row-title {
  border: 0;
  background: transparent;
  text-align: left;
  font-weight: 600;
  color: #111827;
  cursor: pointer;
  flex: 1;
}

.admin-actions a {
  text-decoration: none;
  color: #334155;
  padding: 10px 14px;
  border: 1px solid #d4d9e6;
  border-radius: 10px;
}

.alert {
  margin: 14px 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
}

.alert-ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.menu-builder {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcff;
  padding: 10px;
}

.builder-list {
  list-style: none;
  margin: 0;
  padding-left: 12px;
}

.builder-item {
  margin: 6px 0;
}

.builder-label {
  border: 1px solid #dce2ef;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  cursor: move;
  user-select: none;
}

.builder-label.with-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: 1px solid #d1d5db;
  background: #f9fafb;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.mini-btn.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.builder-item.dragging .builder-label {
  opacity: 0.6;
}

@media (max-width: 900px) {
  .docs-layout {
    display: block;
  }

  .sidebar {
    width: min(84vw, 320px);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    background: #fff;
  }

  .docs-layout.menu-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: inline-flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1002;
    border: 1px solid #d6dbe6;
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    font-weight: 600;
    color: #111827;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.4);
  }

  body.menu-open .mobile-menu-backdrop {
    display: block;
  }

  .content {
    padding: 56px 14px 16px;
  }

  body.scribe-page-mode .content.content-scribe {
    padding: 0;
  }

  .scribe-fullpage .doc-prerequisite-badge-float {
    top: 12px;
    right: 10px;
    left: auto;
    width: min(56vw, 300px);
    max-width: calc(100% - 160px);
    padding: 9px 10px;
    font-size: 12px;
    line-height: 1.35;
    border-left-width: 3px;
  }

  .video-feature {
    grid-template-columns: 1fr;
  }

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

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
  }
}
