#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.main-shell {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-shell > .section {
  flex: 1 1 auto;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px 2px;
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
}

.topbar.hidden {
  display: none;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(134, 194, 255, 0.26);
  background: linear-gradient(145deg, rgba(8, 24, 42, 0.84), rgba(9, 31, 50, 0.62));
  box-shadow:
    0 20px 38px rgba(3, 11, 20, 0.42),
    inset 0 0 0 1px rgba(173, 223, 255, 0.08);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  animation: topbarFloatBrand 7.2s ease-in-out infinite;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-soft);
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #1f73d4);
  color: #fff;
  box-shadow: 0 0 24px rgba(43, 182, 255, 0.45);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  justify-content: flex-end;
  padding: 8px 10px 8px 12px;
  border-radius: 16px;
  border: 1px solid rgba(134, 194, 255, 0.28);
  background: linear-gradient(145deg, rgba(8, 24, 42, 0.82), rgba(7, 26, 46, 0.6));
  box-shadow:
    0 18px 34px rgba(3, 11, 20, 0.38),
    inset 0 0 0 1px rgba(173, 223, 255, 0.07);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  animation: topbarFloatUser 8.4s ease-in-out infinite;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(150deg, var(--accent), #0f5bb0);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 14px rgba(25, 221, 156, 0.8);
}

@keyframes topbarFloatBrand {
  0% {
    transform: translateY(0px) translateX(0px);
  }
  50% {
    transform: translateY(-5px) translateX(2px);
  }
  100% {
    transform: translateY(0px) translateX(0px);
  }
}

@keyframes topbarFloatUser {
  0% {
    transform: translateY(0px) translateX(0px);
  }
  50% {
    transform: translateY(-4px) translateX(-2px);
  }
  100% {
    transform: translateY(0px) translateX(0px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar-brand,
  .topbar-user {
    animation: none;
  }
}

.section {
  display: none;
  height: 100%;
  min-height: 0;
  padding: 22px;
}

.section.active {
  display: flex;
  animation: sectionIn 180ms ease-out;
}

.section-scroll {
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

@keyframes sectionIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-card {
  width: min(460px, 92vw);
  margin: auto;
  padding: 32px;
}

.login-head {
  text-align: center;
  margin-bottom: 18px;
}

.login-head .brand-badge {
  margin: 0 auto 12px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 22px;
}

.login-head h1 {
  font-size: clamp(24px, 4vw, 30px);
}

.login-head p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
}

.section-header-block h2 {
  font-size: 28px;
}

.section-header-block p {
  margin-top: 4px;
  color: var(--text-muted);
}

#dashboardSection {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 42px;
  scroll-padding-bottom: 220px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#dashboardSection.active {
  display: block;
}

#dashboardSection::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 10%, rgba(70, 161, 232, 0.14), transparent 52%),
    radial-gradient(circle at 86% 0%, rgba(43, 182, 255, 0.1), transparent 44%);
}

#dashboardSection > * {
  position: relative;
  z-index: 1;
}

.dashboard-hero {
  margin-bottom: 14px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dashboard-hero-left h2 {
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.1;
  margin-bottom: 4px;
}

.dashboard-hero-left p {
  color: var(--text-muted);
}

.dashboard-overline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.dashboard-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.dashboard-panels {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-panel {
  padding: 16px;
}

.dashboard-panel-head h3 {
  margin: 0 0 4px;
}

.dashboard-panel-head p {
  margin: 0;
}

.dashboard-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.dashboard-stats.compact {
  margin-top: 10px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.dashboard-websites {
  margin-top: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid rgba(90, 151, 204, 0.26);
}

.dashboard-scroll-spacer {
  height: clamp(180px, 20vh, 280px);
  flex: 0 0 auto;
}

.dashboard-websites-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-website-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: min(680px, 100%);
}

.dashboard-website-form input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.7);
  padding: 8px 10px;
  min-width: 170px;
  flex: 1 1 180px;
  outline: none;
}

.dashboard-website-form input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(43, 182, 255, 0.12);
}

.dashboard-website-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.utility-section {
  flex-direction: column;
}

.utility-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.utility-form-card,
.utility-list-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-layout {
  flex: 1;
  min-height: 0;
}

