:root {
  --bg: #0b1020;
  --panel: rgba(20, 26, 44, 0.94);
  --panel-2: rgba(30, 37, 58, 0.92);
  --line: rgba(255,255,255,0.08);
  --text: #f5f7ff;
  --muted: #98a2c9;
  --blue: #5f8bff;
  --green: #2ed09b;
  --yellow: #f8c451;
  --red: #ff7373;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --accent: #5f8bff;
  --input-bg: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.08);
}
/* 默认深色，如果系统是浅色则自动切换 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f5f7;
    --panel: #ffffff;
    --panel-2: #f0f0f2;
    --line: rgba(0,0,0,0.1);
    --text: #1d1d1f;
    --muted: #86868b;
    --blue: #0066cc;
    --accent: #0066cc;
    --input-bg: #f0f0f0;
    --border: rgba(0,0,0,0.1);
  }
}

/* 显式手动切换级别最高 */
[data-theme="light"] {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-2: #f0f0f2;
  --line: rgba(0,0,0,0.1);
  --text: #1d1d1f;
  --muted: #86868b;
  --blue: #0066cc;
  --accent: #0066cc;
  --input-bg: #f0f0f0;
  --border: rgba(0,0,0,0.1);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  transition: background 0.3s ease, color 0.3s ease;
}
button, input, textarea, select { font: inherit; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--blue); }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.header-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  gap: 8px;
  flex-shrink: 0;
}
.brand-title { font-size: 18px; font-weight: 800; text-decoration: none; color: inherit; white-space: nowrap; }
.header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border-color: var(--line);
  color: var(--text);
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
  line-height: 1;
}
.icon-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.12); }
.icon-btn.red-btn { background: linear-gradient(180deg, #ff7373, #e54d4d); }
.icon-btn.red-btn:hover { background: linear-gradient(180deg, #ff9999, #ff7373); }
[data-theme="light"] .icon-btn { background: rgba(0,0,0,0.06); border-color: var(--border); }
[data-theme="light"] .icon-btn:hover { background: rgba(0,0,0,0.12); }

.main-fullscreen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  min-height: 0;
}
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  min-height: 0;
}
.editor-workspace {
  flex: 1;
  display: flex;
  gap: 16px;
  min-height: 0;
  flex-direction: row;
  position: relative;
}
.editor-fab {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity .15s, transform .15s, background .15s;
  padding: 0;
  line-height: 1;
}
.editor-fab:hover { opacity: 1; transform: scale(1.1); background: var(--input-bg); }
@media (max-width: 768px) {
  .editor-workspace { flex-direction: column; }
}
.editor-textarea, .editor-preview {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  overflow: auto;
}
.editor-textarea {
  resize: none;
  font-family: var(--mono);
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
}
.editor-preview {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}
/* CodeMirror Overrides */
.CodeMirror {
  flex: 1;
  height: 100% !important;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 14px;
}
.CodeMirror-dialog {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  padding: 6px 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}
.CodeMirror-dialog input {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  width: auto;
}
.CodeMirror-dialog input:focus { border-color: var(--blue); }
.CodeMirror-dialog button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12px;
  margin-left: 4px;
}
.cm-searching { background: rgba(255, 235, 59, 0.3); }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.toolbar-field {
  flex: 1;
  min-width: 120px;
}
.toolbar-field label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.toolbar-field input, .toolbar-field select { padding: 8px 12px; }

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(180deg, #5f8bff, #3567f0); color: white; }
.btn.secondary { background: rgba(255,255,255,0.06); color: var(--text); border-color: var(--line); }
.btn.red-btn { background: linear-gradient(180deg, #ff7373, #e54d4d); color: white; }
.btn.full { width: 100%; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(0,0,0,.18);
  margin-bottom: 16px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 24px;
  border-radius: 20px;
  width: 90%; max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.modal.large { max-width: 800px; height: 80vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

.capsule-btn { border: none; padding: 6px 15px; border-radius: 16px; cursor: pointer; font-size: 12px; font-weight: 600; }

.text-share-field { margin-bottom: 12px; }
.text-share-field label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.text-share-actions { display: flex; gap: 10px; margin-top: 16px; }

.result-box {
  margin-top: 15px; background: rgba(255,255,255,0.05); padding: 10px; border-radius: 8px;
  word-break: break-all; font-family: var(--mono); font-size: 0.75rem;
}
