/* ================================================================
   appjs 工具库 — 杂志风格 · 深色/浅色双主题
   ================================================================ */

/* ── 浅色主题（默认） ── */
:root,
[data-theme="light"] {
  --bg:            #faf9f6;
  --bg-alt:        #f3f1ed;
  --surface:       #ffffff;
  --surface-2:     #faf9f7;
  --surface-3:     #f5f3ef;
  --border:        #e8e5df;
  --border-light:  #f0ede7;
  --border-strong: #d5d1c9;
  --text:          #1c1c1c;
  --text-secondary:#525252;
  --text-muted:    #999793;
  --text-quiet:    #bbb8b2;
  --accent:        #8b7355;
  --accent-hover:  #7a6349;
  --accent-light:  #f6f1eb;
  --accent-glow:   rgba(139,115,85,.12);
  --danger:        #c7524a;
  --danger-bg:     #fdf5f4;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.03);
  --shadow:        0 2px 8px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-btn:    0 1px 3px rgba(0,0,0,.06);
  --overlay:       rgba(0,0,0,.35);
  --serif:         "Times New Roman", Georgia, "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans:          -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", system-ui, sans-serif;
  --mono:          "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --radius:        2px;
  --radius-md:     6px;
  --radius-lg:     12px;
  --header-h:      56px;
}

/* ── 深色主题 ── */
[data-theme="dark"] {
  --bg:            #171717;
  --bg-alt:        #1c1c1c;
  --surface:       #222222;
  --surface-2:     #262626;
  --surface-3:     #1f1f1f;
  --border:        #2e2e2e;
  --border-light:  #2a2a2a;
  --border-strong: #3a3a3a;
  --text:          #e8e4dd;
  --text-secondary:#b0aea9;
  --text-muted:    #7a7874;
  --text-quiet:    #51504d;
  --accent:        #c4a67a;
  --accent-hover:  #d4b88c;
  --accent-light:  #2a2520;
  --accent-glow:   rgba(196,166,122,.15);
  --danger:        #d9605a;
  --danger-bg:     #2a2020;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.2);
  --shadow:        0 2px 8px rgba(0,0,0,.25);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.35);
  --shadow-btn:    0 1px 3px rgba(0,0,0,.3);
  --overlay:       rgba(0,0,0,.6);
}

/* ── 全局过渡 ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  color-scheme: light dark;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background-color .3s ease, color .3s ease;
}
button, input, textarea {
  font-family: inherit;
  transition: background-color .3s ease, color .3s ease, border-color .3s ease;
}
button { cursor: pointer; border: none; background: none; font-size: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }

/* ================================================================
   首页
   ================================================================ */

/* ── 顶栏（精致细条） ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-logo {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.5px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 主题切换按钮 */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all .2s;
}
.theme-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
}
.theme-toggle svg { width: 17px; height: 17px; }

/* 按钮 */
.btn-primary {
  background: var(--text);
  color: var(--bg);
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: .3px;
  transition: all .2s;
}
.btn-primary:hover {
  background: var(--accent);
  color: #fff;
}
.btn-primary:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn-ghost {
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: transparent;
  transition: all .2s;
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

/* ── 设置齿轮 ── */
.settings-gear {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text-quiet);
  transition: all .15s;
  position: relative;
}
.settings-gear:hover {
  background: var(--surface-3);
  color: var(--text);
}
.settings-gear svg { width: 16px; height: 16px; }
.settings-gear.active {
  background: var(--surface-3);
  color: var(--accent);
}

/* ── 设置下拉面板 ── */
.settings-panel {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  right: 40px;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all .18s cubic-bezier(.25,.1,.25,1);
}
.settings-panel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .12s;
  font-weight: 500;
}
.settings-item:hover {
  background: var(--surface-3);
  color: var(--text);
}
.settings-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}
.settings-item.hint {
  font-size: 11px;
  color: var(--text-quiet);
  cursor: default;
  pointer-events: none;
}
.settings-item.hint:hover {
  background: none;
  color: var(--text-quiet);
}
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Hero 引导区 ── */
.hero {
  text-align: center;
  padding: 100px 24px 64px;
  max-width: 720px;
  margin: 0 auto;
}
.hero-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--accent);
  margin-bottom: 24px;
  padding: 4px 14px;
  border: 1px solid var(--accent);
  opacity: .7;
}
.hero h1 {
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1px;
  margin-bottom: 20px;
  color: var(--text);
}
.hero-desc {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 480px;
  margin: 0 auto 36px;
  letter-spacing: .2px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.btn-hero-primary {
  padding: 13px 32px;
  font-size: 14px;
  font-weight: 600;
  background: var(--text);
  color: var(--bg);
  border: none;
  cursor: pointer;
  letter-spacing: .5px;
  transition: all .2s;
}
.btn-hero-primary:hover {
  background: var(--accent);
  color: #fff;
}

.btn-hero-ghost {
  padding: 13px 32px;
  font-size: 14px;
  font-weight: 550;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  letter-spacing: .5px;
  transition: all .2s;
}
.btn-hero-ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-3);
}