.chat-card {
  height: 100%;
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 760px) {
  .api-chat-head {
    flex-direction: column;
    align-items: stretch;
  }

  .api-chat-status {
    width: fit-content;
  }

  .api-chat-messages .ai-bubble {
    max-width: 100%;
  }
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  gap: 14px;
}

.admin-head-card {
  margin-bottom: 14px;
  padding: 14px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.admin-status-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  width: min(560px, 100%);
}

.admin-status-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(9, 28, 43, 0.72);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-status-card span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-status-card strong {
  font-size: 15px;
}

.admin-card {
  border-color: rgba(115, 179, 232, 0.3);
  background:
    linear-gradient(145deg, rgba(38, 87, 128, 0.2), rgba(9, 25, 38, 0.74)),
    rgba(15, 34, 54, 0.7);
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.list-stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.project-list-tools {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-list-controls {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 160px 190px auto;
  gap: 8px;
  align-items: center;
}

#projectSearchInput {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(8, 21, 33, 0.74);
  color: var(--text-main);
  padding: 9px 12px;
  outline: none;
}

#projectTypeFilter,
#projectSortSelect {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 21, 33, 0.74);
  color: var(--text-main);
  padding: 9px 10px;
  outline: none;
}

#projectListMeta {
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
}

#projectDetailSection {
  display: none;
  overflow: hidden;
  padding: 0;
}

#projectDetailSection.active {
  display: grid;
  grid-template-columns: 250px 1fr 340px;
}

.panel-tree,
.panel-editor,
.panel-ai {
  min-height: 0;
}

.panel-tree {
  background: rgba(15, 34, 54, 0.7);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-soft);
  letter-spacing: 0.08em;
}

.tree-tools {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#treeSearchInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 21, 33, 0.72);
  color: var(--text-main);
  padding: 8px 10px;
  outline: none;
}

.tree-action-row {
  flex-wrap: wrap;
}

.tree-search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding-right: 2px;
}

.tree-root-drop-target {
  border: 1px dashed rgba(126, 198, 250, 0.34);
  border-radius: var(--radius-sm);
  min-height: 34px;
  padding: 7px 8px;
  font-size: 11px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(8, 21, 33, 0.42);
}

.tree-root-drop-target.active {
  border-style: solid;
  border-color: rgba(71, 194, 255, 0.82);
  color: #bce8ff;
  background: rgba(31, 95, 146, 0.36);
}

.tree-scroll {
  flex: 1;
  overflow: auto;
  padding: 10px;
}

.subproject-block {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.subproject-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subproject-list {
  max-height: 164px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.panel-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.panel-editor {
  background: rgba(7, 19, 31, 0.88);
  display: flex;
  flex-direction: column;
}

.editor-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.editor-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.whiteboard-wrap {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: rgba(7, 19, 31, 0.66);
  border-top: 1px solid var(--border);
}

.whiteboard-toolbar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.whiteboard-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  cursor: grab;
  background:
    linear-gradient(90deg, rgba(111, 191, 255, 0.1) 1px, transparent 1px),
    linear-gradient(0deg, rgba(111, 191, 255, 0.1) 1px, transparent 1px),
    rgba(6, 19, 30, 0.88);
  background-size: 26px 26px;
}

.whiteboard-viewport.panning {
  cursor: grabbing;
}

.whiteboard-surface {
  position: absolute;
  left: 0;
  top: 0;
  width: 5000px;
  height: 3800px;
  transform-origin: 0 0;
}

.whiteboard-connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.whiteboard-nodes {
  position: absolute;
  inset: 0;
}

.whiteboard-module-bar {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-tabs {
  min-height: 41px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 34, 54, 0.84);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 4px;
  overflow-x: auto;
}

.editor-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(15, 34, 54, 0.84);
}

.editor-file-info {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--font-code);
  color: var(--text-muted);
  font-size: 12px;
}

.editor-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-soft);
}

.editor-empty i {
  font-size: 40px;
  opacity: 0.34;
}

.code-editor {
  display: none;
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  width: 100%;
  background: transparent;
  padding: 14px 16px;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-main);
  overflow: auto;
}

.code-editor-wrap {
  display: none;
  flex: 1;
  min-height: 0;
  border-top: 1px solid rgba(111, 191, 255, 0.08);
}

