:root {
  --mm-navy: #2C3E50;
  --mm-blue: #3498DB;
  --mm-purple: #5856D6;
  --mm-purple-soft: rgba(88, 86, 214, 0.16);
  --mm-canvas: #F2F2F7;
  --mm-card: #FFFFFF;
  --mm-text: #1E293B;
  --mm-muted: #64748B;
  --mm-border: #E2E8F0;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 0 130px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: #F8FAFC;
  color: var(--mm-text);
  line-height: 1.55;
  overflow-x: hidden;
}

.site-header {
  background: linear-gradient(135deg, #2C3E50 0%, #1E293B 100%);
  color: #FFFFFF;
  padding: 22px 16px 18px;
  text-align: center;
}

.site-header .eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #93C5FD;
  font-weight: 700;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 800;
}

.site-header .subtitle {
  margin: 0 auto 12px;
  max-width: 720px;
  font-size: 14px;
  color: #E2E8F0;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-size: 13px;
}

.site-header nav a {
  color: #BAE6FD;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.site-header nav a:hover {
  background: rgba(255, 255, 255, 0.2);
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 12px;
}

/* MindNode-style Workspace Shell */
.mm-shell {
  background: var(--mm-canvas);
  border: 1px solid #CBD5E1;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.mm-shell.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  border-radius: 0;
  border: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body:has(.mm-shell.is-fullscreen) #adfit-bottom,
body:has(.mm-inline-editor:not([hidden])) #adfit-bottom {
  display: none !important;
}

.mm-shell.is-fullscreen .mm-topbar,
.mm-shell.is-fullscreen .mm-status-strip {
  display: none !important;
}

.mm-shell.is-fullscreen .mm-floating-pill:not([hidden]),
.mm-shell.is-fullscreen .mm-inline-editor:not([hidden]) {
  position: relative;
  z-index: 45;
  flex-shrink: 0;
}

.mm-shell.is-fullscreen .mm-workspace-body {
  flex: 1;
  height: 100%;
  min-height: 0;
}

.mm-shell.is-fullscreen .mm-canvas-wrap {
  flex: 1;
  height: 100%;
  min-height: 0;
}

.mm-shell.is-fullscreen .mm-svg-canvas {
  width: 100%;
  height: 100% !important;
  min-height: 0 !important;
}

/* Top White Toolbar with Purple (#5856D6) Icons */
.mm-topbar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--mm-border);
  padding: 6px 10px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  z-index: 10;
}

.mm-topbar::-webkit-scrollbar,
.mm-status-strip::-webkit-scrollbar,
.mm-owner-141-bar::-webkit-scrollbar {
  display: none;
}

.mm-topbar-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.mm-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #F8FAFC;
  color: var(--mm-purple);
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.mm-icon-btn:hover {
  background: var(--mm-purple-soft);
  border-color: var(--mm-purple);
}

.mm-icon-btn.is-active {
  background: var(--mm-purple);
  color: #FFFFFF;
  border-color: var(--mm-purple);
}

.mm-icon-btn:disabled {
  color: #94A3B8;
  cursor: not-allowed;
  opacity: 0.65;
}

.mm-select {
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mm-text);
  background: #FFFFFF;
}

/* Stats Strip */
.mm-status-strip {
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid #E2E8F0;
  padding: 4px 10px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--mm-muted);
}

.mm-stats-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  flex-shrink: 0;
}

.mm-stat-pill {
  background: #F1F5F9;
  color: #334155;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  flex-shrink: 0;
}

.mm-depth-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mm-compact-btn {
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 6px;
}

/* Main Workspace Body: Outline + Canvas + Inspector */
.mm-workspace-body {
  display: flex;
  position: relative;
  min-height: 600px;
  background: var(--mm-canvas);
}

.mm-side-drawer {
  width: 280px;
  background: #FFFFFF;
  border-right: 1px solid var(--mm-border);
  padding: 12px;
  overflow-y: auto;
  max-height: 740px;
  z-index: 20;
}

.mm-side-drawer[hidden],
.mm-inspector[hidden] {
  display: none !important;
}

.mm-inspector {
  width: 280px;
  background: #FFFFFF;
  border-left: 1px solid var(--mm-border);
  padding: 12px;
  overflow-y: auto;
  max-height: 740px;
  z-index: 20;
}

.mm-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #F1F5F9;
}

.mm-drawer-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--mm-navy);
}

.mm-drawer-close {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  cursor: pointer;
}

.mm-drawer-close:hover {
  background: var(--mm-purple-soft);
  color: var(--mm-purple);
  border-color: var(--mm-purple);
}

.mm-outline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12.5px;
}

