/* ================================================================
   Dashboard — rlwrld Internal Sharing Platform
   Theme: Bright
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Theme: Bright ───────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --surface: #f8f9fa;
  --surface2: #f0f1f3;
  --border: #e2e4e8;
  --text: #1a1a1a;
  --text2: #6b7280;
  --accent: #2563eb;
  --accent-bg: rgba(37,99,235,0.08);
  --accent-rgb: 37,99,235;
  --tag-blue: #3b82f6;
  --tag-blue-bg: rgba(59,130,246,0.10);
  --tag-red: #ef4444;
  --tag-red-bg: rgba(239,68,68,0.10);
  --tag-yellow: #d97706;
  --tag-yellow-bg: rgba(234,179,8,0.10);
}

/* ── Reset ────────────────────────────────────────────────────── */

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

/* ── Typography ───────────────────────────────────────────────── */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Container ────────────────────────────────────────────────── */

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 48px 60px;
}

/* ── Section spacing ──────────────────────────────────────────── */

.section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

/* ================================================================
   Auth Gate — Full screen overlay
   ================================================================ */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 32px;
}

.auth-gate.hidden {
  display: none;
}

.auth-logo {
  width: 120px;
  height: auto;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text2);
  text-align: center;
  margin-top: -16px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.auth-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.12);
}

.auth-btn svg {
  width: 20px;
  height: 20px;
}

.auth-domain {
  font-size: 12px;
  color: var(--text2);
  margin-top: -16px;
}

/* ================================================================
   AppBar — Header
   ================================================================ */

.appbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 48px;
}

.appbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
}

.appbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.appbar-logo img {
  height: 28px;
  width: auto;
}

.appbar-logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.appbar-spacer {
  flex: 1;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  position: relative;
}

.user-menu {
  position: absolute;
  top: 40px;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  display: none;
  z-index: 300;
}

.user-menu.show {
  display: block;
}

.user-menu-item {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.user-menu-item:hover {
  background: var(--surface);
}

.user-menu-name {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ================================================================
   Filter Bar
   ================================================================ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.filter-tab {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
}

.filter-tab:hover {
  color: var(--text);
}

.filter-tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-weight: 600;
}

.filter-category-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.filter-category-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-category-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-category-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.15s;
}

.filter-category-btn.active svg {
  transform: rotate(180deg);
}

.filter-spacer {
  flex: 1;
}

.filter-search {
  position: relative;
}

.filter-search input {
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  width: 240px;
  transition: all 0.15s;
}

.filter-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.filter-search input::placeholder {
  color: var(--text2);
}

.filter-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text2);
}

/* ── Category Dropdown ───────────────────────────────────────── */

.category-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  z-index: 300;
  display: none;
}

.category-dropdown.show {
  display: block;
}

.category-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 10px;
  background: var(--surface);
  color: var(--text);
}

.category-search:focus {
  outline: none;
  border-color: var(--accent);
}

.category-search::placeholder {
  color: var(--text2);
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.category-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text2);
}

.category-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.category-chip.selected {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* ================================================================
   Page Cards — Grid
   ================================================================ */

.page-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.page-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.page-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border-color: rgba(var(--accent-rgb), 0.3);
}

/* ── Preview Area ────────────────────────────────────────────── */

.page-card-preview {
  height: 180px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.page-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
}

.page-card-preview-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
}

.page-card-preview-placeholder svg {
  width: 32px;
  height: 32px;
  color: var(--border);
}

/* ── Lock Overlay ────────────────────────────────────────────── */

.page-card-lock {
  position: absolute;
  inset: 0;
  bottom: auto;
  height: 180px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.page-card-lock svg {
  width: 36px;
  height: 36px;
  color: rgba(255,255,255,0.7);
}

.page-card-request-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  padding: 5px 10px;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
}

