/* ========================================
   Chat CSS Editor - 界面美化 CSS 编辑器页
   iOS 风格 · 白色卡片 · 干净透气

   .chat-css-editor-screen   全屏容器
   .cce-header               顶部导航栏
   .cce-body                 可滚动内容区
   .cce-section              内容区块
   .cce-textarea             CSS 输入框
   .cce-action-btn           快捷操作按钮
   .cce-status-card          状态卡片
   .cce-tips-card            使用提示折叠卡片
   ======================================== */

/* ================================================
   1. 全屏容器
   ================================================ */
.chat-css-editor-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: #ffffff;
  z-index: 700;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0s linear 0.3s;
  will-change: transform;
}

.chat-css-editor-screen.is-active {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0s linear 0s;
}

/* ================================================
   2. 顶部导航栏
   ================================================ */
.cce-header {
  height: 56px;
  margin-top: var(--safe-area-top);
  display: flex;
  align-items: center;
  padding: 0 12px;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.cce-header__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: none; border: none;
  cursor: pointer;
  color: var(--color-text-primary);
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}
.cce-header__back:active {
  background-color: rgba(0, 0, 0, 0.05);
}
.cce-header__back svg {
  width: 22px; height: 22px;
}

.cce-header__title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  letter-spacing: 0.2px;
}

.cce-header__right {
  flex-shrink: 0;
}

.cce-header__done {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.04);
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-accent);
  font-family: var(--font-family);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}
.cce-header__done:active {
  background: rgba(0, 0, 0, 0.08);
}

/* ================================================
   3. 可滚动内容区
   ================================================ */
.cce-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px;
}
.cce-body::-webkit-scrollbar {
  width: 0; display: none;
}

.cce-bottom-spacer {
  height: calc(32px + var(--safe-area-bottom));
}

/* ================================================
   4. 内容区块
   ================================================ */
.cce-section {
  padding: 16px 0 0;
}
.cce-section:first-child {
  padding-top: 20px;
}

.cce-section__title {
  font-size: 16px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.cce-section__desc {
  font-size: 13px;
  color: var(--color-text-secondary, #666);
  font-weight: var(--font-weight-regular);
  line-height: 1.6;
  margin-bottom: 6px;
}

.cce-section__hint {
  font-size: 12px;
  color: var(--color-accent);
  font-weight: var(--font-weight-light);
  line-height: 1.5;
  padding: 6px 10px;
  background: rgba(0, 122, 255, 0.05);
  border-radius: 8px;
  margin-top: 4px;
}

.cce-section__label {
  font-size: 13px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

/* ================================================
   5. CSS 输入框
   ================================================ */
.cce-textarea-wrap {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.cce-textarea-wrap:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.08);
}

.cce-textarea {
  display: block;
  width: 100%;
  height: 300px;
  min-height: 260px;
  max-height: 400px;
  padding: 14px 16px;
  border: none;
  outline: none;
  resize: vertical;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-text-primary);
  background: transparent;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}
.cce-textarea::placeholder {
  color: var(--color-text-hint, #bbb);
  font-weight: var(--font-weight-light);
}
.cce-textarea::-webkit-scrollbar {
  width: 4px;
}
.cce-textarea::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

/* ================================================
   6. 快捷操作按钮
   ================================================ */
.cce-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cce-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 18px;
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.cce-action-btn:active {
  transform: scale(0.95);
}
.cce-action-btn svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
}

.cce-action-btn--default {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-accent);
}
.cce-action-btn--default:active {
  background: rgba(0, 0, 0, 0.09);
}
.cce-action-btn--default svg {
  color: var(--color-accent);
}

.cce-action-btn--danger {
  background: rgba(255, 59, 48, 0.07);
  color: #e8453c;
}
.cce-action-btn--danger:active {
  background: rgba(255, 59, 48, 0.13);
}
.cce-action-btn--danger svg {
  color: #e8453c;
}

/* ================================================
   7. 状态卡片
   ================================================ */
.cce-status-card {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 14px;
  padding: 10px 16px;
}