.mm-outline-item {
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #334155;
}

.mm-outline-item:hover,
.mm-outline-item.is-selected {
  background: var(--mm-purple-soft);
  color: var(--mm-purple);
  font-weight: 700;
}

.mm-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Interactive Canvas Stage */
.mm-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 580px;
  background: var(--mm-canvas);
  touch-action: none;
  user-select: none;
}

.mm-svg-canvas {
  width: 100%;
  height: clamp(560px, 72vh, 760px);
  display: block;
  cursor: grab;
}

.mm-svg-canvas:active {
  cursor: grabbing;
}

/* Top-Right Canvas Zoom & Fullscreen HUD */
.mm-canvas-hud {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 16;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  padding: 3px 5px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.10);
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.24s ease, transform 0.24s ease, visibility 0s linear 0s;
}

.mm-shell.is-fullscreen .mm-canvas-hud.is-hud-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.55s ease, transform 0.55s ease, visibility 0s linear 0.55s;
}

.mm-hud-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1E293B;
  cursor: pointer;
  line-height: 1.2;
}

.mm-hud-btn:hover {
  background: var(--mm-purple-soft);
  color: var(--mm-purple);
}

.mm-hud-btn.is-active {
  background: var(--mm-purple);
  color: #FFFFFF;
}

.mm-hud-zoom-label {
  min-width: 48px;
  text-align: center;
  color: var(--mm-purple);
  font-variant-numeric: tabular-nums;
}

/* Context Popover Menu (새로운 중심 마디 | 확대/축소하여 맞추기 | 모두 선택) */
.mm-context-menu {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  border: 1px solid #E2E8F0;
  display: inline-flex;
  overflow: hidden;
  z-index: 15;
}

.mm-context-menu[hidden] {
  display: none !important;
}

.mm-context-btn {
  background: transparent;
  border: 0;
  border-right: 1px solid #E2E8F0;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1E293B;
  cursor: pointer;
}

.mm-context-btn:last-child {
  border-right: 0;
}

.mm-context-btn:hover {
  background: var(--mm-purple-soft);
  color: var(--mm-purple);
}

/* Docked Quick Action Pill Bar (never overlaps canvas nodes) */
.mm-floating-pill {
  position: static;
  transform: none;
  background: #FFFFFF;
  border-top: 1px solid var(--mm-border);
  padding: 5px 10px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  flex-shrink: 0;
  z-index: 12;
  width: 100%;
}

.mm-floating-pill[hidden],
.mm-inline-editor[hidden] {
  display: none !important;
}

.mm-pill-badge {
  border: 1.5px solid #475569;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}

.mm-pill-divider {
  width: 1px;
  height: 18px;
  background: #CBD5E1;
}

.mm-pill-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mm-purple);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mm-pill-btn:hover {
  background: var(--mm-purple-soft);
}

.mm-pill-btn.is-active {
  background: var(--mm-purple);
  color: #FFFFFF;
}

/* Inline Quick Editor Bar */
.mm-inline-editor {
  background: #FFFFFF;
  border-top: 1px solid var(--mm-border);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mm-inline-editor label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mm-navy);
}

.mm-node-input {
  flex: 1;
  min-width: 180px;
  border: 1.5px solid var(--mm-purple);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  color: var(--mm-text);
}

/* Inspector Swatches & Controls */
.mm-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.mm-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px #CBD5E1;
  cursor: pointer;
}

.mm-color-swatch.is-active {
  box-shadow: 0 0 0 2.5px var(--mm-purple);
}

.mm-inspector-group {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #F1F5F9;
}

.mm-inspector-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.mm-action-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mm-textarea {
  width: 100%;
  min-height: 92px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-family: inherit;
  margin-bottom: 6px;
}

/* Info Cards & FAQ below Workspace */
.section-title {
  margin: 28px 0 12px;
  font-size: 19px;
  color: var(--mm-navy);
  border-left: 4px solid var(--mm-purple);
  padding-left: 10px;
}

