/* ==========================================================================
   Pi Studio — styles
   主题：默认浅色（html[data-theme="light"]），可切换深色（html[data-theme="dark"]）
   ========================================================================== */

/* ------------------------------ 主题变量 -------------------------------- */
:root,
html[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f6fc;
  --bg-2: #eceffa;

  --panel: rgba(255, 255, 255, 0.78);
  --panel-2: rgba(255, 255, 255, 0.9);
  --elev: rgba(255, 255, 255, 0.98);

  --line: rgba(24, 30, 66, 0.1);
  --line-strong: rgba(24, 30, 66, 0.17);

  --text: #191f3d;
  --text-dim: #4e5779;
  --text-mute: #838cab;

  --v: #6d5cf6;
  --c: #0ea5e9;
  --p: #ec4899;
  --g: #10b981;
  --y: #d97706;
  --r: #e11d48;

  --grad: linear-gradient(135deg, #7c6cff, #29c3f6);
  --grad-warm: linear-gradient(135deg, #f472b6, #8b7dff);
  --grad-soft: linear-gradient(135deg, rgba(124, 108, 255, 0.11), rgba(41, 195, 246, 0.09));
  --on-accent: #0d0c22;
  --hero-grad: linear-gradient(135deg, #2a2f52, #6d5cf6 45%, #0ea5e9);

  --hover: rgba(24, 30, 66, 0.055);
  --hover-2: rgba(24, 30, 66, 0.1);
  --sunken: rgba(24, 30, 66, 0.045);
  --chip: rgba(24, 30, 66, 0.05);

  --code-bg: #f4f6fc;
  --code-head: rgba(24, 30, 66, 0.035);
  --code-text: #2a3350;

  --bubble-bg: linear-gradient(135deg, rgba(124, 108, 255, 0.17), rgba(41, 195, 246, 0.11));
  --bubble-line: rgba(124, 108, 255, 0.26);

  --shadow: 0 22px 60px -26px rgba(28, 38, 88, 0.28);
  --shadow-sm: 0 10px 26px -14px rgba(28, 38, 88, 0.24);
  --glow: 0 0 0 1px rgba(124, 108, 255, 0.22), 0 18px 46px -22px rgba(124, 108, 255, 0.45);

  --scroll-thumb: rgba(24, 30, 66, 0.18);
  --scroll-thumb-hover: rgba(24, 30, 66, 0.3);
  --overlay: rgba(28, 36, 72, 0.26);

  --aurora-opacity: 0.3;
  --grain-opacity: 0.02;
  --blob-1: #7c6cff;
  --blob-2: #29c3f6;
  --blob-3: #f472b6;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;

  --sidebar-w: 292px;
  --font: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "PingFang SC",
    "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "SF Mono", ui-monospace, Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #06080f;
  --bg-2: #0a0e1c;

  --panel: rgba(18, 23, 44, 0.62);
  --panel-2: rgba(24, 30, 56, 0.72);
  --elev: rgba(28, 35, 64, 0.94);

  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);

  --text: #e9ecff;
  --text-dim: #a8b0d2;
  --text-mute: #767fa6;

  --v: #8b7dff;
  --c: #43e0ff;
  --p: #ff7ac8;
  --g: #5eead4;
  --y: #fbbf24;
  --r: #fb7185;

  --grad: linear-gradient(135deg, #8b7dff, #43e0ff);
  --grad-warm: linear-gradient(135deg, #ff7ac8, #8b7dff);
  --grad-soft: linear-gradient(135deg, rgba(139, 125, 255, 0.16), rgba(67, 224, 255, 0.1));
  --on-accent: #0a0a18;
  --hero-grad: linear-gradient(135deg, #ffffff, #b9b3ff 40%, #62e6ff);

  --hover: rgba(255, 255, 255, 0.05);
  --hover-2: rgba(255, 255, 255, 0.1);
  --sunken: rgba(0, 0, 0, 0.3);
  --chip: rgba(255, 255, 255, 0.045);

  --code-bg: rgba(6, 8, 16, 0.85);
  --code-head: rgba(255, 255, 255, 0.028);
  --code-text: #cdd6f4;

  --bubble-bg: linear-gradient(135deg, rgba(139, 125, 255, 0.24), rgba(67, 224, 255, 0.13));
  --bubble-line: rgba(139, 125, 255, 0.28);

  --shadow: 0 20px 60px -24px rgba(0, 0, 0, 0.9);
  --shadow-sm: 0 8px 24px -12px rgba(0, 0, 0, 0.8);
  --glow: 0 0 0 1px rgba(139, 125, 255, 0.28), 0 18px 50px -22px rgba(139, 125, 255, 0.6);

  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.24);
  --overlay: rgba(3, 4, 10, 0.62);

  --aurora-opacity: 0.5;
  --grain-opacity: 0.035;
  --blob-1: #5b3df5;
  --blob-2: #0e7fa8;
  --blob-3: #a1267a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}

::selection {
  background: rgba(124, 108, 255, 0.28);
}

/* ------------------------------ aurora ---------------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.aurora .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--aurora-opacity);
  will-change: transform;
  transition: opacity 0.3s ease;
}
.aurora .b1 {
  width: 52vw;
  height: 52vw;
  left: -12vw;
  top: -18vw;
  background: radial-gradient(circle at 30% 30%, var(--blob-1), transparent 68%);
  animation: drift1 26s ease-in-out infinite;
}
.aurora .b2 {
  width: 46vw;
  height: 46vw;
  right: -14vw;
  top: 4vw;
  background: radial-gradient(circle at 60% 40%, var(--blob-2), transparent 68%);
  animation: drift2 32s ease-in-out infinite;
}
.aurora .b3 {
  width: 42vw;
  height: 42vw;
  left: 26vw;
  bottom: -24vw;
  background: radial-gradient(circle at 50% 50%, var(--blob-3), transparent 70%);
  opacity: calc(var(--aurora-opacity) * 0.7);
  animation: drift3 38s ease-in-out infinite;
}
.aurora .grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vw, 4vw, 0) scale(1.08); }
}
@keyframes drift2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.05); }
  50% { transform: translate3d(-5vw, 6vw, 0) scale(0.96); }
}
@keyframes drift3 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-4vw, -5vw, 0) scale(1.1); }
}

/* ------------------------------ layout ---------------------------------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.app.collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}
.app.collapsed .sidebar {
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
}

/* ------------------------------ sidebar --------------------------------- */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 12px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  backdrop-filter: blur(22px) saturate(150%);
  transition: opacity 0.22s, transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s;
  overflow: hidden;
  min-width: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  flex: 1;
  min-width: 0;
}
.brand-mark {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 0 10px rgba(124, 108, 255, 0.5));
  animation: sparkle 6s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.07); }
}
.brand-name {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: 0.2px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 2px 8px;
  margin: 0 -2px;
  min-height: 0;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.ghost-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.ghost-row:hover {
  background: var(--hover);
  color: var(--text);
}
.ghost-row svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.ghost-row kbd {
  margin-left: auto;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  color: var(--text-mute);
  background: var(--chip);
}
.foot-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------ buttons --------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.14s, background 0.16s, box-shadow 0.16s, border-color 0.16s;
  user-select: none;
  white-space: nowrap;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn:hover {
  background: var(--hover-2);
  border-color: var(--line-strong);
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.btn-primary {
  border: 0;
  background: var(--grad);
  color: var(--on-accent);
  font-weight: 700;
  box-shadow: 0 10px 26px -12px rgba(124, 108, 255, 0.7);
}
.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 14px 32px -12px rgba(124, 108, 255, 0.8);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--hover);
  color: var(--text);
}
.btn-danger {
  border-color: rgba(225, 29, 72, 0.32);
  color: var(--r);
  background: rgba(225, 29, 72, 0.09);
}
.btn-danger:hover {
  background: rgba(225, 29, 72, 0.16);
  border-color: rgba(225, 29, 72, 0.5);
}
html[data-theme="dark"] .btn-danger {
  color: #ffc4cd;
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.12);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 9px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex: none;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}
svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 16px;
  height: 16px;
  flex: none;
}
.brand-mark path {
  stroke: none;
}