.cce-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.cce-status-row + .cce-status-row {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.cce-status-label {
  font-size: 13px;
  color: var(--color-text-secondary, #666);
  font-weight: var(--font-weight-regular);
}

.cce-status-value {
  font-size: 13px;
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
}

.cce-status-value--custom {
  color: var(--color-accent);
}

/* ================================================
   8. 使用提示折叠卡片
   ================================================ */
.cce-tips-card {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 14px;
  overflow: hidden;
}

.cce-tips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}
.cce-tips-header:active {
  background-color: rgba(0, 0, 0, 0.03);
}

.cce-tips-header__title {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.cce-tips-header__arrow {
  width: 18px; height: 18px;
  color: var(--color-text-hint);
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cce-tips-card.is-open .cce-tips-header__arrow {
  transform: rotate(180deg);
}

.cce-tips-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cce-tips-card.is-open .cce-tips-body {
  max-height: 3000px;
}

.cce-tips-list {
  list-style: none;
  margin: 0;
  padding: 0 16px 8px;
}

.cce-tips-list li {
  font-size: 13px;
  color: var(--color-text-secondary, #666);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  position: relative;
  padding-left: 14px;
}
.cce-tips-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-weight: var(--font-weight-semibold);
  font-size: 16px;
}
.cce-tips-list li:last-child {
  border-bottom: none;
}

.cce-tips-note {
  font-size: 11px;
  color: var(--color-text-hint);
  font-weight: var(--font-weight-light);
  line-height: 1.5;
  padding: 4px 16px 14px;
}

.cce-tips-note code {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 10px;
  background: rgba(0, 122, 255, 0.06);
  color: var(--color-accent);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ================================================
   9. 提示列表内 code / strong 样式
   ================================================ */
.cce-tips-list li strong {
  display: block;
  font-size: 13px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.cce-tips-list li code {
  display: inline-block;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 11px;
  background: rgba(0, 122, 255, 0.06);
  color: var(--color-accent);
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  line-height: 1.8;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  user-select: all;
  -webkit-user-select: all;
}

.cce-tips-list li code:active {
  transform: scale(0.95);
  background: rgba(0, 122, 255, 0.12);
}

/* 复制成功反馈 */
.cce-tips-list li code.cce-code--copied {
  background: rgba(52, 199, 89, 0.12);
  color: #34c759;
}
.cce-tips-list li code.cce-code--copied::after {
  content: ' ✓';
  font-size: 10px;
}

.cce-tips-list li br + code {
  margin-top: 2px;
}

.cce-tips-list li {
  padding-bottom: 10px;
  margin-bottom: 2px;
}

/* ================================================
   10. 外观预设区
   ================================================ */
.cce-preset-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.cce-preset-list {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 4px;
}

.cce-preset-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.cce-preset-list__title {
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary, #666);
}

.cce-preset-list__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: none; background: none;
  cursor: pointer;
  color: var(--color-text-hint);
  border-radius: var(--radius-full);
  transition: background-color 0.15s ease;
}
.cce-preset-list__close:active {
  background: rgba(0, 0, 0, 0.05);
}
.cce-preset-list__close svg {
  width: 16px; height: 16px;
  transform: rotate(180deg);
}

.cce-preset-list__body {
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cce-preset-list__body::-webkit-scrollbar { width: 0; display: none; }

.cce-preset-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-hint, #bbb);
}

.cce-preset-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}
.cce-preset-card:last-child { border-bottom: none; }

.cce-preset-card__info {
  flex: 1;
  min-width: 0;
  margin-right: 10px;
}

.cce-preset-card__name {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cce-preset-card__meta {
  font-size: 11px;
  color: var(--color-text-hint, #bbb);
  margin-top: 2px;
}

.cce-preset-card__preview {
  margin-top: 4px;
}
.cce-preset-card__preview code {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 10px;
  color: var(--color-text-secondary, #666);
  background: rgba(0, 0, 0, 0.03);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cce-preset-card__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.cce-preset-card__btn {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 14px;
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.cce-preset-card__btn:active { transform: scale(0.95); }

.cce-preset-card__btn--apply {
  background: rgba(0, 122, 255, 0.08);
  color: var(--color-accent);
}
.cce-preset-card__btn--apply:active {
  background: rgba(0, 122, 255, 0.15);
}

.cce-preset-card__btn--delete {
  background: rgba(255, 59, 48, 0.07);
  color: #e8453c;
}
.cce-preset-card__btn--delete:active {
  background: rgba(255, 59, 48, 0.13);
}

/* ================================================
   11. 保存预设弹窗
   ================================================ */
.cce-modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.cce-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.cce-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: 280px;
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px 16px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.cce-modal.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.cce-modal__title {
  font-size: 16px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  text-align: center;
  margin-bottom: 16px;
}

.cce-modal__input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.02);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}
.cce-modal__input:focus {
  border-color: var(--color-accent);
}
.cce-modal__input::placeholder {
  color: var(--color-text-hint, #bbb);
}

.cce-modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.cce-modal__btn {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}

.cce-modal__btn--cancel {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-secondary, #666);
}
.cce-modal__btn--cancel:active {
  background: rgba(0, 0, 0, 0.09);
}

.cce-modal__btn--confirm {
  background: var(--color-accent);
  color: #fff;
}
.cce-modal__btn--confirm:active {
  opacity: 0.85;
}