.page-card-request-btn:hover {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ── Card Info ────────────────────────────────────────────────── */

.page-card-info {
  padding: 14px 16px;
}

.page-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-card-date {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
}

/* ── Tags ────────────────────────────────────────────────────── */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.tag-accent {
  background: var(--accent-bg);
  color: var(--accent);
}

.tag-blue {
  background: var(--tag-blue-bg);
  color: var(--tag-blue);
}

.tag-red {
  background: var(--tag-red-bg);
  color: var(--tag-red);
}

.tag-yellow {
  background: var(--tag-yellow-bg);
  color: var(--tag-yellow);
}

.tag-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Permission badge on card ────────────────────────────────── */

.page-card-permission {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.permission-editor {
  background: rgba(var(--accent-rgb), 0.9);
  color: #ffffff;
}

.permission-viewer {
  background: rgba(255,255,255,0.85);
  color: var(--text2);
  border: 1px solid var(--border);
}

/* ================================================================
   Create Page — Form
   ================================================================ */

.form-container {
  max-width: 680px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.form-label-sub {
  font-weight: 400;
  color: var(--text2);
  margin-left: 4px;
}

.form-required {
  color: var(--tag-red);
  font-weight: 400;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: all 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

/* ── Tag Input ───────────────────────────────────────────────── */

.tag-input-container {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  transition: all 0.15s;
  cursor: text;
}

.tag-input-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.tag-input-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-input-tag-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.6;
}

.tag-input-tag-remove:hover {
  opacity: 1;
}

.tag-input-field {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  flex: 1;
  min-width: 100px;
  background: transparent;
  color: var(--text);
}

.tag-input-field::placeholder {
  color: var(--text2);
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 100;
  display: none;
  max-height: 160px;
  overflow-y: auto;
}

.tag-suggestions.show {
  display: block;
}

.tag-suggestion-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.tag-suggestion-item:hover {
  background: var(--surface);
}

/* ── Permission Input ────────────────────────────────────────── */

.permission-input-container {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.permission-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.permission-row:last-child {
  border-bottom: none;
}

.permission-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.permission-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
}

.permission-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.permission-user-email {
  font-size: 11px;
  color: var(--text2);
}

.permission-role-select {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.permission-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: text;
}

.permission-add-input {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  flex: 1;
  background: transparent;
  color: var(--text);
}

.permission-add-input::placeholder {
  color: var(--text2);
}

/* ================================================================
   View Page
   ================================================================ */

.view-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.view-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.view-iframe-container {
  width: 100%;
  height: calc(100vh - 180px);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.view-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Comment Sidebar ─────────────────────────────────────────── */

.comment-sidebar {
  position: fixed;
  top: 56px;
  right: 0;
  width: 320px;
  height: calc(100vh - 56px);
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.comment-sidebar.open {
  transform: translateX(0);
}

.comment-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.comment-sidebar-title {
  font-size: 15px;
  font-weight: 600;
}

.comment-sidebar-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text2);
  padding: 4px;
}

.comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.comment-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
  font-size: 13px;
}

.comment-item {
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 10px;
}

.comment-item-quote {
  font-size: 12px;
  color: var(--accent);
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  margin-bottom: 8px;
  font-style: italic;
}

.comment-item-text {
  font-size: 13px;
  color: var(--text);
}

.comment-item-meta {
  font-size: 11px;
  color: var(--text2);
  margin-top: 6px;
}

.comment-add {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.comment-add textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  height: 80px;
  background: var(--surface);
  color: var(--text);
}

.comment-add textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.comment-add button {
  margin-top: 8px;
  width: 100%;
}

/* ================================================================
   Toast / Notification
   ================================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 500;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ================================================================
   Create Panel — Sliding Overlay
   ================================================================ */

.create-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.create-overlay.open {
  opacity: 1;
  visibility: visible;
}

.create-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 90%;
  max-width: 800px;
  height: 100vh;
  background: var(--bg);
  z-index: 450;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
}

.create-panel.open {
  transform: translateX(0);
}

.create-panel-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.create-panel-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text2);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
}

.create-panel-close:hover {
  background: var(--surface);
  color: var(--text);
}

.create-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.create-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.create-panel-body .form-container {
  max-width: 100%;
}

/* ── File Dropzone ─────────────────────────────────────────────── */

.file-dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text2);
  font-size: 13px;
}

.file-dropzone:hover,
.file-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.file-dropzone svg {
  color: var(--text2);
}

.file-dropzone:hover svg,
.file-dropzone.dragover svg {
  color: var(--accent);
}

.file-dropzone-sub {
  font-size: 11px;
  color: var(--text2);
  opacity: 0.7;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
}

.file-chip-remove {
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  line-height: 1;
}

.file-chip-remove:hover {
  color: var(--tag-red);
}

.file-chip-size {
  color: var(--text2);
  font-size: 10px;
}

/* ── Theme Selector ────────────────────────────────────────────── */