/* --------------------------- project list ------------------------------- */
.sec-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.p-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
  border: 1px solid transparent;
}
.p-item:hover {
  background: var(--hover);
}
.p-item.active {
  background: var(--grad-soft);
  border-color: rgba(124, 108, 255, 0.26);
  box-shadow: var(--shadow-sm);
}
.p-item.active::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 3px;
  background: var(--grad);
  box-shadow: 0 0 10px rgba(124, 108, 255, 0.7);
}
.p-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 15px;
  flex: none;
  background: var(--chip);
  border: 1px solid var(--line);
}
.p-main {
  flex: 1;
  min-width: 0;
}
.p-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p-sub {
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.p-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.p-item:hover .p-actions {
  opacity: 1;
}
.mini-btn {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--text-mute);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.mini-btn:hover {
  background: var(--hover-2);
  color: var(--text);
}
.mini-btn svg {
  width: 14px;
  height: 14px;
}
.p-tasks {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 6px 14px;
  position: relative;
}
.p-tasks::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}
.t-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px 6px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: background 0.14s, color 0.14s;
  position: relative;
}
.t-item:hover {
  background: var(--hover);
  color: var(--text);
}
.t-item.active {
  background: rgba(124, 108, 255, 0.13);
  color: var(--text);
}
.t-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--text-mute);
  opacity: 0.5;
}
.t-dot.ready {
  background: var(--g);
  opacity: 1;
  box-shadow: 0 0 8px var(--g);
}
.t-dot.running {
  background: var(--c);
  opacity: 1;
  box-shadow: 0 0 8px var(--c);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.t-empty {
  padding: 6px 10px 8px 14px;
  font-size: 12px;
  color: var(--text-mute);
}

/* ------------------------------ topbar ---------------------------------- */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(150%);
  flex: none;
  z-index: 5;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  font-size: 13.5px;
  color: var(--text-dim);
}
.crumb .sep {
  opacity: 0.4;
}
.crumb .c-name {
  color: var(--text);
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb .c-proj {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.crumb .editable {
  cursor: text;
  border-radius: 7px;
  padding: 2px 6px;
  margin: -2px -6px;
  border: 1px dashed transparent;
}
.crumb .editable:hover {
  border-color: var(--line-strong);
  background: var(--hover);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  max-width: 260px;
}
.pill:hover {
  background: var(--hover-2);
  border-color: var(--line-strong);
  color: var(--text);
}
.pill .p-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grad);
  flex: none;
}
.pill .p-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.accent {
  border-color: rgba(124, 108, 255, 0.35);
  background: rgba(124, 108, 255, 0.12);
  color: var(--v);
}
.pill.warn {
  border-color: rgba(217, 119, 6, 0.4);
  background: rgba(217, 119, 6, 0.12);
  color: var(--y);
}