.hero-divider {
  width: 60px;
  height: 1px;
  background: var(--border-strong);
  margin: 0 auto 40px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 56px;
}
.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.hero-stat strong {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.hero-stat span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.section-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-header .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  white-space: nowrap;
}
.section-header .count {
  font-size: 11px;
  color: var(--text-quiet);
  letter-spacing: .5px;
  white-space: nowrap;
}
.section-header .rule {
  flex: 1;
  height: 1px;
  background: var(--border);
  min-width: 20px;
}
/* 两个区块之间的视觉分隔 */
.apps-section + .apps-section {
  border-top: 1px solid var(--border);
  padding-top: 32px;
  margin-top: 16px;
}
.apps-section + .apps-section .section-header {
  padding-top: 0;
}
.btn-add {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  background: transparent;
  letter-spacing: .3px;
  white-space: nowrap;
  cursor: pointer;
  transition: all .2s;
}
.btn-add:hover {
  background: var(--accent);
  color: #fff;
}

/* ── 卡片网格（杂志式 3 列） ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  padding: 0 40px 80px;
  max-width: 1320px;
  margin: 0 auto;
}

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all .25s cubic-bezier(.25,.1,.25,1);
  overflow: hidden;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

/* 卡片顶部色条 */
.card-accent {
  height: 3px;
  width: 100%;
  transition: height .25s, opacity .25s;
  opacity: .85;
}
.card:hover .card-accent {
  opacity: 1;
  height: 4px;
}

/* 卡片主体 */
.card-body {
  padding: 28px 28px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 卡片编号 */
.card-num {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text-quiet);
  margin-bottom: 14px;
  letter-spacing: 1px;
  font-style: italic;
}

/* 标签 */
.card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.card-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  transition: all .2s;
}
.card:hover .card-tag {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* 卡片标题 */
.card-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.3px;
  margin-bottom: 10px;
  color: var(--text);
  transition: color .25s;
}
.card:hover .card-name {
  color: var(--accent);
}

/* 卡片描述 */
.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  letter-spacing: .2px;
}

/* 卡片底部（署名行） */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-top: 1px solid var(--border-light);
  gap: 8px;
}
.card-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.card-date {
  font-size: 11px;
  color: var(--text-quiet);
  letter-spacing: .3px;
  white-space: nowrap;
}
.card-author {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--accent);
  white-space: nowrap;
  opacity: .7;
}
.card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* 图标按钮 */
.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-quiet);
  transition: all .15s;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-btn.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.icon-btn svg {
  width: 14px; height: 14px;
}

/* 分享按钮 */
.icon-btn.share-btn {
  color: var(--text-quiet);
}
.icon-btn.share-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}
.icon-btn.share-btn.shared {
  color: var(--accent);
}

/* 加密锁图标 */
.card-lock-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  color: var(--text-muted);
  vertical-align: middle;
}
.card-lock-icon svg {
  width: 14px;
  height: 14px;
}
.card-encrypted .card-lock-icon {
  color: var(--accent);
}

/* 加密按钮 */
.icon-btn.encrypt-app {
  color: var(--text-quiet);
}
.icon-btn.encrypt-app:hover {
  color: var(--accent);
  background: var(--accent-light);
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 100px 20px;
  grid-column: 1 / -1;
  color: var(--text-muted);
}
.empty-rule {
  width: 60px;
  height: 1px;
  background: var(--border-strong);
  margin: 0 auto 24px;
}
.empty h3 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.empty p {
  font-size: 14px;
  margin-bottom: 4px;
}
.empty .hint {
  font-size: 13px;
  color: var(--text-quiet);
}

/* ================================================================
   模态框
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
}
.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.field input,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--surface-3);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
/* 自动填充标记：淡色左边框闪烁提示 */
.field input.auto-filled,
.field textarea.auto-filled {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
}
@keyframes autoFillIn {
  from { border-left-color: var(--accent); }
  50%  { border-left-color: var(--border); }
  to   { border-left-color: var(--accent); }
}
.field input.auto-filled {
  animation: autoFillIn .6s ease;
}

