:root,
[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #151926;
  --muted: #5a647d;
  --border: #dfe4f0;
  --primary: #4f61df;
  --primary-hover: #3e4fc8;
  --primary-soft: rgba(79, 97, 223, 0.12);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(21, 25, 38, 0.06);
  --sidebar-bg: #ffffff;
}

[data-theme="word"] {
  --bg: #f0f4fa;
  --surface: #ffffff;
  --surface-2: #e3ecf8;
  --text: #11223a;
  --muted: #4b5d78;
  --border: #cddbf0;
  --primary: #185abd;
  --primary-hover: #104596;
  --primary-soft: rgba(24, 90, 189, 0.12);
  --success: #107c41;
  --warning: #ca5010;
  --danger: #c50f1f;
  --shadow: 0 10px 30px rgba(24, 90, 189, 0.08);
  --sidebar-bg: #185abd;
  --sidebar-text: #ffffff;
  --sidebar-muted: rgba(255, 255, 255, 0.78);
}

[data-theme="dark"] {
  --bg: #0f131c;
  --surface: #171d2b;
  --surface-2: #20283b;
  --text: #eef2ff;
  --muted: #9aa5c4;
  --border: #2a334a;
  --primary: #6c82ff;
  --primary-hover: #8396ff;
  --primary-soft: rgba(108, 130, 255, 0.16);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --sidebar-bg: #131824;
}

[data-theme="space"] {
  --bg: #060914;
  --surface: rgba(15, 22, 44, 0.84);
  --surface-2: rgba(27, 38, 72, 0.85);
  --text: #f0f4ff;
  --muted: #9eb0db;
  --border: rgba(114, 137, 218, 0.25);
  --primary: #7c8cff;
  --primary-hover: #96a4ff;
  --primary-soft: rgba(124, 140, 255, 0.18);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  --sidebar-bg: rgba(10, 15, 32, 0.9);
}

[data-theme="winter"] {
  --bg: linear-gradient(180deg, #061021 0%, #0b1d38 55%, #102a4c 100%);
  --surface: rgba(13, 28, 54, 0.84);
  --surface-2: rgba(22, 46, 84, 0.82);
  --text: #eef6ff;
  --muted: #9ec0e6;
  --border: rgba(125, 195, 255, 0.24);
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-soft: rgba(56, 189, 248, 0.18);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 14px 36px rgba(0, 8, 24, 0.55);
  --sidebar-bg: rgba(8, 19, 38, 0.9);
}

@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-msg-new {
  animation: msgSlideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

[data-theme="paper"] {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #efe7d8;
  --text: #2c251d;
  --muted: #6c5f50;
  --border: #e1d6c3;
  --primary: #9b5122;
  --primary-hover: #7d3f18;
  --primary-soft: rgba(155, 81, 34, 0.12);
  --success: #2d7a47;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 8px 24px rgba(44, 37, 29, 0.06);
  --sidebar-bg: #fbf7ee;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

h1, h2, h3, h4 {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  margin: 0 0 0.5rem;
  line-height: 1.25;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 9999;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
}

.space-stars-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  backdrop-filter: blur(12px);
}

[data-theme="word"] .sidebar {
  color: #fff;
  border-right-color: rgba(255, 255, 255, 0.14);
}
[data-theme="word"] .brand,
[data-theme="word"] .brand-sub,
[data-theme="word"] .nav-item,
[data-theme="word"] .theme-panel-label {
  color: #fff;
}
[data-theme="word"] .nav-item:hover,
[data-theme="word"] .nav-item.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
[data-theme="word"] .brand-mark {
  background: #fff;
  color: #185abd;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-accent {
  color: var(--primary);
}
[data-theme="word"] .brand-accent {
  color: #cfe2ff;
}
.brand-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.mobile-close-btn,
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
}

.sidebar-search {
  position: relative;
  margin-bottom: 16px;
}
.sidebar-search input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.sidebar-search input:focus {
  border-color: var(--primary);
}
.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
}
.search-hit {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
.search-hit:hover {
  background: var(--primary-soft);
}
.search-hit small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: var(--surface-2);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-icon {
  width: 20px;
  text-align: center;
}

.theme-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
[data-theme="word"] .theme-panel {
  border-top-color: rgba(255, 255, 255, 0.2);
}
.theme-panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.theme-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.theme-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.theme-pill.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
[data-theme="word"] .theme-pill {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
[data-theme="word"] .theme-pill.active {
  background: #fff;
  color: #185abd;
}

/* Main content */
.content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(10px);
}
.topbar-crumb {
  font-weight: 600;
  font-size: 15px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
}

.main-content {
  padding: 28px 28px 60px;
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
}

/* Cards, Buttons, Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn:active {
  transform: translateY(1px);
}
.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
}
.badge-success {
  background: rgba(22, 163, 74, 0.14);
  color: var(--success);
}
.badge-warning {
  background: rgba(217, 119, 6, 0.15);
  color: var(--warning);
}
.badge-danger {
  background: rgba(220, 38, 38, 0.15);
  color: var(--danger);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary-soft), var(--surface));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  align-items: center;
}
.hero h1 {
  font-size: 30px;
  margin-bottom: 10px;
}
.hero p {
  color: var(--muted);
  margin: 0 0 18px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Screenshot showcase */
.screenshot-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #111;
  cursor: zoom-in;
  position: relative;
}
.screenshot-box img {
  width: 100%;
  display: block;
  object-fit: cover;
}
.screenshot-ribbon-crop img {
  max-height: 220px;
  object-fit: cover;
  object-position: top left;
}
.screenshot-caption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hotspot-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.hotspot-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.hotspot-item strong {
  display: block;
  color: var(--primary);
  margin-bottom: 2px;
}

/* Steps & Accordion */
.steps-list {
  margin: 10px 0 0;
  padding-left: 20px;
}
.steps-list li {
  margin-bottom: 6px;
}

.tip-box {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
}

.alert-banner {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--warning);
  background: rgba(217, 119, 6, 0.1);
  margin-bottom: 16px;
  font-size: 14px;
}

/* Online Word Editor */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  align-items: center;
}
.editor-toolbar select,
.editor-toolbar input[type="color"] {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.tb-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.tb-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.editor-page-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 24px;
  display: flex;
  justify-content: center;
}
.editor-paper {
  width: 100%;
  max-width: 794px;
  min-height: 680px;
  background: #ffffff;
  color: #111111;
  padding: 48px 56px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  border-radius: 4px;
  outline: none;
  font-family: 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.5;
}
.editor-paper table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}
.editor-paper td, .editor-paper th {
  border: 1px solid #333;
  padding: 6px 8px;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}
.lightbox-dialog {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  width: 100%;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.lightbox-dialog img {
  width: 100%;
  display: block;
  max-height: 82vh;
  object-fit: contain;
  background: #000;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -300px;
    z-index: 100;
    transition: left 0.2s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .mobile-menu-btn,
  .mobile-close-btn {
    display: inline-flex;
  }
  .hero {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 18px 16px 50px;
  }
  .editor-paper {
    padding: 24px 20px;
  }
}

@media print {
  .sidebar, .topbar, .editor-toolbar, .alert-banner, .no-print {
    display: none !important;
  }
  .editor-page-wrap {
    border: none;
    padding: 0;
    background: #fff;
  }
  .editor-paper {
    box-shadow: none;
    padding: 0;
  }
}