.ctx-ring {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ctx-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.chev svg {
  width: 100%;
  height: 100%;
}
.ctx-ring circle {
  fill: none;
  stroke-width: 3;
}
.ctx-ring .bg {
  stroke: var(--line-strong);
}
.ctx-ring .fg {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.ctx-ring span {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-dim);
  z-index: 1;
}

/* ------------------------------ stage ----------------------------------- */
.stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.scroll-pad {
  max-width: 940px;
  margin: 0 auto;
  padding: 26px 26px 12px;
}
.stage.wide .scroll-pad {
  max-width: 1160px;
}

/* --------------------------- welcome screen ----------------------------- */
.welcome {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  animation: fadeUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.welcome .hero-orb {
  width: 92px;
  height: 92px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  background: var(--grad-soft);
  border: 1px solid rgba(124, 108, 255, 0.26);
  box-shadow: var(--glow);
  margin-bottom: 14px;
  animation: float 7s ease-in-out infinite;
}
.welcome .hero-orb svg {
  width: 46px;
  height: 46px;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
.welcome h1 {
  margin: 0;
  font-size: 33px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--hero-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome p {
  margin: 4px 0 0;
  color: var(--text-dim);
  max-width: 480px;
}
.welcome .hero-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
}
.welcome .recent {
  margin-top: 40px;
  width: 100%;
  max-width: 720px;
  text-align: left;
}
.welcome .recent h3 {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 10px 2px;
  font-weight: 700;
}
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.recent-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s, background 0.16s;
  backdrop-filter: blur(12px);
}
.recent-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 108, 255, 0.35);
  box-shadow: var(--shadow-sm);
}
.recent-card .rc-main {
  min-width: 0;
  flex: 1;
}
.recent-card .rc-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-card .rc-sub {
  font-size: 11.5px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------- project home ------------------------------- */
.proj-home {
  padding: 34px 30px 40px;
  animation: fadeUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.proj-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 6px;
}
.proj-hero .ph-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 27px;
  border: 1px solid var(--line-strong);
  flex: none;
}
.proj-hero h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.3px;
}
.proj-hero .ph-path {
  font-size: 12px;
  color: var(--text-mute);
  font-family: var(--mono);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ph-path span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60ch;
}
.proj-actions {
  display: flex;
  gap: 9px;
  margin: 20px 0 26px;
  flex-wrap: wrap;
}
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 12px;
}
.task-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 15px 16px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.2s;
  overflow: hidden;
}
.task-card:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 108, 255, 0.36);
  box-shadow: var(--shadow-sm);
}
.task-card .tc-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-card .tc-title {
  font-weight: 640;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.task-card .tc-preview {
  font-size: 12.5px;
  color: var(--text-mute);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.task-card .tc-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
}
.task-card .tc-meta .dot-sep {
  opacity: 0.4;
}
.task-card.new-card {
  border-style: dashed;
  border-color: rgba(124, 108, 255, 0.4);
  background: rgba(124, 108, 255, 0.05);
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 118px;
  color: var(--v);
  font-weight: 600;
  gap: 8px;
}
.task-card.new-card:hover {
  background: rgba(124, 108, 255, 0.1);
}
.task-card.new-card svg {
  width: 24px;
  height: 24px;
}

.empty-hint {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-mute);
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
}

/* ------------------------------ chat ------------------------------------ */
.thread {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 20px;
}
.msg {
  animation: fadeUp 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  display: flex;
  justify-content: flex-end;
}
.msg.user .bubble {
  max-width: min(78%, 620px);
  padding: 11px 15px;
  border-radius: 16px 16px 5px 16px;
  background: var(--bubble-bg);
  border: 1px solid var(--bubble-line);
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble img {
  max-width: 100%;
  border-radius: 10px;
  display: block;
  margin-top: 6px;
}

.msg.assistant {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--grad);
  box-shadow: 0 6px 18px -8px rgba(124, 108, 255, 0.7);
  margin-top: 1px;
}
.avatar svg {
  width: 16px;
  height: 16px;
  stroke: var(--on-accent);
  stroke-width: 2.4;
}
.msg.assistant .body {
  flex: 1;
  min-width: 0;
}
.msg.assistant .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 4px;
  height: 18px;
}
.msg.assistant .meta-row .dot-sep {
  opacity: 0.5;
}