.field textarea.code {
  font-family: var(--mono);
  font-size: 13px;
  min-height: 220px;
  resize: vertical;
  line-height: 1.7;
  tab-size: 2;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 22px;
  font-size: 13px;
  letter-spacing: .3px;
  opacity: 0;
  transition: all .25s;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================================================================
   运行页
   ================================================================ */
.run-page {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* iframe 全屏 */
.run-iframe-wrap {
  position: absolute;
  inset: 0;
  background: var(--bg);
}
.run-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 加载状态 */
.run-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: .3px;
  z-index: 1;
  background: var(--bg);
  pointer-events: none;
}
.run-loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 访客返回按钮（非所有者看分享应用时） ── */
.guest-back {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  transition: all .15s;
  text-decoration: none;
  letter-spacing: .3px;
}
.guest-back:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-2);
}
.guest-back svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   浮动沉浸式控制台（毛玻璃）
   ═══════════════════════════════════════════════════════════════ */
.console-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform .35s cubic-bezier(.25,.1,.25,1);
}

/* 浅色毛玻璃 */
[data-theme="light"] .console-panel,
:root .console-panel {
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 -4px 24px rgba(0,0,0,.05);
}

/* 深色毛玻璃 */
[data-theme="dark"] .console-panel {
  background: rgba(30,30,30,.78);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 -4px 24px rgba(0,0,0,.25);
}

/* ── 控制条（始终可见的窄行） ── */
.console-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  flex-shrink: 0;
  min-height: 42px;
}

.console-bar .cb-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 550;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all .15s;
  letter-spacing: .3px;
}
.console-bar .cb-back:hover {
  background: var(--surface-3);
  color: var(--text);
}
.console-bar .cb-back svg { width: 14px; height: 14px; }

.console-bar .cb-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .2px;
}

.console-bar .cb-actions { display: flex; gap: 3px; align-items: center; }

.console-bar .cb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 550;
  padding: 4px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: all .15s;
  white-space: nowrap;
  letter-spacing: .3px;
}
.console-bar .cb-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.console-bar .cb-btn svg { width: 12px; height: 12px; }

/* 重新运行按钮 */
.console-bar .cb-rerun {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}
.console-bar .cb-rerun:hover {
  background: var(--accent);
  color: #fff;
}

/* 控制台切换按钮 */
.console-bar .cb-toggle {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 550;
  transition: all .15s;
  letter-spacing: .3px;
}
.console-bar .cb-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.console-bar .cb-toggle .badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0px 6px;
  border-radius: 10px;
  margin-left: 4px;
  min-width: 16px;
  display: inline-block;
  text-align: center;
  line-height: 16px;
}

/* 主题切换（控制条里的迷你版） */
.console-bar .cb-theme {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: all .15s;
}
.console-bar .cb-theme:hover {
  background: var(--surface-3);
  color: var(--text);
}
.console-bar .cb-theme svg { width: 14px; height: 14px; }

.console-bar .cb-sep {
  width: 0;
  height: 14px;
  border-left: 1px solid var(--border);
  margin: 0 2px;
}