.theme-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.theme-card-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.6;
}

.theme-card-option:hover {
  opacity: 0.85;
  border-color: rgba(var(--accent-rgb), 0.4);
}

.theme-card-option.selected {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.theme-card-preview {
  height: 80px;
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
}

.theme-card-info {
  padding: 8px 12px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.theme-card-radio {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-card-option.selected .theme-card-radio {
  border-color: var(--accent);
}

.theme-card-option.selected .theme-card-radio::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.theme-card-swatches {
  display: flex;
  gap: 4px;
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ── Radio Groups ──────────────────────────────────────────────── */

.radio-group {
  display: flex;
  gap: 16px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--accent);
}

/* ── Submit Button ─────────────────────────────────────────────── */

.create-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 14px 24px;
  font-size: 15px;
  margin-top: 8px;
  margin-bottom: 32px;
}

/* ================================================================
   Editor View — Chat + Preview Split
   ================================================================ */

.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.editor-overlay.open {
  opacity: 1;
  visibility: visible;
}

.editor-panel {
  position: fixed;
  inset: 0;
  z-index: 550;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.35s ease;
  display: flex;
  flex-direction: column;
}

.editor-panel.open {
  transform: translateX(0);
}

/* ── Editor Header ─────────────────────────────────────────────── */

.editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.editor-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.editor-close:hover {
  border-color: var(--tag-red);
  color: var(--tag-red);
}

.editor-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.editor-spacer {
  flex: 1;
}

/* ── Editor Split ──────────────────────────────────────────────── */

.editor-split {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Chat Side ─────────────────────────────────────────────────── */

.editor-chat {
  width: 400px;
  min-width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.editor-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.editor-msg.user {
  flex-direction: row-reverse;
}

.editor-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.editor-msg.user .editor-msg-avatar {
  background: var(--surface2);
  color: var(--text2);
}

.editor-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.editor-msg.bot .editor-msg-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
}

.editor-msg.user .editor-msg-bubble {
  background: var(--accent);
  color: #ffffff;
  border-radius: 12px 4px 12px 12px;
}

/* ── Chat Input ────────────────────────────────────────────────── */

.editor-chat-input {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg);
}

.editor-chat-input textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
}

.editor-chat-input textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.editor-chat-input textarea::placeholder {
  color: var(--text2);
}

.editor-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.editor-send-btn:hover {
  opacity: 0.85;
}

/* ── Preview Side ──────────────────────────────────────────────── */

.editor-preview {
  flex: 1;
  background: var(--surface2);
  position: relative;
}

.editor-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Loading State ─────────────────────────────────────────────── */

.editor-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text2);
}

.editor-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: editor-spin 0.8s linear infinite;
}

@keyframes editor-spin {
  to { transform: rotate(360deg); }
}

.editor-loading-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.editor-loading-sub {
  font-size: 13px;
  color: var(--text2);
}

/* ================================================================
   Deploy Success Popup
   ================================================================ */

.deploy-popup {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.deploy-popup-inner {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
  position: relative;
}

.deploy-popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text2);
  padding: 4px;
}

.deploy-popup-icon {
  text-align: center;
  margin-bottom: 16px;
}

.deploy-popup-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.deploy-popup-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}

.deploy-popup-url-row {
  display: flex;
  gap: 8px;
}

.deploy-popup-url {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 1024px) {
  .container {
    padding: 20px 24px 48px;
  }

  .appbar {
    padding: 0 24px;
  }

  .page-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-search input {
    width: 180px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 16px 16px 40px;
  }

  .appbar {
    padding: 0 16px;
  }

  .appbar-logo-text {
    display: none;
  }

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

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

  .filter-tabs {
    align-self: flex-start;
  }

  .filter-spacer {
    display: none;
  }

  .filter-search input {
    width: 100%;
  }

  .comment-sidebar {
    width: 100%;
  }

  .page-card-preview {
    height: 140px;
  }

  .page-card-lock {
    height: 140px;
  }

  .create-panel {
    width: 100%;
  }

  .create-panel-body {
    padding: 20px 16px;
  }

  .theme-selector {
    grid-template-columns: repeat(2, 1fr);
  }

  .editor-split {
    flex-direction: column;
  }

  .editor-chat {
    width: 100%;
    min-width: 0;
    height: 50%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .editor-preview {
    height: 50%;
  }
}