.monaco-editor-container {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.code-line-numbers {
  width: 56px;
  min-width: 56px;
  border-right: 1px solid var(--border);
  background: rgba(10, 27, 42, 0.72);
  color: rgba(151, 190, 221, 0.76);
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.65;
  padding: 14px 8px 14px 0;
  text-align: right;
  overflow: hidden;
  user-select: none;
}

.code-line-numbers span {
  display: block;
}

.rich-editor-wrap {
  display: none;
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(143, 190, 224, 0.46), transparent 52%),
    linear-gradient(180deg, #d8e1ea 0%, #c8d3df 100%);
  overflow: auto;
  padding: 14px;
  gap: 10px;
  flex-direction: column;
}

.rich-toolbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(69, 102, 132, 0.28);
  background: rgba(244, 248, 252, 0.96);
  padding: 10px;
  border-radius: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(18, 40, 64, 0.18);
}

.rich-toolbar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(79, 114, 146, 0.2);
}

.rich-toolbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #173048;
}

.rich-toolbar-title i {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2f7cc3, #225c94);
  color: #f6fbff;
  box-shadow: 0 6px 14px rgba(34, 92, 148, 0.34);
}

.rich-toolbar-title strong {
  display: block;
  font-size: 13px;
}

.rich-toolbar-title span {
  display: block;
  font-size: 11px;
  color: #607991;
}

.rich-toolbar-save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #4e6a84;
}

.rich-status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #20d08a;
  box-shadow: 0 0 0 4px rgba(32, 208, 138, 0.2);
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.rich-status-indicator.unsaved {
  background: #ffb347;
  box-shadow: 0 0 0 4px rgba(255, 179, 71, 0.22);
}

.rich-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.rich-toolbar-row-actions {
  border-top: 1px solid rgba(79, 114, 146, 0.18);
  padding-top: 8px;
  align-items: center;
}

.rich-toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rich-toolbar-buttons {
  flex-direction: row;
  align-items: center;
  gap: 5px;
}

.rich-toolbar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4f6881;
}

.rich-toolbar-sep {
  width: 1px;
  height: 30px;
  background: rgba(85, 116, 145, 0.28);
  align-self: center;
  margin: 0 2px;
}

.rich-select,
#richColorInput,
#richHighlightInput {
  border: 1px solid rgba(84, 118, 152, 0.38);
  border-radius: 10px;
  background: #fff;
  color: #142033;
  padding: 6px 10px;
  min-height: 34px;
  font-size: 13px;
}

#richColorInput,
#richHighlightInput {
  width: 46px;
  padding: 3px;
}

#richFontFamilySelect {
  min-width: 162px;
}

#richPageSizeSelect {
  min-width: 128px;
}

#richFontSizeSelect,
#richLineHeightSelect {
  min-width: 82px;
}

.rich-tool-btn {
  min-width: 34px;
  height: 34px;
  border-radius: 10px;
  border-color: rgba(84, 118, 152, 0.24);
  background: rgba(255, 255, 255, 0.76);
  color: #1f3d59;
}

.rich-tool-btn:hover {
  border-color: rgba(48, 114, 187, 0.48);
  background: #fff;
}

.rich-tool-btn.is-active {
  border-color: rgba(38, 102, 170, 0.8);
  background: linear-gradient(145deg, #2f7cc3, #235b92);
  color: #fff;
  box-shadow: 0 7px 16px rgba(32, 89, 146, 0.28);
}

.rich-page-canvas {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 10px 16px;
  border: 1px solid rgba(82, 113, 142, 0.2);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.5), rgba(213, 224, 235, 0.2)),
    repeating-linear-gradient(
      0deg,
      rgba(134, 159, 183, 0.08) 0,
      rgba(134, 159, 183, 0.08) 2px,
      transparent 2px,
      transparent 20px
    );
}