/* ── 日志面板（展开时显示） ── */
.console-body-wrap {
  overflow: hidden;
  transition: max-height .35s cubic-bezier(.25,.1,.25,1);
  max-height: 0;
}
.console-panel.open .console-body-wrap {
  max-height: 240px;
}
.console-body {
  padding: 4px 16px 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.8;
  overflow-y: auto;
  max-height: 220px;
  color: var(--text-secondary);
}
[data-theme="dark"] .console-body {
  color: #c8c6c0;
}
.console-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 0;
}
.console-line.error { color: #d9605a; }
.console-line.warn  { color: #d4a43a; }
.console-line.info  { color: #5a9fd4; }
[data-theme="dark"] .console-line.error { color: #e06060; }
[data-theme="dark"] .console-line.warn  { color: #e0b040; }
[data-theme="dark"] .console-line.info  { color: #60b0e0; }
.console-line .ctag {
  color: var(--text-quiet);
  margin-right: 6px;
  font-size: 10px;
}
[data-theme="dark"] .console-line .ctag {
  color: #5a5854;
}
.console-empty {
  color: var(--text-quiet);
  font-style: italic;
}

/* ================================================================
   响应式
   ================================================================ */
/* ================================================================
   登录/注册页
   ================================================================ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}
.auth-container {
  width: 100%;
  max-width: 400px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .3s ease-out;
}
.auth-logo {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -.5px;
}
.auth-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  background: none;
  cursor: pointer;
}
.auth-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.auth-tab:hover {
  color: var(--text);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.auth-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--surface-3);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.auth-error {
  font-size: 13px;
  color: var(--danger);
  padding: 8px 12px;
  background: var(--danger-bg);
  border: 1px solid rgba(199,82,74,.2);
}
.auth-btn {
  width: 100%;
  padding: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .5px;
  border: none;
  cursor: pointer;
  transition: all .2s;
  margin-top: 4px;
}
.auth-btn:hover {
  background: var(--accent);
  color: #fff;
}
.auth-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── 解锁模态框（run 页面专用，专业加密设计）── */
.run-unlock-modal {
  max-width: 420px;
}
.unlock-app-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.rlock-icon {
  display: block;
  color: var(--accent);
  opacity: .7;
}
.rlock-name {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  word-break: break-word;
}
.unlock-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* ── 分享管理面板 ── */
.share-mgmt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.share-mgmt-item:last-child {
  border-bottom: none;
}
.share-mgmt-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.share-mgmt-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-mgmt-link {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-mgmt-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.share-mgmt-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .12s;
  font-size: 11px;
  font-weight: 550;
}
.share-mgmt-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.share-mgmt-btn.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.share-mgmt-btn.copy:hover {
  color: var(--accent);
  background: var(--accent-light);
}
.share-mgmt-btn.share-go {
  width: auto;
  padding: 5px 12px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .3px;
}
.share-mgmt-btn.share-go:hover {
  background: var(--accent);
  color: #fff;
}

/* ── 用户信息（顶栏）── */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.user-name {
  color: var(--text-secondary);
  font-weight: 550;
}
.btn-login {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: transparent;
  letter-spacing: .3px;
  transition: all .2s;
}
.btn-login:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-3);
}
.btn-logout {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 550;
  color: var(--text-quiet);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  transition: all .15s;
}
.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* ================================================================
   响应式 — 平板 (≤768px)
   ================================================================ */
@media (max-width: 768px) {
  .topbar { padding: 0 20px; }
  .hero { padding: 64px 20px 40px; }
  .hero h1 { font-size: 36px; }
  .hero-desc { font-size: 14px; }
  .hero-stats { gap: 32px; }
  .hero-stat strong { font-size: 24px; }
  .grid {
    grid-template-columns: 1fr;
    padding: 0 20px 60px;
    gap: 16px;
  }
  .section-header { padding: 0 20px 16px; }
  .card-body { padding: 22px 22px 16px; }
  .card-footer { padding: 12px 22px; }
  .settings-panel { right: 12px; }
  .editor-main { flex-direction: column; }
  .editor-pane.code { border-right: none; border-bottom: 1px solid var(--border); min-height: 300px; }
  .split-handle { width: 100%; height: 4px; cursor: row-resize; }
}

/* ================================================================
   响应式 — 手机 (≤640px)
   ================================================================ */
@media (max-width: 640px) {
  /* ── 顶栏 ── */
  .topbar {
    padding: 0 14px;
    height: 52px;
  }
  .topbar-logo { font-size: 18px; }
  .user-name { display: none; }
  .btn-login { font-size: 11px; padding: 5px 10px; }
  .btn-logout { font-size: 11px; padding: 4px 8px; }

  /* ── Hero ── */
  .hero {
    padding: 48px 18px 36px;
  }
  .hero h1 {
    font-size: 30px;
    letter-spacing: -.5px;
  }
  .hero-desc {
    font-size: 14px;
    max-width: 100%;
    margin-bottom: 28px;
    line-height: 1.7;
  }
  .hero-desc br { display: none; }
  .hero-badge {
    font-size: 9px;
    letter-spacing: 2px;
    padding: 3px 10px;
    margin-bottom: 18px;
  }
  .hero-actions {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 36px;
  }
  .btn-hero-primary,
  .btn-hero-ghost {
    width: 100%;
    text-align: center;
    padding: 13px 24px;
    font-size: 14px;
  }
  .hero-divider { margin-bottom: 32px; }
  .hero-stats { gap: 28px; }
  .hero-stat strong { font-size: 22px; }
  .hero-stat span { font-size: 10px; letter-spacing: 1px; }

  /* ── 应用目录 ── */
  .apps-section { padding-top: 8px; }
  .section-header {
    padding: 0 14px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .section-header .label { font-size: 10px; letter-spacing: 1.5px; }
  .section-header .count { font-size: 10px; }
  .btn-add { font-size: 11px; padding: 6px 12px; }

  /* ── 卡片网格 ── */
  .grid {
    padding: 0 14px 52px;
    gap: 14px;
  }

  /* ── 卡片 ── */
  .card-body {
    padding: 20px 18px 14px;
  }
  .card-num {
    font-size: 11px;
    margin-bottom: 10px;
  }
  .card-tag {
    font-size: 9px;
    padding: 2px 7px;
    letter-spacing: .5px;
  }
  .card-tags {
    gap: 6px;
    margin-bottom: 10px;
  }
  .card-name {
    font-size: 18px;
    letter-spacing: -.2px;
    margin-bottom: 8px;
  }
  .card-desc {
    font-size: 12px;
    line-height: 1.6;
  }

  /* 卡片底部 — 防止文字重叠 */
  .card-footer {
    padding: 10px 18px;
    flex-wrap: wrap;
    gap: 6px;
    min-height: auto;
  }
  .card-footer-left {
    flex: 1 1 100%;
    min-width: 0;
    overflow: hidden;
  }
  .card-date {
    font-size: 10px;
    white-space: nowrap;
  }
  .card-author {
    font-size: 9px;
    letter-spacing: .3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .card-actions {
    flex-shrink: 1;
    justify-content: flex-end;
    flex: 0 0 auto;
  }
  .card-actions .icon-btn {
    width: 32px;
    height: 32px;
  }
  .card-actions .icon-btn svg {
    width: 14px;
    height: 14px;
  }

  /* ── 设置面板 ── */
  .settings-panel {
    right: 8px;
    top: calc(var(--header-h) + 4px);
    width: 180px;
  }
  .settings-item {
    padding: 11px 14px;
    font-size: 12px;
  }

  /* ── 模态框 ── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    animation: modalUp .25s ease-out;
  }
  @keyframes modalUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .modal-header {
    padding: 18px 18px 14px;
  }
  .modal-header h2 {
    font-size: 16px;
  }
  .modal-body {
    padding: 18px;
  }
  .modal-footer {
    padding: 14px 18px;
  }
  .field { margin-bottom: 14px; }
  .field label { font-size: 10px; letter-spacing: .8px; }
  .field input,
  .field textarea {
    font-size: 13px;
    padding: 9px 12px;
  }
  .field textarea.code {
    min-height: 180px;
    font-size: 12px;
  }

  /* ── Toast ── */
  .toast {
    bottom: 24px;
    left: 14px;
    right: 14px;
    transform: translateY(12px);
    text-align: center;
    font-size: 12px;
    padding: 9px 16px;
  }
  .toast.show {
    transform: translateY(0);
  }

  /* ── 空状态 ── */
  .empty { padding: 64px 16px; }
  .empty h3 { font-size: 20px; }
  .empty p { font-size: 13px; }

  /* ── 登录/注册页 ── */
  .auth-page { padding: 16px; align-items: flex-start; }
  .auth-container { max-width: 100%; }
  .auth-card { padding: 36px 24px; }
  .auth-logo { font-size: 28px; }
  .auth-tab { font-size: 13px; padding: 8px 0; }
  .auth-field input { padding: 10px 12px; font-size: 13px; }
  .auth-btn { padding: 11px; font-size: 14px; }

  /* ── 编辑器 ── */
  .editor-topbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .editor-topbar .title-inp { max-width: 100%; flex: 1 1 140px; }
  .editor-topbar .desc-inp { max-width: 100%; flex: 2 1 200px; }
  .editor-topbar .kbd { display: none; }

  /* ── 通用图标按钮（移动端增大触控区域） ── */
  .icon-btn {
    width: 34px;
    height: 34px;
  }
  .icon-btn svg {
    width: 15px;
    height: 15px;
  }
}

/* ================================================================
   响应式 — 小手机 (≤480px)
   ================================================================ */
@media (max-width: 480px) {
  /* ── 顶栏 ── */
  .topbar {
    padding: 0 10px;
    height: 48px;
  }
  .topbar-logo { font-size: 17px; }
  .settings-gear { width: 32px; height: 32px; }
  .theme-toggle { width: 32px; height: 32px; }
  .theme-toggle svg { width: 15px; height: 15px; }

  /* ── Hero ── */
  .hero {
    padding: 36px 14px 28px;
  }
  .hero h1 {
    font-size: 24px;
    letter-spacing: -.3px;
  }
  .hero-desc {
    font-size: 13px;
    margin-bottom: 22px;
  }
  .hero-badge {
    font-size: 8px;
    letter-spacing: 1.5px;
    padding: 2px 8px;
    margin-bottom: 14px;
  }
  .btn-hero-primary,
  .btn-hero-ghost {
    padding: 12px 20px;
    font-size: 13px;
  }
  .hero-stats { gap: 18px; }
  .hero-stat strong { font-size: 18px; }
  .hero-stat span { font-size: 9px; letter-spacing: .8px; }

  /* ── 卡片 ── */
  .grid {
    padding: 0 8px 40px;
    gap: 10px;
  }
  .card-body {
    padding: 16px 14px 12px;
  }
  .card-name {
    font-size: 16px;
  }
  .card-desc {
    font-size: 11px;
  }
  .card-footer {
    padding: 8px 14px;
  }

  /* ── 设置面板 ── */
  .settings-panel {
    right: 4px;
    top: 46px;
    width: 168px;
  }
  .settings-item {
    padding: 10px 12px;
    font-size: 11px;
    gap: 8px;
  }

  /* ── 分区标题 ── */
  .section-header {
    padding: 0 10px 12px;
    gap: 6px;
  }
  .section-header .label { font-size: 9px; letter-spacing: 1px; }
  .btn-add { font-size: 10px; padding: 5px 10px; }

  /* ── 模态框 ── */
  .modal-header { padding: 14px 14px 12px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 12px 14px; gap: 8px; }
  .modal-header h2 { font-size: 15px; }

  /* ── 登录/注册 ── */
  .auth-card { padding: 28px 18px; }
  .auth-logo { font-size: 24px; }
  .auth-subtitle { font-size: 12px; margin-bottom: 24px; }

  /* ── Toast ── */
  .toast { left: 10px; right: 10px; font-size: 11px; }

  /* ── 空状态 ── */
  .empty h3 { font-size: 18px; }

  /* ── 解锁模态框 ── */
  .rlock-name { font-size: 16px; }
  .unlock-hint { font-size: 12px; }

  /* ── 分享管理 ── */
  .share-mgmt-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 0;
  }
  .share-mgmt-link {
    font-size: 10px;
  }
  .share-mgmt-name {
    font-size: 13px;
  }
  .share-mgmt-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ================================================================
   响应式 — 运行页控制台 (≤640px)
   ================================================================ */
@media (max-width: 640px) {
  .console-bar {
    gap: 4px;
    padding: 6px 8px;
    min-height: 40px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .console-bar .cb-back {
    font-size: 0;
    padding: 6px;
  }
  .console-bar .cb-back svg { width: 16px; height: 16px; }
  .console-bar .cb-title {
    font-size: 11px;
    max-width: 90px;
  }
  .console-bar .cb-btn {
    font-size: 0;
    padding: 6px 8px;
  }
  .console-bar .cb-btn svg {
    width: 14px;
    height: 14px;
  }
  .console-bar .cb-btn.cb-rerun {
    font-size: 10px;
    padding: 5px 10px;
  }
  .console-bar .cb-btn.cb-rerun svg {
    width: 11px;
    height: 11px;
  }
  .console-bar .cb-toggle {
    font-size: 10px;
    padding: 5px 10px;
  }
  .console-bar .cb-toggle .badge {
    font-size: 9px;
    min-width: 14px;
    line-height: 14px;
    padding: 0 4px;
    margin-left: 2px;
  }
  .console-bar .cb-theme {
    width: 30px;
    height: 30px;
  }
  .console-bar .cb-theme svg {
    width: 14px;
    height: 14px;
  }
  .console-bar .cb-sep {
    margin: 0 1px;
  }
  .console-panel.open .console-body-wrap {
    max-height: 180px;
  }
  .console-body {
    max-height: 160px;
    padding: 4px 10px 10px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .console-bar {
    padding: 5px 6px;
    gap: 2px;
  }
  .console-bar .cb-title {
    font-size: 10px;
    max-width: 70px;
  }
  .console-bar .cb-btn {
    padding: 5px 6px;
  }
  .console-bar .cb-btn.cb-rerun {
    font-size: 9px;
    padding: 4px 8px;
  }
  .console-bar .cb-toggle {
    font-size: 9px;
    padding: 4px 8px;
  }
}