/* markdown */
.md {
  word-break: break-word;
  overflow-wrap: anywhere;
}
.md > *:first-child {
  margin-top: 0;
}
.md > *:last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0.55em 0;
}
.md h1, .md h2, .md h3, .md h4 {
  margin: 1.15em 0 0.5em;
  line-height: 1.32;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.md h1 { font-size: 1.5em; }
.md h2 { font-size: 1.28em; }
.md h3 { font-size: 1.12em; }
.md h4 { font-size: 1em; color: var(--text-dim); }
.md ul, .md ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}
.md li {
  margin: 0.24em 0;
}
.md li::marker {
  color: var(--v);
}
.md a {
  color: var(--c);
  text-decoration: none;
  border-bottom: 1px solid rgba(14, 165, 233, 0.35);
}
.md a:hover {
  border-bottom-color: var(--c);
}
.md blockquote {
  margin: 0.7em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid rgba(124, 108, 255, 0.5);
  color: var(--text-dim);
  background: rgba(124, 108, 255, 0.055);
  border-radius: 0 8px 8px 0;
}
.md hr {
  border: 0;
  height: 1px;
  background: var(--line-strong);
  margin: 1.2em 0;
}
.md strong {
  color: var(--text);
  font-weight: 700;
}
.md del {
  opacity: 0.6;
}
.md code.inline {
  font-family: var(--mono);
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(124, 108, 255, 0.11);
  border: 1px solid rgba(124, 108, 255, 0.18);
  color: #5b4bd6;
  white-space: nowrap;
}
html[data-theme="dark"] .md code.inline {
  color: #d7d2ff;
  background: rgba(139, 125, 255, 0.14);
  border-color: rgba(139, 125, 255, 0.2);
}
.md table {
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 13px;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
}
.md th, .md td {
  border: 1px solid var(--line);
  padding: 7px 11px;
  text-align: left;
}
.md th {
  background: var(--chip);
  font-weight: 650;
}
.md tr:nth-child(even) td {
  background: rgba(24, 30, 66, 0.018);
}
html[data-theme="dark"] .md tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.018);
}

/* code block */
.codeblock {
  margin: 0.8em 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--code-bg);
  overflow: hidden;
}
.codeblock .cb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--code-head);
  font-size: 11.5px;
  color: var(--text-mute);
  font-family: var(--mono);
}
.codeblock .cb-head .cb-lang {
  text-transform: lowercase;
}
.codeblock .cb-head .cb-copy {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.codeblock .cb-head .cb-copy:hover {
  background: var(--hover-2);
  color: var(--text);
}
.codeblock .cb-copy.done {
  color: var(--g);
  border-color: rgba(16, 185, 129, 0.4);
}
.codeblock pre {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.8px;
  line-height: 1.65;
  color: var(--code-text);
}
.codeblock pre code {
  font-family: inherit;
  white-space: pre;
}

/* thinking */
.thinking {
  margin: 0 0 6px;
  border-radius: 12px;
  border: 1px solid rgba(124, 108, 255, 0.16);
  background: rgba(124, 108, 255, 0.05);
  overflow: hidden;
}
.thinking summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--v);
  list-style: none;
  user-select: none;
}
.thinking summary::-webkit-details-marker {
  display: none;
}
.thinking summary .chev {
  margin-left: auto;
  transition: transform 0.2s;
  width: 14px;
  height: 14px;
}
.thinking[open] summary .chev {
  transform: rotate(90deg);
}
.thinking .think-body {
  padding: 0 14px 12px;
  font-size: 13px;
  color: var(--text-mute);
  font-style: italic;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px solid rgba(124, 108, 255, 0.12);
  padding-top: 10px;
}

/* tool card */
.tool {
  margin: 8px 0;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  transition: border-color 0.2s;
}
.tool.running {
  border-color: rgba(14, 165, 233, 0.32);
}
.tool.error {
  border-color: rgba(225, 29, 72, 0.32);
}
.tool-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12.8px;
  user-select: none;
}
.tool-head:hover {
  background: var(--hover);
}
.tool-ico {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(124, 108, 255, 0.14);
  color: var(--v);
}
.tool-ico svg {
  width: 14px;
  height: 14px;
}
.tool.running .tool-ico {
  background: rgba(14, 165, 233, 0.14);
  color: var(--c);
}
.tool.error .tool-ico {
  background: rgba(225, 29, 72, 0.14);
  color: var(--r);
}
.tool-name {
  font-weight: 650;
  color: var(--text);
}
.tool-summary {
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.tool-status {
  font-size: 11px;
  color: var(--text-mute);
  flex: none;
}
.tool-spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(14, 165, 233, 0.25);
  border-top-color: var(--c);
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.tool-body {
  display: none;
  border-top: 1px solid var(--line);
  padding: 11px 13px;
  background: var(--sunken);
}
.tool.open .tool-body {
  display: block;
}
.tool-body pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.2px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow: auto;
}
.tool-body .tool-args {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.tool-body .tool-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 8px 0 4px;
  font-weight: 700;
}

