:root {
  --international-orange: #FF4400;
  --radius: 0.75rem;
  --bg: #F2F0E9;
  --surface: #FDFDFB;
  --surface-hover: #E8E6DD;
  --border: #E5E2D9;
  --border-strong: #D5D2C9;
  --text: #1A1A1A;
  --text-secondary: #4A4A4A;
  --text-muted: #8A8A8A;
  --green-bg: #ecfdf5;
  --green: #047857;
  --green-border: #a7f3d0;
  --amber-bg: #fffbeb;
  --amber: #b45309;
  --amber-border: #fde68a;
  --red-bg: #fef2f2;
  --red: #b91c1c;
  --red-border: #fecaca;
  --blue-bg: #eff6ff;
  --blue: #1d4ed8;
  --blue-border: #bfdbfe;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}
h1, h2, h3 { font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }

/* ===== Login ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { font-size: 24px; font-weight: 800; color: var(--international-orange); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.login-field { margin-bottom: 20px; }
.login-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.login-field input {
  width: 100%;
  padding: 12px 14px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.login-field input:focus { border-color: var(--international-orange); box-shadow: 0 0 0 3px rgba(255,68,0,0.08); }
.login-error { color: var(--red); font-size: 13px; font-weight: 600; margin-bottom: 12px; min-height: 20px; }
.login-btn {
  width: 100%;
  padding: 12px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: var(--international-orange);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.login-btn:hover { background: #e63d00; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== App Shell ===== */
#app { display: flex; flex-direction: column; height: 100vh; }

/* ===== Top Bar ===== */
#topbar {
  height: 52px;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.logo { color: var(--international-orange); font-weight: 800; font-size: 15px; letter-spacing: 0.3px; cursor: pointer; }
.topbar-center { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.breadcrumb { color: #8899aa; font-size: 13px; cursor: pointer; font-weight: 600; }
.breadcrumb:hover { color: #a0c4ff; }
.breadcrumb-sep { color: #3a3a5a; font-size: 13px; }
.breadcrumb-current { color: #ccc; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unsaved-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff9800; display: none; flex-shrink: 0; }
.unsaved-dot.show { display: inline-block; }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-name { color: #8899aa; font-size: 13px; font-weight: 600; }
.topbar-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout { background: transparent; color: #8899aa; border: 1px solid #3a3a5a; }
.btn-logout:hover { background: #2a2a4a; color: #ccc; }
.btn-settings { background: #2d3a4a; color: #a0c4ff; }
.btn-settings:hover { background: #3a4a5a; }
.btn-preview { background: #2d3a4a; color: #a0c4ff; }
.btn-preview:hover { background: #3a4a5a; }
.btn-history { background: #2d3a4a; color: #a0c4ff; }
.btn-history:hover { background: #3a4a5a; }
.btn-publish { background: #047857; color: #fff; }
.btn-publish:hover { background: #065f46; }

/* ===== Browse View ===== */
#browse-view { flex: 1; overflow-y: auto; padding: 32px 48px; }
.browse-container { max-width: 1400px; margin: 0 auto; }
header { margin-bottom: 28px; }
header h1 { font-size: 28px; margin-bottom: 4px; }
header p { color: var(--text-muted); font-size: 14px; font-weight: 500; }

.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.search-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search-input-wrap { flex: 1; min-width: 300px; position: relative; }
.search-input-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrap input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.search-input-wrap input:focus { border-color: var(--international-orange); box-shadow: 0 0 0 3px rgba(255,68,0,0.08); }
.search-input-wrap input::placeholder { color: var(--text-muted); }
.filter-select {
  padding: 10px 14px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
  min-width: 140px;
}
.filter-select:focus { border-color: var(--international-orange); box-shadow: 0 0 0 3px rgba(255,68,0,0.08); }
.btn-clear {
  padding: 10px 18px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-clear:hover { background: var(--surface-hover); }

.results-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 0 4px; }
.results-count { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.results-count strong { color: var(--international-orange); font-weight: 800; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--surface-hover); position: sticky; top: 0; z-index: 1; }
th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: var(--surface-hover); }
.course-title-cell { font-weight: 600; color: var(--text); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-91 { background: var(--blue-bg); color: var(--blue); }
.badge-135 { background: var(--amber-bg); color: var(--amber); }
.btn-edit {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--international-orange);
  border-radius: 6px;
  background: transparent;
  color: var(--international-orange);
  cursor: pointer;
}
.btn-edit:hover { background: var(--international-orange); color: #fff; }

.pagination { display: flex; gap: 4px; }
.page-btn {
  padding: 6px 12px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.page-btn:hover { background: var(--surface-hover); }
.page-btn.active { background: var(--international-orange); color: #fff; border-color: var(--international-orange); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Editor View ===== */
#editor-view { flex: 1; overflow: hidden; }
#editor-layout { display: flex; height: 100%; }

/* Editor Sidebar */
#editor-sidebar {
  width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
#sidebar-header h3 { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
#sidebar-tree { flex: 1; overflow-y: auto; padding: 8px 0; }
.tree-section { margin-bottom: 4px; }
.tree-section-header {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tree-section-header:hover { background: var(--surface-hover); }
.tree-section-header .arrow { font-size: 10px; transition: transform 0.2s; }
.tree-section-header .arrow.collapsed { transform: rotate(-90deg); }
.tree-item {
  padding: 7px 16px 7px 32px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.tree-item:hover { background: #f0f4ff; }
.tree-item.active { background: #e3f2fd; border-left-color: var(--international-orange); font-weight: 600; }
.tree-item .type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}
.type-html .type-badge { background: var(--blue-bg); color: var(--blue); }
.type-selftest .type-badge { background: var(--amber-bg); color: var(--amber); }
.type-quiz .type-badge { background: var(--red-bg); color: var(--red); }
.tree-item .page-num { color: var(--text-muted); font-size: 11px; min-width: 18px; flex-shrink: 0; }
.tree-item .page-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Editor Panel */
#editor-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#editor-toolbar {
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
#editor-toolbar .page-label { font-size: 14px; font-weight: 600; color: var(--text); }
#editor-toolbar .page-type {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--text-muted);
  font-weight: 600;
}
#editor-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.editor-empty-state { text-align: center; padding: 60px; color: var(--text-muted); }

/* HTML Editor */
.html-editor { max-width: 900px; margin: 0 auto; }
.editor-field { margin-bottom: 20px; }
.editor-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.editor-field input[type="text"],
.editor-field input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.editor-field input:focus { border-color: var(--international-orange); }

/* Rich Text Toolbar */
.rte-toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  flex-wrap: wrap;
}
.rte-btn {
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'Manrope', system-ui, sans-serif;
}
.rte-btn:hover { background: var(--border); }
.rte-divider { width: 1px; background: var(--border-strong); margin: 4px; }
.rte-content {
  border: 1px solid var(--border-strong);
  border-radius: 0 0 8px 8px;
  padding: 20px 24px;
  min-height: 300px;
  background: var(--surface);
  outline: none;
  line-height: 1.6;
  font-size: 14px;
  overflow: hidden;
}
.rte-content:focus { border-color: var(--international-orange); }

/* Content rendering in editor */
.rte-content img { max-width: 100%; height: auto !important; display: block; border-radius: 4px; }
.rte-content .image-medium { max-width: 350px; }
.rte-content .image-small { max-width: 200px; }
.rte-content .image-large { max-width: 700px; }
.rte-content .aligncenter, .rte-content [style*="margin-left: auto"][style*="margin-right: auto"] { margin-left: auto !important; margin-right: auto !important; }
.rte-content table { border-collapse: collapse; width: 100% !important; max-width: 100% !important; table-layout: fixed; }
.rte-content table[style*="width:"] { width: 100% !important; }
.rte-content .ae_noborder, .rte-content .ae_noborder td { border: none !important; }
.rte-content .cell-padding td { padding: 12px 16px; vertical-align: top; }
.rte-content td { overflow: hidden; word-wrap: break-word; }
.rte-content ul, .rte-content ol { margin: 12px 0; padding-left: 24px; }
.rte-content li { margin-bottom: 6px; line-height: 1.6; }
.rte-content p { margin-bottom: 12px; }
.rte-content iframe { max-width: 100% !important; height: auto; aspect-ratio: 16/9; border: none; border-radius: 4px; display: block; }
.rte-content .fr-video { display: block; max-width: 100%; overflow: hidden; }
.rte-content video { max-width: 100%; height: auto; border-radius: 4px; }
.rte-content td[bgcolor="#330066"] { border-radius: 4px; padding: 12px 16px !important; }
.rte-content td[bgcolor="#330066"] span { color: #fff !important; }

/* Selftest Editor */
.selftest-editor { max-width: 900px; margin: 0 auto; }
.question-editor { background: var(--surface); border-radius: 8px; padding: 24px; border: 1px solid var(--border); }
.answer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.answer-row.correct-answer { background: var(--green-bg); border-color: var(--green-border); }
.answer-row input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}
.answer-row .hint-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
}
.answer-row .correct-toggle {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
}
.answer-row .correct-toggle.is-correct { background: var(--green); color: #fff; border-color: var(--green); }
.answer-row .remove-btn {
  padding: 6px 10px;
  border: none;
  background: var(--red-bg);
  color: var(--red);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.answer-row .remove-btn:hover { background: var(--red-border); }
.add-answer-btn {
  padding: 8px 16px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  margin-top: 8px;
  width: 100%;
}
.add-answer-btn:hover { background: var(--surface-hover); border-color: var(--text-muted); }

/* Quiz Editor */
.quiz-editor { max-width: 900px; margin: 0 auto; }
.quiz-settings {
  background: var(--surface);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.quiz-settings .setting { display: flex; align-items: center; gap: 8px; }
.quiz-settings label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.quiz-settings input[type="number"] {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
}
.quiz-question-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.quiz-question-card .q-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
}

/* Question Bank Pool (read-only) */
.pool-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--amber-bg);
  color: var(--amber);
  font-weight: 600;
  margin-left: 8px;
}
.pool-notice {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: 6px;
  line-height: 1.5;
}
.pool-question {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--surface);
}
.pool-q-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.pool-q-text {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.5;
}
.pool-answers { display: flex; flex-direction: column; gap: 4px; }
.pool-answer {
  font-size: 12px;
  padding: 4px 10px;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: 4px;
}
.pool-answer.pool-correct { color: var(--green); font-weight: 600; background: var(--green-bg); }

/* Sidebar page count */
.sidebar-page-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 16px 12px;
}

/* Settings Panel */
#settings-panel {
  position: fixed;
  top: 52px;
  right: 0;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  height: calc(100vh - 52px);
  z-index: 50;
  padding: 24px;
  overflow-y: auto;
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.settings-header h3 { font-size: 18px; color: var(--text); }
.settings-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-close:hover { background: var(--surface-hover); color: var(--text); }
.setting-group { margin-bottom: 20px; }
.setting-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.setting-group input[type="text"],
.setting-group input[type="number"],
.setting-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.setting-group input:focus, .setting-group textarea:focus { border-color: var(--international-orange); }
.version-details { font-size: 13px; color: var(--text-secondary); line-height: 1.8; }
.version-details strong { font-weight: 700; }

/* Toggle Switch */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-strong);
  border-radius: 24px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* History Button */
.btn-history { background: #2d3a4a; color: #a0c4ff; }
.btn-history:hover { background: #3a4a5a; }

/* History Panel */
#history-panel {
  position: fixed;
  top: 52px;
  right: 0;
  width: 420px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  height: calc(100vh - 52px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.history-header h3 { font-size: 18px; color: var(--text); }
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}
.history-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.history-current {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--green-bg);
}
.history-current .history-version-badge {
  background: var(--green);
  color: #fff;
}
.history-item {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.history-item:hover {
  background: var(--surface-hover);
}
.history-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.history-version-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-hover);
  color: var(--text-secondary);
}
.history-editor {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.history-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}
.history-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-style: italic;
}
.history-actions {
  display: flex;
  gap: 8px;
}
.history-btn-view {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif;
}
.history-btn-view:hover { background: var(--blue-bg); }
.history-btn-restore {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--international-orange);
  border-radius: 6px;
  background: transparent;
  color: var(--international-orange);
  cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif;
}
.history-btn-restore:hover { background: var(--international-orange); color: #fff; }

/* History Panel */
#history-panel {
  position: fixed;
  top: 52px;
  right: 0;
  width: 420px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  height: calc(100vh - 52px);
  z-index: 50;
  padding: 0;
  overflow-y: auto;
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.history-header h3 { font-size: 18px; color: var(--text); }
.history-list { padding: 12px; }
.history-loading { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.history-current {
  padding: 14px 16px;
  border: 2px solid var(--international-orange);
  border-radius: 8px;
  margin-bottom: 12px;
  background: rgba(255,68,0,0.03);
}
.history-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface);
  transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--border-strong); }
.history-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.history-version-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--blue-bg);
  color: var(--blue);
}
.history-current .history-version-badge {
  background: var(--international-orange);
  color: #fff;
}
.history-editor {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.history-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}
.history-version {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.history-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.5;
}
.history-summary {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 8px;
}
.history-actions { display: flex; gap: 8px; }
.history-actions button,
.history-btn-view,
.history-btn-restore {
  padding: 5px 12px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
}
.history-actions button:hover,
.history-btn-view:hover { background: var(--surface-hover); }
.history-actions .btn-restore,
.history-btn-restore {
  border-color: var(--international-orange);
  color: var(--international-orange);
}
.history-actions .btn-restore:hover,
.history-btn-restore:hover {
  background: var(--international-orange);
  color: #fff;
}
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Preview Modal */
#preview-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.preview-toolbar {
  height: 48px;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  color: #ccc;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.preview-close-btn {
  padding: 7px 16px;
  background: #f44336;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.preview-close-btn:hover { background: #d32f2f; }
#preview-frame { flex: 1; border: none; background: #fff; margin: 16px; border-radius: 8px; }

/* Publish Modal */
#publish-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
}
.publish-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.publish-card h3 { font-size: 20px; margin-bottom: 8px; }
.publish-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
.publish-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.publish-actions .login-btn { width: auto; padding: 10px 24px; }
.publish-actions .btn-clear { padding: 10px 24px; }
.publish-status { margin-top: 16px; font-size: 13px; font-weight: 600; min-height: 20px; }
.publish-status.success { color: var(--green); }
.publish-status.error { color: var(--red); }

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255,255,255,0.8);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--international-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
