@import url("../design-system/tokens.css");

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

html,
body {
  height: 100%;
}

body.experience-page {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  background: var(--aycm-bg-dark);
  color: var(--aycm-text-primary);
  overflow: hidden;
}

.experience-exit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: rgba(8, 13, 26, 0.96);
  border-bottom: 1px solid var(--aycm-border);
  flex-shrink: 0;
}

.experience-exit-bar a {
  color: var(--aycm-brand-cyan);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.experience-exit-bar a:hover {
  text-decoration: underline;
}

.experience-exit-note {
  font-size: 12px;
  color: var(--aycm-text-secondary);
}

.chapter-studio-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 45px);
  min-height: 620px;
  background: #101820;
}

/* Title bar */
.cs-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgb(23, 36, 48);
  flex-shrink: 0;
}

.cs-titlebar-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cs-kicker {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.cs-window-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-titlebar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cs-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-size: 14px;
}

.cs-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cs-antidote-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cs-antidote-btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  font-size: 10px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.cs-antidote-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.cs-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cs-toolbar-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.cs-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.cs-toolbar-btn.destructive {
  color: #ff8a8a;
}

.cs-toolbar-btn.session {
  color: #5ec49a;
  border-color: rgba(56, 115, 97, 0.35);
}

.cs-toolbar-btn.session.active {
  color: #ff8a8a;
}

/* Context bar */
.cs-contextbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  background: #1a222c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.cs-sidebar-toggle {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
}

.cs-sidebar-toggle.active {
  color: #387361;
}

.cs-context-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.12);
}

.cs-scope-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-contextbar .cs-sidebar-toggle:last-child {
  margin-left: auto;
}

/* Workspace */
.cs-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cs-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #141b24;
  transition: width 0.22s ease, opacity 0.22s ease;
}

.cs-panel.hidden {
  width: 0 !important;
  opacity: 0;
  overflow: hidden;
  border: none !important;
}

/* Outline */
.cs-outline {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.cs-outline-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cs-outline-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
}

.cs-outline-count {
  float: right;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.cs-outline-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
}

.cs-outline-body::-webkit-scrollbar {
  width: 4px;
}

.cs-outline-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.cs-chapter-block {
  margin-bottom: 4px;
}

.cs-chapter-row,
.cs-scene-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 26px;
}

.cs-chapter-row:hover,
.cs-scene-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cs-chapter-row.selected {
  background: rgba(56, 115, 97, 0.18);
}

.cs-scene-row.selected {
  background: rgba(51, 204, 255, 0.1);
}

.cs-chevron {
  width: 14px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.cs-chapter-index {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  min-width: 18px;
}

.cs-chapter-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-editing-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 115, 97, 0.25);
  color: #5ec49a;
  flex-shrink: 0;
}

.cs-scene-list {
  margin-left: 22px;
  padding-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.cs-scene-row {
  padding-left: 6px;
}

.cs-scene-num {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  min-width: 42px;
}

.cs-scene-title {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-outline-empty {
  font-size: 10px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.28);
  padding: 4px 8px 4px 26px;
}

.cs-outline-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.cs-outline-footer button {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cs-discard-btn {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
}

.cs-save-btn {
  background: #387361;
  border-color: #387361;
  color: #fff;
}

/* Editor */
.cs-editor {
  flex: 1;
  min-width: 0;
  background: #1c2430;
}

.cs-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #171e28;
}

.cs-tool-select,
.cs-tool-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.78);
  cursor: default;
}

.cs-tool-btn.active {
  background: rgba(56, 115, 97, 0.35);
  border-color: rgba(56, 115, 97, 0.5);
  color: #fff;
}

.cs-tool-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 2px;
}

.cs-manuscript {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px 48px;
}

.cs-manuscript::-webkit-scrollbar {
  width: 6px;
}

.cs-manuscript::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.cs-manuscript-inner {
  max-width: 680px;
  margin: 0 auto;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 24px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.92);
  user-select: text;
  pointer-events: none;
}

.cs-manuscript-inner p {
  margin-bottom: 1em;
}

/* Inspector */
.cs-inspector {
  width: 390px;
  flex-shrink: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  background: #161d27;
}

.cs-inspector-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
}

.cs-tab {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  font-weight: 700;
  padding: 10px 6px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
}

.cs-tab:hover {
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.04);
}

.cs-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 -2px 0 #387361;
}

.cs-inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
}

.cs-inspector-body::-webkit-scrollbar {
  width: 4px;
}

.cs-inspector-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

.cs-field-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  margin-bottom: 6px;
}

.cs-field {
  margin-bottom: 18px;
}

.cs-field-value {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  pointer-events: none;
}

.cs-field-value.multiline {
  min-height: 72px;
  line-height: 1.5;
}

.cs-stepper {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
}

.cs-stepper span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.cs-word-panel {
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cs-word-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 8px;
}

.cs-word-stats strong {
  color: #fff;
  font-size: 14px;
}

.cs-progress-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 8px;
}

.cs-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #c45c7a, #e87898);
}

.cs-word-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

.cs-link-btn {
  display: inline-flex;
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #387361;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cs-link-btn:hover {
  filter: brightness(1.08);
}

.cs-card {
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 14px;
}

.cs-card-title {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 6px;
}

.cs-card-desc {
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 10px;
}

.cs-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cs-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
}

.cs-pill.clickable {
  cursor: pointer;
}

.cs-pill.clickable:hover,
.cs-pill.selected {
  background: rgba(51, 204, 255, 0.12);
  border-color: rgba(51, 204, 255, 0.35);
  color: #fff;
}

.cs-scene-card {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 8px;
  cursor: pointer;
}

.cs-scene-card:hover,
.cs-scene-card.selected {
  border-color: rgba(56, 115, 97, 0.45);
  background: rgba(56, 115, 97, 0.1);
}

.cs-scene-card-head {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 4px;
}

.cs-scene-card-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
}

.cs-status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cs-status-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}

.cs-status-chip.active {
  background: rgba(56, 115, 97, 0.22);
  border-color: rgba(56, 115, 97, 0.45);
  color: #5ec49a;
}

.cs-task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

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

.cs-task-check {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.cs-task-check.done {
  background: #387361;
  border-color: #387361;
}

/* Toast */
.cs-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(15, 22, 41, 0.96);
  border: 1px solid rgba(51, 204, 255, 0.25);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
}

.cs-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Hint overlay for first visit */
.cs-hint-banner {
  padding: 8px 16px;
  background: rgba(51, 204, 255, 0.08);
  border-bottom: 1px solid rgba(51, 204, 255, 0.18);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  flex-shrink: 0;
}

.cs-hint-banner strong {
  color: var(--aycm-brand-cyan);
}

@media (max-width: 1100px) {
  .cs-inspector {
    width: 320px;
  }

  .cs-outline {
    width: 240px;
  }

  .cs-manuscript-inner {
    font-size: 18px;
    padding: 0;
  }
}

@media (max-width: 860px) {
  .cs-workspace {
    flex-direction: column;
    overflow-y: auto;
  }

  .cs-panel.hidden {
    display: none;
  }

  .cs-outline,
  .cs-inspector {
    width: 100%;
    max-height: 280px;
  }

  .cs-editor {
    min-height: 360px;
  }

  .cs-titlebar-right .cs-toolbar-actions {
    display: none;
  }
}