/* notice / error */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
}
.notice.error {
  border-color: rgba(225, 29, 72, 0.32);
  background: rgba(225, 29, 72, 0.07);
  color: var(--r);
}
.notice.info {
  border-color: rgba(14, 165, 233, 0.28);
  background: rgba(14, 165, 233, 0.06);
  color: var(--c);
}
html[data-theme="dark"] .notice.error {
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.09);
  color: #ffc9d1;
}
html[data-theme="dark"] .notice.info {
  border-color: rgba(67, 224, 255, 0.28);
  background: rgba(67, 224, 255, 0.07);
  color: #b6ecff;
}
.notice svg {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
}
.notice .n-title {
  font-weight: 650;
  color: inherit;
}
.notice .n-body {
  margin-top: 3px;
  font-size: 12.3px;
  opacity: 0.9;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  vertical-align: text-bottom;
  margin-left: 2px;
  border-radius: 2px;
  background: var(--grad);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0.15; }
}

/* ------------------------------ composer -------------------------------- */
.composer-wrap {
  flex: none;
  padding: 0 24px 18px;
  background: linear-gradient(180deg, transparent, var(--bg) 46%);
}
.composer {
  max-width: 940px;
  margin: 0 auto;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}
.stage.wide ~ .composer-wrap .composer {
  max-width: 1160px;
}
.composer:focus-within {
  border-color: rgba(124, 108, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.1), var(--shadow);
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  max-height: 260px;
  padding: 15px 17px 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
}
.composer textarea::placeholder {
  color: var(--text-mute);
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 10px 16px;
}
.composer-hints {
  font-size: 11.5px;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.composer-hints kbd {
  font-family: var(--font);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--chip);
  color: var(--text-dim);
}
.composer-hints .err {
  color: var(--r);
}
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: var(--on-accent);
  cursor: pointer;
  flex: none;
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
  box-shadow: 0 10px 24px -12px rgba(124, 108, 255, 0.8);
}
.send-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.6);
}
.send-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}
.send-btn.stop {
  background: linear-gradient(135deg, #fb7185, #e11d48);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(225, 29, 72, 0.8);
}
.composer .queue-hint {
  margin: 0 16px;
  padding: 8px 0 0;
  font-size: 11.5px;
  color: var(--y);
  display: flex;
  align-items: center;
  gap: 7px;
}
.attach-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 10px 16px 0;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 11.5px;
  color: var(--text-dim);
}
.attach-chip img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 5px;
}

/* ------------------------------ slash menu ------------------------------ */
.slash-menu {
  position: fixed;
  z-index: 60;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.slash-item.active,
.slash-item:hover {
  background: rgba(124, 108, 255, 0.14);
}
.slash-item .si-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--v);
  font-family: var(--mono);
}
.slash-item .si-desc {
  font-size: 12px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.slash-item .si-src {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-mute);
}

/* ------------------------------ modal ----------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade 0.16s ease;
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  width: 100%;
  max-width: 520px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  box-shadow: var(--shadow), 0 0 0 1px rgba(124, 108, 255, 0.07);
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.2, 1);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
}
.modal.wide {
  max-width: 620px;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 20px 12px;
}
.modal-head h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  flex: 1;
}
.modal-body {
  padding: 4px 20px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 20px 18px;
  justify-content: flex-end;
}
.modal-foot .left {
  margin-right: auto;
}

.field {
  margin-bottom: 15px;
}
.field > label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 11.5px;
  color: var(--text-mute);
  margin-top: 5px;
}
.input,
select.input {
  width: 100%;
  padding: 10px 13px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: rgba(124, 108, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.13);
}
.input.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}
.path-row {
  display: flex;
  gap: 8px;
}
.path-row .input {
  flex: 1;
}
.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.emoji-opt {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, background 0.14s;
}
.emoji-opt:hover {
  transform: translateY(-2px) scale(1.06);
  background: var(--hover-2);
}
.emoji-opt.sel {
  border-color: rgba(124, 108, 255, 0.75);
  background: rgba(124, 108, 255, 0.16);
  box-shadow: 0 0 14px -2px rgba(124, 108, 255, 0.6);
}
.color-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-opt {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.14s;
  position: relative;
}
.color-opt:hover {
  transform: scale(1.12);
}
.color-opt.sel {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.check-row input {
  accent-color: var(--v);
  width: 16px;
  height: 16px;
}

/* folder browser */
.fb-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--sunken);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  word-break: break-all;
}
.fb-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 330px;
  overflow-y: auto;
  background: var(--sunken);
}
.fb-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 13.2px;
  border-bottom: 1px solid var(--line);
}
.fb-row:last-child {
  border-bottom: 0;
}
.fb-row:hover {
  background: rgba(124, 108, 255, 0.1);
}
.fb-row .fb-ico {
  color: var(--y);
  flex: none;
  display: grid;
  place-items: center;
}
.fb-row .fb-ico svg {
  width: 15px;
  height: 15px;
}
.fb-row .fb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fb-empty {
  padding: 22px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
}