.rich-page-stack {
  --rich-page-width: 794px;
  --rich-page-height: 1123px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

.rich-doc-page {
  width: min(var(--rich-page-width), 100%);
  height: var(--rich-page-height);
  position: relative;
  border: 1px solid rgba(71, 105, 139, 0.28);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 48px rgba(16, 37, 62, 0.18);
  overflow: hidden;
}

.rich-doc-page::after {
  content: "Seite " attr(data-page-number);
  position: absolute;
  bottom: 14px;
  right: 18px;
  color: #7b8fa4;
  font-size: 12px;
  font-family: var(--font-ui);
  pointer-events: none;
}

.rich-doc-page-editor {
  height: 100%;
  width: 100%;
  color: #101820;
  padding: 56px 70px;
  line-height: 1.6;
  font-size: 16px;
  font-family: Georgia, "Times New Roman", serif;
  overflow: hidden;
  outline: none;
  user-select: text;
  cursor: text;
  white-space: normal;
  word-break: break-word;
  box-sizing: border-box;
}

.rich-doc-page-editor:empty::before {
  content: "Beginne mit deinem Dokument...";
  color: #90a5b9;
}

.rich-doc-page-editor h1,
.rich-doc-page-editor h2,
.rich-doc-page-editor h3 {
  margin-top: 0.8em;
  margin-bottom: 0.35em;
  color: #0e2137;
}

.rich-doc-page-editor p {
  margin: 0.45em 0;
}

.rich-doc-page-editor ul,
.rich-doc-page-editor ol {
  margin: 0.5em 0 0.7em 1.5em;
}

.rich-doc-page-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.rich-doc-page-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
}

.rich-doc-page-editor th,
.rich-doc-page-editor td {
  border: 1px solid #d0d8e2;
  padding: 8px 10px;
  text-align: left;
}

.rich-statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(71, 105, 139, 0.2);
  border-radius: 12px;
  background: rgba(245, 249, 253, 0.82);
  color: #375268;
  padding: 8px 10px;
  font-size: 12px;
}

.asset-viewer {
  display: none;
  flex: 1;
  min-height: 0;
  padding: 10px;
  gap: 8px;
  flex-direction: column;
}

.asset-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.asset-viewer-body {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(8, 21, 33, 0.78);
  overflow: auto;
}

.asset-center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 14px;
}

.asset-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(111, 191, 255, 0.24);
}

.asset-frame {
  width: 100%;
  min-height: 520px;
  height: 100%;
  border: none;
  background: #fff;
}

.asset-message {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text-muted);
  line-height: 1.5;
}

.asset-message h4 {
  color: var(--text-main);
}

.pdf-asset-pages {
  min-height: 100%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pdf-asset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pdf-asset-page-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}

.pdf-asset-page {
  border: 1px solid rgba(111, 191, 255, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(6, 18, 30, 0.55);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pdf-asset-page.active {
  border-color: rgba(74, 196, 255, 0.68);
  box-shadow: 0 0 0 2px rgba(43, 182, 255, 0.2);
}

.pdf-asset-page-label {
  font-size: 12px;
  color: var(--text-muted);
}

.pdf-asset-page-frame {
  background: #fff;
  border: 1px solid rgba(144, 167, 188, 0.35);
  border-radius: 6px;
  overflow: hidden;
  max-width: 980px;
  margin: 0 auto;
}

.pdf-asset-page-image {
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.preview-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: none;
  flex-direction: column;
  min-height: min(760px, calc(100vh - 70px));
  background: rgba(6, 19, 30, 0.97);
  box-shadow: 0 22px 60px rgba(1, 8, 16, 0.66);
  position: fixed;
  inset: 58px 18px 18px;
  z-index: 1900;
}

.preview-pane.show {
  display: flex;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

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

.preview-panel {
  display: none;
  flex: 1;
  min-height: 0;
}

.preview-panel.active {
  display: flex;
}

#webPreviewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

#pythonPreviewOutput {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.55;
  color: #b8d2ea;
  background: rgba(3, 11, 19, 0.86);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.panel-ai {
  background: rgba(15, 34, 54, 0.75);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ai-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.ai-panel {
  display: none;
  min-height: 0;
  flex-direction: column;
  flex: 1;
  padding: 10px;
  gap: 10px;
}

.ai-panel.active {
  display: flex;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ai-input-wrap {
  display: flex;
  gap: 8px;
}

.ai-input-wrap textarea {
  flex: 1;
  min-height: 40px;
  max-height: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(7, 19, 31, 0.75);
  padding: 9px 11px;
  resize: none;
  font-size: 13px;
  outline: none;
}

.modules-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
}

.struct-result {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  min-height: 64px;
}

.documents-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.document-browser-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.document-browser-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.document-path-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.document-filter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 220px;
  gap: 8px;
}

#docSearchInput,
#docTypeFilter {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.68);
  padding: 9px 10px;
  outline: none;
}

.document-widget-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  align-content: start;
}

.document-detail-view {
  display: none;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.document-detail-view.active {
  display: grid;
}

.document-browser-view.hidden {
  display: none;
}

.doc-editor-panel,
.doc-ai-panel {
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.doc-editor-panel {
  gap: 10px;
}

.doc-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#docTitleInput {
  flex: 1;
  min-width: 220px;
}

#docEditor {
  display: none;
  flex: 1;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(7, 19, 31, 0.65);
  padding: 13px;
  resize: none;
  outline: none;
  line-height: 1.55;
}

.doc-preview-body {
  flex: 1;
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(7, 19, 31, 0.72);
  overflow: auto;
}

.doc-preview-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 10px;
  color: var(--text-soft);
  font-size: 13px;
}