.info-card {
  background: #FFFFFF;
  border: 1px solid var(--mm-border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.info-card ul, .info-card ol {
  margin: 8px 0;
  padding-left: 20px;
}

.info-card li {
  margin-bottom: 6px;
}

.faq-list details {
  background: #FFFFFF;
  border: 1px solid var(--mm-border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 10px;
}

.faq-list summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--mm-navy);
}

.faq-list p {
  margin: 8px 0 0;
  color: #334155;
  font-size: 14px;
}

.ad-slot-host {
  margin: 18px auto;
  text-align: center;
  min-height: 10px;
}

/* Owner (formin97@gmail.com) 141st Predicted Exam Bar */
.mm-owner-141-bar {
  background: linear-gradient(90deg, #EEF2FF 0%, #F5F3FF 100%);
  border-bottom: 1.5px solid #C7D2FE;
  padding: 5px 10px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.mm-owner-141-bar[hidden] {
  display: none !important;
}

.mm-owner-141-left,
.mm-owner-141-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.mm-owner-badge {
  background: var(--mm-purple);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mm-141-question-select {
  min-width: 170px;
  max-width: 300px;
}

/* Google Drive Sync & Folder Management Modal */
.mm-drive-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.mm-drive-modal-backdrop[hidden] {
  display: none !important;
}

.mm-drive-modal {
  background: #FFFFFF;
  border-radius: 16px;
  border: 1px solid #CBD5E1;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.24);
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 20px;
}

.mm-drive-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #E2E8F0;
}

.mm-drive-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--mm-navy);
}

.mm-drive-status-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: #334155;
}

.mm-drive-status-box.is-connected {
  background: #EEF2FF;
  border-color: #C7D2FE;
}

.mm-drive-folder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.mm-drive-folder-prefix {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
  background: #F1F5F9;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
}

.mm-drive-folder-input {
  flex: 1;
  min-width: 160px;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mm-text);
}

.mm-drive-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.mm-drive-file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  max-height: 220px;
  overflow-y: auto;
  background: #F8FAFC;
}

.mm-drive-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #E2E8F0;
  font-size: 12.5px;
}

.mm-drive-file-item:last-child {
  border-bottom: 0;
}

.mm-drive-file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.mm-drive-file-name {
  font-weight: 700;
  color: #1E293B;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mm-drive-file-sub {
  font-size: 11px;
  color: #64748B;
}

.mm-drive-file-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .site-header {
    padding: 10px 12px 8px;
  }
  .site-header h1 {
    font-size: 16px;
    margin-bottom: 4px;
  }
  .site-header .subtitle {
    display: none;
  }
  .mm-topbar,
  .mm-owner-141-bar,
  .mm-status-strip {
    padding: 4px 8px;
    gap: 4px;
  }
  .mm-icon-btn {
    padding: 4px 7px;
    font-size: 11px;
  }
  .mm-select {
    padding: 4px 6px;
    font-size: 11px;
  }
  #mm-stat-branches,
  #mm-stat-depth,
  #mm-stat-tasks {
    display: none;
  }
  .mm-side-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    max-height: none;
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.18);
  }
  .mm-inspector {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(300px, 86vw);
    max-height: none;
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.18);
  }
  .mm-svg-canvas {
    height: clamp(500px, 72vh, 720px);
  }
}

/* Android WebView App Mode (data-clarity-mask="true" or is-in-app) — Maximize Canvas Space */
html:has(body[data-clarity-mask="true"]),
html:has(body.is-in-app) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body[data-clarity-mask="true"],
body.is-in-app {
  height: 100dvh;
  max-height: 100dvh;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body[data-clarity-mask="true"] .site-header,
body[data-clarity-mask="true"] .section-title,
body[data-clarity-mask="true"] .info-card,
body[data-clarity-mask="true"] .faq-list,
body[data-clarity-mask="true"] #mm-ad-slot,
body[data-clarity-mask="true"] #mm-lang-select,
body.is-in-app .site-header,
body.is-in-app .section-title,
body.is-in-app .info-card,
body.is-in-app .faq-list,
body.is-in-app #mm-ad-slot,
body.is-in-app #mm-lang-select {
  display: none !important;
}

body[data-clarity-mask="true"] .container,
body.is-in-app .container {
  max-width: 100%;
  width: 100%;
  flex: 1;
  height: 100%;
  min-height: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-clarity-mask="true"] .mm-shell,
body.is-in-app .mm-shell {
  flex: 1;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-clarity-mask="true"] .mm-workspace-body,
body.is-in-app .mm-workspace-body {
  flex: 1;
  height: 100%;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

body[data-clarity-mask="true"] .mm-canvas-wrap,
body.is-in-app .mm-canvas-wrap {
  flex: 1;
  height: 100%;
  min-height: 0;
  display: flex;
}

body[data-clarity-mask="true"] .mm-svg-canvas,
body.is-in-app .mm-svg-canvas {
  width: 100%;
  height: 100% !important;
  min-height: 0 !important;
}

body[data-clarity-mask="true"] #mm-stat-branches,
body[data-clarity-mask="true"] #mm-stat-depth,
body[data-clarity-mask="true"] #mm-stat-tasks,
body.is-in-app #mm-stat-branches,
body.is-in-app #mm-stat-depth,
body.is-in-app #mm-stat-tasks {
  display: none !important;
}