/* command palette */
.palette {
  width: 100%;
  max-width: 600px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
  align-self: start;
  margin-top: 8vh;
}
.palette input {
  width: 100%;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.palette-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.pal-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.pal-item.active {
  background: rgba(124, 108, 255, 0.15);
}
.pal-item .pal-ico {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  background: var(--chip);
  flex: none;
}
.pal-item .pal-main {
  flex: 1;
  min-width: 0;
}
.pal-item .pal-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal-item .pal-sub {
  font-size: 11.5px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal-item .pal-kind {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-mute);
  flex: none;
}
.pal-group {
  padding: 10px 12px 5px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
}

/* toasts */
.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 380px;
  padding: 11px 15px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toastIn 0.26s cubic-bezier(0.2, 0.9, 0.2, 1);
  pointer-events: auto;
}
.toast.out {
  animation: toastOut 0.22s ease forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px) scale(0.96); }
}
.toast .t-ico {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(124, 108, 255, 0.16);
  color: var(--v);
}
.toast.ok .t-ico {
  background: rgba(16, 185, 129, 0.16);
  color: var(--g);
}
.toast.err .t-ico {
  background: rgba(225, 29, 72, 0.14);
  color: var(--r);
}
.toast .t-msg {
  flex: 1;
  word-break: break-word;
}

/* context menu */
.ctx-menu {
  position: fixed;
  z-index: 150;
  min-width: 190px;
  padding: 6px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.ctx-item:hover {
  background: rgba(124, 108, 255, 0.14);
  color: var(--text);
}
.ctx-item.danger:hover {
  background: rgba(225, 29, 72, 0.12);
  color: var(--r);
}
.ctx-item svg {
  width: 15px;
  height: 15px;
}
.ctx-sep {
  height: 1px;
  background: var(--line);
  margin: 5px 4px;
}
.ctx-item .k {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.5;
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: content-box;
}

/* ---------------------- 难度选择器 / 统计卡片 --------------------------- */
.think-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.think-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.think-opt:hover {
  background: var(--hover-2);
  transform: translateX(2px);
}
.think-opt.sel {
  border-color: rgba(124, 108, 255, 0.55);
  background: rgba(124, 108, 255, 0.12);
}
.to-radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  flex: none;
  position: relative;
}
.think-opt.sel .to-radio {
  border-color: var(--v);
}
.think-opt.sel .to-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--v);
}
.to-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.to-label {
  font-weight: 650;
  font-size: 13.5px;
}
.to-desc {
  font-size: 11.5px;
  color: var(--text-mute);
}
.to-code {
  font-size: 11px;
  color: var(--text-mute);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--chip);
}
.stat-card.hero {
  grid-column: 1 / -1;
  background: var(--grad-soft);
  border-color: rgba(124, 108, 255, 0.28);
}
.sc-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
}
.sc-value {
  font-size: 19px;
  font-weight: 750;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}