.doc-ai-panel {
  gap: 10px;
}

#documentAiPrompt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.65);
  padding: 10px;
  resize: vertical;
  outline: none;
  min-height: 88px;
}

.doc-ai-messages {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.doc-ai-panel.doc-ai-disabled {
  opacity: 0.85;
}

.doc-ai-panel.doc-ai-disabled .quick-action-row {
  opacity: 0.7;
}

#projectNotesInput {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.65);
  padding: 10px;
  resize: vertical;
  outline: none;
  min-height: 100px;
}

#projectDocAiPrompt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.65);
  padding: 10px;
  resize: vertical;
  outline: none;
  min-height: 100px;
}

.presentation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
  z-index: 2000;
  display: none;
  padding: 14px;
}

.presentation-overlay.show {
  display: flex;
}

.presentation-stage {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px;
}

.presentation-slide-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #101d2f;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  overflow: auto;
}

.presentation-slide {
  width: min(100%, 980px);
  min-height: 72%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  background: #fff;
  color: #122032;
  padding: 28px;
  line-height: 1.45;
}

.presentation-pdf {
  width: min(100%, 1100px);
  height: min(82vh, 860px);
  border: none;
  border-radius: var(--radius-md);
  background: #fff;
}

.presentation-notes {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(13, 27, 41, 0.96);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.presentation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.presentation-notes-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
  line-height: 1.5;
  background: rgba(5, 16, 28, 0.8);
}

#goodnotesContextInput,
#goodnotesPromptInput,
#goodnotesAiResult {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.65);
  padding: 10px;
  resize: vertical;
  outline: none;
}

.goodnotes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.goodnotes-web,
.goodnotes-ai {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.goodnotes-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#goodnotesFrame {
  flex: 1;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

#projectWebCompanionFrame,
#goodnotesCompanionFrame {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.canvas-overlay {
  position: fixed;
  inset: 0;
  z-index: 2050;
  background: rgba(3, 10, 18, 0.84);
  display: none;
  padding: 14px;
}

.canvas-overlay.show {
  display: block;
}

.canvas-shell {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(9, 26, 40, 0.98);
  display: flex;
  flex-direction: column;
}

.canvas-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.canvas-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
}

#canvasFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.canvas-inspector {
  border-left: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 2070;
  background: rgba(4, 11, 19, 0.86);
  display: none;
  padding: 12px;
}

.pdf-editor-overlay.show {
  display: block;
}

.pdf-editor-shell {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(9, 26, 40, 0.98);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.pdf-editor-page-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border: 1px solid rgba(111, 191, 255, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(6, 22, 34, 0.66);
}

.pdf-editor-meta {
  border-bottom: 1px solid rgba(111, 191, 255, 0.16);
  padding: 7px 12px;
}

.pdf-editor-pages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.pdf-edit-page-wrap {
  width: max-content;
}

.pdf-edit-page-wrap.active .pdf-edit-page-label {
  color: #a7ddff;
}

.pdf-edit-page-wrap.active .pdf-edit-page {
  border-color: rgba(74, 196, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(43, 182, 255, 0.2), 0 18px 36px rgba(10, 28, 48, 0.28);
}

.pdf-edit-page-label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 5px 2px;
}

.pdf-edit-page {
  position: relative;
  border: 1px solid rgba(139, 171, 203, 0.36);
  background: #fff;
  box-shadow: 0 18px 36px rgba(10, 28, 48, 0.28);
  overflow: hidden;
}

.pdf-page-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdf-edit-element {
  position: absolute;
  outline: none;
  border: 1px dashed transparent;
  border-radius: 4px;
  z-index: 3;
}

.pdf-edit-element.text {
  background: rgba(255, 245, 157, 0.2);
  border-color: rgba(255, 179, 0, 0.45);
  color: #101820;
  white-space: pre-wrap;
}

.pdf-edit-element.image {
  overflow: hidden;
  resize: both;
  min-width: 24px;
  min-height: 24px;
  background: rgba(255, 255, 255, 0.12);
}

.pdf-edit-element.image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.pdf-edit-element.selected {
  border-color: #2bb6ff;
  box-shadow: 0 0 0 2px rgba(43, 182, 255, 0.26);
}

#canvasTextInput,
#canvasFontSizeInput {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.7);
  padding: 8px 10px;
  color: var(--text-main);
  outline: none;
}