.stat-card.hero .sc-value {
  font-size: 27px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sc-sub {
  font-size: 12px;
  color: var(--text-mute);
}

.pill svg {
  width: 14px;
  height: 14px;
  opacity: 0.85;
}
.pill.accent svg {
  opacity: 1;
}
.usage-pill .p-text {
  font-variant-numeric: tabular-nums;
}
.usage-pill.live {
  border-color: rgba(14, 165, 233, 0.5);
  color: var(--c);
}
.usage-pill.live svg {
  animation: pulse 1.2s ease-in-out infinite;
}

/* ------------------------------ 配色预设 -------------------------------- */
/* 主色 + 浅色底色；深色模式只换主色，保留深色底盘 */

html[data-theme="light"][data-accent="mint"] {
  --bg: #f2faf5;
  --bg-2: #e7f7ed;
  --v: #0f9d76;
  --c: #0d9488;
  --grad: linear-gradient(135deg, #22c55e, #14b8a6);
  --grad-soft: linear-gradient(135deg, rgba(34, 197, 94, 0.13), rgba(20, 184, 166, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(34, 197, 94, 0.16), rgba(20, 184, 166, 0.11));
  --bubble-line: rgba(34, 197, 94, 0.28);
  --hero-grad: linear-gradient(135deg, #1e4638, #16a34a 45%, #0d9488);
  --blob-1: #4ade80;
  --blob-2: #2dd4bf;
  --blob-3: #a7f3d0;
}
html[data-theme="dark"][data-accent="mint"] {
  --v: #34d399;
  --c: #2dd4bf;
  --grad: linear-gradient(135deg, #34d399, #2dd4bf);
  --grad-soft: linear-gradient(135deg, rgba(52, 211, 153, 0.16), rgba(45, 212, 191, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(52, 211, 153, 0.22), rgba(45, 212, 191, 0.13));
  --bubble-line: rgba(52, 211, 153, 0.3);
  --blob-1: #10b981;
  --blob-2: #0d9488;
  --blob-3: #065f46;
}

html[data-theme="light"][data-accent="amber"] {
  --bg: #fdf9ee;
  --bg-2: #faf1dc;
  --v: #b45309;
  --c: #d97706;
  --grad: linear-gradient(135deg, #f59e0b, #fbbf24);
  --grad-soft: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(251, 191, 36, 0.11));
  --bubble-bg: linear-gradient(135deg, rgba(245, 158, 11, 0.17), rgba(251, 191, 36, 0.12));
  --bubble-line: rgba(245, 158, 11, 0.3);
  --hero-grad: linear-gradient(135deg, #4a3410, #d97706 45%, #f59e0b);
  --blob-1: #fbbf24;
  --blob-2: #fcd34d;
  --blob-3: #fdba74;
}
html[data-theme="dark"][data-accent="amber"] {
  --v: #fbbf24;
  --c: #f59e0b;
  --grad: linear-gradient(135deg, #fbbf24, #f59e0b);
  --grad-soft: linear-gradient(135deg, rgba(251, 191, 36, 0.16), rgba(245, 158, 11, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(251, 191, 36, 0.22), rgba(245, 158, 11, 0.13));
  --bubble-line: rgba(251, 191, 36, 0.3);
  --blob-1: #d97706;
  --blob-2: #b45309;
  --blob-3: #92400e;
}

html[data-theme="light"][data-accent="sakura"] {
  --bg: #fdf5f8;
  --bg-2: #fbeaf1;
  --v: #be1e63;
  --c: #db2777;
  --grad: linear-gradient(135deg, #f472b6, #ec4899);
  --grad-soft: linear-gradient(135deg, rgba(244, 114, 182, 0.14), rgba(236, 72, 153, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(244, 114, 182, 0.17), rgba(236, 72, 153, 0.11));
  --bubble-line: rgba(244, 114, 182, 0.3);
  --hero-grad: linear-gradient(135deg, #4d1b33, #db2777 45%, #f472b6);
  --blob-1: #f9a8d4;
  --blob-2: #fda4af;
  --blob-3: #fbcfe8;
}
html[data-theme="dark"][data-accent="sakura"] {
  --v: #f472b6;
  --c: #fb7185;
  --grad: linear-gradient(135deg, #f472b6, #fb7185);
  --grad-soft: linear-gradient(135deg, rgba(244, 114, 182, 0.16), rgba(251, 113, 133, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(244, 114, 182, 0.22), rgba(251, 113, 133, 0.13));
  --bubble-line: rgba(244, 114, 182, 0.3);
  --blob-1: #be185d;
  --blob-2: #9d174d;
  --blob-3: #831843;
}

html[data-theme="light"][data-accent="sky"] {
  --bg: #f1f8fe;
  --bg-2: #e6f2fc;
  --v: #0369a1;
  --c: #0891b2;
  --grad: linear-gradient(135deg, #38bdf8, #0891b2);
  --grad-soft: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(8, 145, 178, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.17), rgba(8, 145, 178, 0.11));
  --bubble-line: rgba(56, 189, 248, 0.3);
  --hero-grad: linear-gradient(135deg, #0c2d48, #0284c7 45%, #38bdf8);
  --blob-1: #7dd3fc;
  --blob-2: #67e8f9;
  --blob-3: #bae6fd;
}
html[data-theme="dark"][data-accent="sky"] {
  --v: #38bdf8;
  --c: #22d3ee;
  --grad: linear-gradient(135deg, #38bdf8, #22d3ee);
  --grad-soft: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(34, 211, 238, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(34, 211, 238, 0.13));
  --bubble-line: rgba(56, 189, 248, 0.3);
  --blob-1: #0284c7;
  --blob-2: #0e7490;
  --blob-3: #075985;
}

html[data-theme="light"][data-accent="lavender"] {
  --bg: #f8f6ff;
  --bg-2: #f0ecfe;
  --v: #6d28d9;
  --c: #9333ea;
  --grad: linear-gradient(135deg, #a78bfa, #8b5cf6);
  --grad-soft: linear-gradient(135deg, rgba(167, 139, 250, 0.15), rgba(139, 92, 246, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(139, 92, 246, 0.11));
  --bubble-line: rgba(167, 139, 250, 0.32);
  --hero-grad: linear-gradient(135deg, #2e1f57, #7c3aed 45%, #a78bfa);
  --blob-1: #c4b5fd;
  --blob-2: #d8b4fe;
  --blob-3: #ddd6fe;
}
html[data-theme="dark"][data-accent="lavender"] {
  --v: #a78bfa;
  --c: #c084fc;
  --grad: linear-gradient(135deg, #a78bfa, #c084fc);
  --grad-soft: linear-gradient(135deg, rgba(167, 139, 250, 0.16), rgba(192, 132, 252, 0.1));
  --bubble-bg: linear-gradient(135deg, rgba(167, 139, 250, 0.22), rgba(192, 132, 252, 0.13));
  --bubble-line: rgba(167, 139, 250, 0.3);
  --blob-1: #7c3aed;
  --blob-2: #6d28d9;
  --blob-3: #5b21b6;
}

/* ---------------------- 侧栏拖动 / 搜索入口 -------------------------- */
.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: transparent;
  border-radius: 2px;
  transition: background 0.15s;
}
.sidebar-resizer:hover::after,
.sidebar-resizer.dragging::after {
  background: var(--v);
}
body.resizing {
  cursor: col-resize;
  user-select: none;
}
body.resizing .app {
  transition: none;
}

.search-trigger {
  justify-content: flex-start;
  font-weight: 500;
  background: var(--sunken);
  border-color: var(--line);
  color: var(--text-mute);
  padding: 8px 13px;
}
.search-trigger:hover {
  color: var(--text);
  background: var(--hover-2);
}

/* ---------------------- 对话内查找 (Ctrl+F) -------------------------- */
.findbar {
  position: absolute;
  top: 68px;
  right: 26px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px 7px 12px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: pop 0.18s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.findbar .fb-ico {
  width: 15px;
  height: 15px;
  color: var(--text-mute);
}
.findbar input {
  width: 210px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
}
.findbar input::placeholder {
  color: var(--text-mute);
}
.find-count {
  font-size: 11.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
  padding-right: 2px;
}
.findbar .icon-btn {
  width: 26px;
  height: 26px;
}
.findbar .icon-btn svg {
  width: 15px;
  height: 15px;
}

mark.find-hit {
  background: rgba(251, 191, 36, 0.45);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
mark.find-hit.current {
  background: var(--v);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.22);
}

/* 搜索跳转时闪一下 */
@keyframes flashHit {
  0% { background: rgba(124, 108, 255, 0.2); }
  100% { background: transparent; }
}
.msg.flash,
.notice.flash {
  animation: flashHit 1.7s ease;
  border-radius: 14px;
}

/* ---------------------- 全局搜索面板 -------------------------- */
.search-panel {
  width: 100%;
  max-width: 780px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
  align-self: start;
  margin-top: 7vh;
  display: flex;
  flex-direction: column;
  max-height: 76vh;
}
.search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.search-head svg {
  width: 17px;
  height: 17px;
  color: var(--text-mute);
}
.search-head input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.search-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.chip {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover {
  background: var(--hover-2);
}
.chip.on {
  border-color: var(--v);
  color: var(--v);
  font-weight: 600;
}
.search-body {
  overflow-y: auto;
  padding: 6px;
  flex: 1;
  min-height: 0;
}
.sr-group {
  margin-bottom: 4px;
}
.sr-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px 5px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.sr-head .sr-emoji {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
  background: var(--chip);
  border: 1px solid var(--line);
}
.sr-head .sr-title {
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.sr-head .sr-proj {
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
}
.sr-hit {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 8px 11px 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.sr-hit:hover,
.sr-hit.active {
  background: var(--hover-2);
}
.sr-role {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  flex: none;
  margin-top: 2px;
  color: var(--text-mute);
}
.sr-role.user {
  border-color: rgba(124, 108, 255, 0.4);
  color: var(--v);
}
.sr-text {
  font-size: 12.8px;
  color: var(--text-dim);
  line-height: 1.6;
  word-break: break-word;
}
.sr-text mark {
  background: rgba(251, 191, 36, 0.5);
  color: var(--text);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}
.sr-empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
}
.sr-foot {
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-mute);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------------------- 外观弹窗 -------------------------- */
.scope-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.scope-opt {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.scope-opt:hover {
  background: var(--hover-2);
}
.scope-opt.sel {
  border-color: var(--v);
  background: var(--grad-soft);
  color: var(--v);
}
.scope-opt svg {
  width: 16px;
  height: 16px;
}
.accent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.accent-opt {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--chip);
  padding: 9px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}
.accent-opt:hover {
  transform: translateY(-2px);
}
.accent-opt.sel {
  border-color: var(--v);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.16);
}
.accent-swatch {
  height: 36px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.accent-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

/* misc */
.only-collapsed {
  display: none;
}
.app.collapsed .only-collapsed {
  display: inline-grid;
}
.spacer {
  flex: 1;
}
.muted {
  color: var(--text-mute);
}
.mono {
  font-family: var(--mono);
}
.nowrap {
  white-space: nowrap;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 0 minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    opacity: 1;
  }
  .app.mobile-open .sidebar {
    transform: none;
    box-shadow: var(--shadow);
  }
  .app.mobile-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--overlay);
  }
  .only-collapsed {
    display: inline-grid;
  }
  .crumb .c-proj {
    display: none;
  }
  .scroll-pad {
    padding: 18px 16px 8px;
  }
  .composer-wrap {
    padding: 0 12px 12px;
  }
  .usage-pill .p-text {
    display: none;
  }
  .pill {
    max-width: 150px;
  }
}