#canvasColorInput {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 19, 31, 0.7);
  padding: 4px;
}

.placeholder-section {
  justify-content: center;
  align-items: center;
}

.placeholder-box {
  padding: 26px;
  text-align: center;
  max-width: 420px;
}

.placeholder-box i {
  font-size: 36px;
  opacity: 0.35;
  margin-bottom: 8px;
}

.placeholder-box h3 {
  margin-bottom: 6px;
}

@media (max-width: 1280px) {
  #projectDetailSection.active {
    grid-template-columns: 220px 1fr 300px;
  }

  .document-detail-view {
    grid-template-columns: 1fr 300px;
  }

  .canvas-body {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
}

@media (max-width: 1080px) {
  .dashboard-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-hero-actions {
    justify-content: flex-start;
  }

  .dashboard-panels {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .dashboard-website-form {
    width: 100%;
  }

  .project-list-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-list-controls #projectSearchInput {
    grid-column: 1 / -1;
  }

  #projectDetailSection.active {
    grid-template-columns: 200px 1fr;
  }

  .panel-ai {
    display: none;
  }

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

  .admin-status-cards {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .document-detail-view {
    grid-template-columns: 1fr;
  }

  .document-filter-row {
    grid-template-columns: 1fr;
  }

  .goodnotes-layout {
    grid-template-columns: 1fr;
  }

  .presentation-stage {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    inset: 60px 10px 10px;
  }
}

@media (max-width: 760px) {
  .section {
    padding: 14px;
  }

  .topbar {
    padding: 8px 10px;
    gap: 8px;
  }

  .topbar-brand {
    min-width: auto;
  }

  .brand-subtitle,
  .topbar-user span {
    display: none;
  }

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

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    padding: 14px;
  }

  .dashboard-hero-actions {
    width: 100%;
  }

  .dashboard-hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .dashboard-website-form {
    align-items: stretch;
  }

  .dashboard-website-form input,
  .dashboard-website-form button {
    width: 100%;
  }

  .utility-layout {
    grid-template-columns: 1fr;
  }

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

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

  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .project-list-controls {
    grid-template-columns: 1fr;
  }

  #projectDetailSection.active {
    display: flex;
    flex-direction: column;
  }

  .panel-tree {
    min-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .editor-workspace {
    display: flex;
    flex-direction: column;
  }

  .document-widget-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .document-detail-view.active {
    display: flex;
    flex-direction: column;
  }

  .canvas-body {
    display: flex;
    flex-direction: column;
  }

  .canvas-inspector {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .pdf-editor-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .rich-editor-wrap {
    padding: 10px;
  }

  .rich-toolbar {
    padding: 8px;
  }

  .rich-toolbar-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .rich-toolbar-row {
    align-items: stretch;
  }

  .rich-toolbar-group {
    width: 100%;
  }

  .rich-toolbar-buttons {
    flex-wrap: wrap;
  }

  .rich-toolbar-sep {
    display: none;
  }

  #richFontFamilySelect,
  #richPageSizeSelect,
  #richFontSizeSelect,
  #richLineHeightSelect {
    width: 100%;
    min-width: 0;
  }

  .rich-toolbar-row-actions .btn {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  .rich-page-canvas {
    padding: 10px 4px;
  }

  .rich-doc-page {
    border-radius: 10px;
    height: min(var(--rich-page-height), calc(100vh - 260px));
  }

  .rich-doc-page-editor {
    padding: 26px 22px;
  }
}
