/* ========================================================================
   Heli — Editorial Warm Theme
   ------------------------------------------------------------------------
   Chat:  Mediterranean cream + terracotta, serif display, calm density
   Admin: Ink-black sidebar + warm ivory canvas, Linear/Vercel B2B feel
   ======================================================================== */

:root {
  color-scheme: light;

  /* Neutrals (warm) */
  --ink: #14130F;
  --ink-2: #2A2823;
  --ink-3: #4A463E;
  --muted: #807A6E;
  --muted-2: #A8A294;
  --line: #E7D8C4;
  --line-strong: #CDB89E;
  --paper: #FBF3E6;       /* canvas */
  --paper-2: #F3E3CE;     /* hover wash */
  --surface: #FFFFFF;     /* card */
  --surface-2: #FFF8EE;

  /* Accent */
  --accent: #B85224;
  --accent-2: #7F3218;
  --accent-soft: #F6DEC6;
  --accent-tint: rgba(184, 82, 36, 0.1);
  --selected-bg: var(--ink);
  --selected-border: var(--ink);
  --selected-fg: var(--paper);
  --chrome-bg: var(--ink);
  --chrome-bg-hover: rgba(250, 246, 236, 0.1);
  --chrome-border: rgba(255, 255, 255, 0.12);
  --chrome-fg: var(--paper);
  --chrome-muted: rgba(250, 246, 236, 0.68);
  --chrome-soft-muted: rgba(250, 246, 236, 0.5);
  --action-bg: var(--ink);
  --action-bg-hover: var(--accent);
  --action-border: var(--ink);
  --action-fg: var(--paper);

  /* Secondary — olive (used sparingly for skill chips) */
  --olive: #6B7A3C;
  --olive-soft: #EFEFD9;

  /* Signal */
  --success: #1F7A4D;
  --success-soft: #DDEFE2;
  --danger:  #B42318;
  --danger-soft: #FBE7E4;
  --warn: #B8761A;
  --warn-soft: #FAEACB;

  /* Code */
  --code-bg: #14130F;
  --code-fg: #ECE5D2;

  /* Type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", ui-serif, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Shadows */
  --shadow-1: 0 1px 0 rgba(20, 19, 15, 0.04), 0 1px 2px rgba(20, 19, 15, 0.04);
  --shadow-2: 0 4px 14px rgba(20, 19, 15, 0.06), 0 1px 2px rgba(20, 19, 15, 0.05);
  --shadow-3: 0 28px 60px rgba(20, 19, 15, 0.18), 0 2px 6px rgba(20, 19, 15, 0.06);
  --user-bubble-shadow: 0 6px 18px rgba(194, 65, 12, 0.22);

  /* Editorial */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08  0 0 0 0 0.07  0 0 0 0 0.06  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }

html, body { height: 100%; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-theme="wechat"] {
  --ink: #111827;
  --ink-2: #1F2937;
  --ink-3: #4B5563;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --line: #DDE3EA;
  --line-strong: #C7D0DA;
  --paper: #F3F5F7;
  --paper-2: #E9EEF2;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;
  --accent: #07C160;
  --accent-2: #05984D;
  --accent-soft: #DDF7E9;
  --accent-tint: rgba(7, 193, 96, 0.12);
  --selected-bg: #DDF7E9;
  --selected-border: #A9E9C7;
  --selected-fg: #047A3E;
  --chrome-bg: #EAF8F0;
  --chrome-bg-hover: #DDF7E9;
  --chrome-border: #C7E7D4;
  --chrome-fg: #163525;
  --chrome-muted: #64746B;
  --chrome-soft-muted: #73847B;
  --action-bg: #07A653;
  --action-bg-hover: #07984D;
  --action-border: #07984D;
  --action-fg: white;
  --user-bubble-shadow: 0 6px 18px rgba(7, 193, 96, 0.22);
  --olive: #10B981;
  --olive-soft: #DCFCE7;
  --warn: #D97706;
  --warn-soft: #FEF3C7;
  --grain: none;
}

body[data-theme="simple"] {
  --ink: #111111;
  --ink-2: #242424;
  --ink-3: #525252;
  --muted: #737373;
  --muted-2: #A3A3A3;
  --line: #E5E5E5;
  --line-strong: #D4D4D4;
  --paper: #FFFFFF;
  --paper-2: #F4F4F4;
  --surface: #FFFFFF;
  --surface-2: #F8F8F8;
  --accent: #3A3A3A;
  --accent-2: #242424;
  --accent-soft: #ECECEC;
  --accent-tint: rgba(17, 17, 17, 0.06);
  --selected-bg: #ECECEC;
  --selected-border: #D4D4D4;
  --selected-fg: #242424;
  --chrome-bg: #F8F8F8;
  --chrome-bg-hover: #EFEFEF;
  --chrome-border: #E5E5E5;
  --chrome-fg: #242424;
  --chrome-muted: #737373;
  --chrome-soft-muted: #8A8A8A;
  --action-bg: #3A3A3A;
  --action-bg-hover: #262626;
  --action-border: #3A3A3A;
  --action-fg: white;
  --olive: #525252;
  --olive-soft: #F0F0F0;
  --warn: #737373;
  --warn-soft: #F2F2F2;
  --grain: none;
  --shadow-1: none;
  --shadow-2: none;
  --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.14);
  --user-bubble-shadow: 0 6px 18px rgba(17, 17, 17, 0.16);
}

/* Refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(20,19,15,0.15) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(20,19,15,0.14); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(20,19,15,0.28); border: 2px solid transparent; background-clip: content-box; }

/* ============ FORM PRIMITIVES ============ */
button, input, textarea, select {
  font: inherit;
  color: var(--ink);
  font-family: var(--font-sans);
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-md);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 100ms ease, box-shadow 140ms ease;
}

button:hover {
  border-color: var(--line-strong);
  background: var(--paper-2);
}

button:active { transform: translateY(1px); }

button.primary {
  background: var(--action-bg);
  border-color: var(--action-border);
  color: var(--action-fg);
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 4px 12px color-mix(in srgb, var(--accent) 18%, transparent);
}
button.primary:hover { background: var(--action-bg-hover); border-color: var(--action-bg-hover); }
button.primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
button.danger-button {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  box-shadow: 0 4px 12px rgba(180, 35, 24, 0.18);
}
button.danger-button:hover {
  background: #941B12;
  border-color: #941B12;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-md);
  padding: 7px 12px;
  text-decoration: none;
  font-weight: 500;
}
.button-link:hover {
  border-color: var(--line-strong);
  background: var(--paper-2);
}

.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  line-height: 1;
}
.btn .btn-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn.icon-only {
  width: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: 999px;
}
.btn.wide-action {
  width: 100%;
}
.btn-ghost {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-1);
}
.btn-danger-soft {
  background: color-mix(in srgb, var(--danger-soft) 58%, var(--surface) 42%);
  border-color: rgba(180, 35, 24, 0.16);
  color: var(--danger);
}
.btn-danger-soft:hover {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.26);
}
.ui-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: currentColor;
}
.ui-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button.icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-grid; place-items: center;
  color: var(--muted);
  border-radius: 999px;
}
button.icon:hover { color: var(--ink); }

.modal-header .icon {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}
.modal-header .icon:hover,
.modal-header .icon:active {
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  transform: none;
}
.modal-header .icon .ui-icon {
  width: 18px;
  height: 18px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 9px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
input:disabled, textarea:disabled, select:disabled {
  background: var(--paper-2);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
  box-shadow: none;
}
input[type="file"] {
  background: var(--surface);
  border-style: dashed;
  cursor: pointer;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select:hover {
  border-color: var(--line-strong);
  background-color: var(--surface-2);
}
select:disabled {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted-2) 50%),
    linear-gradient(135deg, var(--muted-2) 50%, transparent 50%);
}
textarea { min-height: 92px; resize: vertical; }

/* ============ LOGIN ============ */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 12% 0%, rgba(194,65,12,0.10), transparent 55%),
    radial-gradient(800px 500px at 95% 100%, rgba(107,122,60,0.10), transparent 60%),
    var(--paper);
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-3);
  position: relative;
  overflow: hidden;
}
.login-panel::before {
  content: "";
  position: absolute; inset: 0;
  background-image: var(--grain);
  opacity: 0.5;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.login-panel h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 38px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  line-height: 1.05;
}
.login-panel h1 em { color: var(--accent); font-style: italic; }
.login-panel p { margin: 0 0 22px; color: var(--muted); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.field-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ============================================================
   CHAT SHELL
   ============================================================ */
.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 64px 280px minmax(0, 1fr) 312px;
  background: var(--paper);
}

.shell.shell-wide {
  grid-template-columns: 64px minmax(0, 1fr);
}

.shell.shell-no-materials {
  grid-template-columns: 64px 280px minmax(0, 1fr);
}

.shell.conversation-sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr) 312px;
}

.shell.shell-no-materials.conversation-sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.app-rail {
  background: var(--chrome-bg);
  border-right: 1px solid var(--chrome-border);
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  gap: 16px;
}

.rail-brand {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.rail-brand img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.rail-tabs {
  display: grid;
  gap: 8px;
  width: 100%;
}

.rail-tabs-bottom {
  margin-top: auto;
}

.rail-tab {
  width: 48px;
  height: 54px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 6px 0;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--chrome-muted);
  box-shadow: none;
}

.rail-tab:hover,
.rail-tab.active {
  background: var(--chrome-bg-hover);
  border-color: var(--selected-border);
  color: var(--chrome-fg);
}

.rail-tab.active {
  background: var(--selected-bg);
  border-color: var(--selected-border);
  color: var(--selected-fg);
  box-shadow: none;
}

body:is([data-theme=""], :not([data-theme])) .rail-tab:hover,
body:is([data-theme=""], :not([data-theme])) .rail-tab.active {
  background: rgba(250, 246, 236, 0.1);
  border-color: rgba(250, 246, 236, 0.16);
  color: var(--paper);
}

body:is([data-theme=""], :not([data-theme])) .rail-tab.active {
  background: rgba(250, 246, 236, 0.14);
  border-color: rgba(250, 246, 236, 0.22);
}

.rail-tab .ui-icon {
  width: 19px;
  height: 19px;
}

.rail-tab span:not(.ui-icon) {
  font-size: 10.5px;
  line-height: 1;
  font-weight: 500;
  opacity: 0.82;
}

.rail-tab.active span:not(.ui-icon) {
  opacity: 1;
}

.sidebar, .skills {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.skills { border-left: 1px solid var(--line); border-right: 0; }
.skills {
  overflow: visible;
}

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 10px;
  flex-shrink: 0;
}

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

.sidebar-head {
  align-items: flex-start;
  padding-top: 13px;
}

.conversation-sidebar-icon-button.btn.icon-only {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.conversation-sidebar-icon-button:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink);
}

.conversation-sidebar-icon-button .ui-icon {
  width: 19px;
  height: 19px;
}

.brand {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.015em;
  line-height: 1.05;
  color: var(--ink);
}

.sidebar-brand-image {
  display: block;
  width: 58px;
  height: auto;
  object-fit: contain;
}

.user {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  letter-spacing: 0.01em;
}

.conversation-list, .skills-list {
  overflow: auto;
  padding: 12px 10px;
}
.conversation-list { flex: 1; }
.material-panel .skills-list {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.skills-page {
  gap: 16px;
}

.skills-page-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

.skills-page-tabs > button:not(.btn) {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  padding: 6px 2px;
  font-weight: 700;
}

.skills-page-tabs > button:not(.btn):hover,
.skills-page-tabs > button:not(.btn):active {
  background: transparent;
  transform: none;
  color: var(--ink);
}

.skills-page-tabs > button.active {
  color: var(--ink);
}

.skills-page-tabs > button span {
  min-width: 22px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.skills-page-tabs > .btn {
  margin-left: auto;
}

.channels-page {
  padding: 24px;
}

.channel-panel {
  max-width: 980px;
  width: 100%;
}

.channel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.channel-card-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.channel-title {
  font-weight: 750;
  font-size: 16px;
  letter-spacing: 0;
}

.channel-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.channel-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.channel-status.connected {
  background: var(--success-soft);
  color: var(--success);
}

.channel-status.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.channel-body {
  padding: 20px;
}

.channel-empty,
.channel-connected,
.channel-binding {
  display: grid;
  gap: 18px;
}

.channel-empty,
.channel-connected {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.channel-connected {
  grid-template-areas:
    "facts actions"
    "setting actions";
}

.channel-binding {
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
}

.channel-qr {
  width: 260px;
  height: 260px;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
}

.channel-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.channel-copy {
  min-width: 0;
  display: grid;
  gap: 9px;
  color: var(--muted);
  line-height: 1.55;
}

.channel-copy strong {
  color: var(--ink);
  font-size: 15px;
}

.channel-copy label {
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.channel-copy code {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

.channel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  grid-area: actions;
}

.channel-binding .channel-actions {
  grid-column: 2;
  justify-content: flex-start;
}

.channel-facts {
  grid-area: facts;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.channel-setting {
  grid-area: setting;
  justify-self: start;
}

.channel-note {
  grid-area: setting;
  align-self: end;
  justify-self: start;
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.channel-facts div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.channel-facts span,
.channel-facts strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-facts span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.channel-facts strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 13px;
}

.sidebar-material-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-material-tabs .btn {
  justify-content: center;
  min-width: 0;
  background: var(--surface);
  border-color: var(--line);
  box-shadow: none;
}

.sidebar-material-tabs .btn:hover {
  background: var(--paper-2);
}

.sidebar-material-tabs .btn.active {
  background: var(--selected-bg);
  border-color: var(--selected-border);
  color: var(--selected-fg);
}

.sidebar-material-tabs .btn.active .ui-icon {
  color: var(--selected-fg);
}

.skill-group { margin-bottom: 14px; }

.skill-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.skill-empty {
  padding: 8px 10px 12px;
  color: var(--muted-2);
  font-size: 12px;
}

.conversation-item-wrap {
  position: relative;
  margin-bottom: 4px;
}

.conversation-item, .skill-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px 12px;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.conversation-item:hover, .skill-item:hover {
  background: var(--paper-2);
}
.conversation-item.active {
  background: var(--selected-bg);
  border-color: var(--selected-border);
  color: var(--selected-fg);
}
.conversation-item.active .conversation-meta { color: color-mix(in srgb, var(--selected-fg) 68%, transparent); }
.skill-item.active {
  background: var(--accent-soft);
  border-color: rgba(194, 65, 12, 0.18);
  color: var(--accent-2);
}
.optional-skill-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.optional-skill-item.installed {
  border-color: rgba(93, 127, 79, 0.24);
  background: rgba(93, 127, 79, 0.08);
}
.optional-skill-item.conflict {
  opacity: 0.72;
}
.skill-item-main {
  min-width: 0;
}
.skill-item-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.skill-item-actions .btn {
  min-height: 32px;
  padding: 6px 9px;
}

.skill-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 14px 13px;
  box-shadow: var(--shadow-1);
  min-height: 94px;
}

.skill-card:hover {
  border-color: var(--line-strong);
  background: var(--paper-2);
}

.skill-card.active {
  border-color: rgba(194, 65, 12, 0.34);
  background: var(--accent-soft);
}

.skill-card.installed {
  border-color: rgba(93, 127, 79, 0.24);
}

.skill-card.conflict {
  opacity: 0.72;
}

.skill-card-select {
  min-width: 0;
  min-height: 66px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.skill-card-select:hover,
.skill-card-select:active,
.skill-card-select:disabled {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.skill-card-select:disabled {
  cursor: default;
}

.skill-card-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  align-self: center;
  min-width: 78px;
}

.skill-card-action .btn {
  min-height: 36px;
  padding: 7px 10px;
  white-space: nowrap;
}

.skill-section {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.skill-section + .skill-section {
  margin-top: 14px;
}

.skill-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.skill-section-head small {
  color: var(--muted-2);
  font-size: 11px;
}

.skill-section-grid {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.skill-card[data-skill-tooltip]::after {
  content: attr(data-skill-tooltip);
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(100% + 8px);
  z-index: 20;
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-3);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.skills .skill-card[data-skill-tooltip]::after {
  left: auto;
  right: calc(100% + 8px);
  top: 0;
  width: min(320px, calc(100vw - 24px));
}

.skill-card[data-skill-tooltip]:hover::after,
.skill-card[data-skill-tooltip]:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.conversation-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-title, .skill-name {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.skill-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.skill-title-row .skill-name {
  flex: 1;
  min-width: 0;
}

.conversation-title-row .conversation-title {
  flex: 1;
  min-width: 0;
}

.conversation-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 700;
}

.conversation-item.active .conversation-badge {
  background: var(--surface);
  color: var(--accent-2);
}
.conversation-pin-icon {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-items: center;
  color: var(--olive);
}
.conversation-pin-icon .ui-icon,
.conversation-pin-icon .ui-icon svg {
  width: 15px;
  height: 15px;
}
.conversation-item.active .conversation-pin-icon {
  color: var(--accent-2);
}

.conversation-more {
  position: absolute;
  right: 8px;
  top: 7px;
  width: 28px;
  height: 28px;
  padding: 0;
  opacity: 0;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--muted);
}
.conversation-more:hover,
.conversation-more:active {
  background: transparent !important;
  transform: none;
}
.conversation-more .ui-icon,
.conversation-more .ui-icon svg {
  width: 18px;
  height: 18px;
}

.conversation-item-wrap:hover .conversation-more,
.conversation-more:focus-visible,
.conversation-item-wrap:has(.conversation-menu:not([hidden])) .conversation-more {
  opacity: 1;
}

.conversation-item-wrap .conversation-item {
  padding-right: 42px;
}

.conversation-item.active + .conversation-more {
  color: var(--accent-2);
}

.conversation-menu {
  position: absolute;
  right: 8px;
  top: 38px;
  z-index: 10;
  width: 150px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}

.conversation-menu[hidden] { display: none; }
.conversation-menu .btn {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.conversation-menu .danger-menu-action {
  color: var(--danger);
}
.conversation-menu .pin-menu-action .ui-icon {
  color: var(--olive);
}

.conversation-meta, .skill-desc {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 8px;
  overflow: hidden;
}

.skill-desc {
  display: -webkit-box;
  min-height: 34px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.conversation-meta {
  white-space: nowrap;
  text-overflow: ellipsis;
}

.skill-source-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  max-width: 96px;
  height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--olive-soft);
  color: var(--olive);
  font-style: normal;
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.materials-stack {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  overflow: hidden;
}
.materials-stack.split { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
.materials-stack.single { grid-template-rows: minmax(0, 1fr); }

.material-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  overflow: hidden;
}
.material-panel-head {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.material-panel-head small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.drive-mini-toolbar {
  flex-shrink: 0;
  display: grid;
  gap: 8px;
  padding: 10px 10px 6px;
}
.drive-mini-crumbs, .drive-mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.drive-mini-crumbs button, .drive-mini-actions button {
  padding: 6px 8px;
  font-size: 12px;
}
.drive-mini-actions .btn {
  min-height: 31px;
  gap: 5px;
}
.drive-mini-actions .ui-icon {
  width: 14px;
  height: 14px;
}
.drive-mini-error {
  margin: 0 10px 8px;
  padding: 7px 9px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}
.drive-tree-root {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  background: var(--surface);
}
.drive-tree-root span {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
}
.drive-tree-root strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.drive-tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 1px;
  padding: 0 6px 12px;
  font-family: var(--font-sans);
}
.drive-tree-node {
  min-width: 0;
  position: relative;
}
.drive-tree-row {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 28px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  text-align: left;
  background: transparent;
  border-color: transparent;
  border-radius: var(--r-sm);
  padding: 5px 62px 5px calc(8px + var(--depth) * 16px);
  min-height: 32px;
}
.drive-tree-row:hover { background: var(--paper-2); }
.drive-tree-row.selected,
.drive-tree-root.selected { background: var(--accent-soft); border-color: rgba(194, 65, 12, 0.18); }
.drive-tree-row.dragging { opacity: 0.45; }
.drive-tree-row.drag-over,
.drive-tree-root.drag-over,
.drive-tree.drag-over {
  background: var(--olive-soft);
  border-color: rgba(107, 122, 60, 0.28);
}
.drive-tree-chevron {
  color: var(--muted);
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}
.drive-tree-chevron .ui-icon {
  width: 15px;
  height: 15px;
}
.drive-tree-icon,
.drive-tree-thumb {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  overflow: hidden;
  flex: 0 0 auto;
}
.drive-tree-icon.folder {
  color: var(--warn);
  background: var(--warn-soft);
}
.drive-tree-icon.file {
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
}
.drive-tree-icon .ui-icon {
  width: 15px;
  height: 15px;
}
.drive-tree-thumb {
  border: 1px solid var(--line);
  background: var(--surface);
}
.drive-tree-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.file-type-badge {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
}
.drive-tree-file-badge,
.drive-table-file-badge {
  flex: 0 0 auto;
}
.file-type-pdf {
  color: #b42318;
  background: #fff1f0;
  border-color: #f4b8b2;
}
.file-type-excel {
  color: #167044;
  background: #ecfdf3;
  border-color: #abefc6;
}
.file-type-ppt {
  color: #b54708;
  background: #fff4e5;
  border-color: #ffd6a0;
}
.file-type-html {
  color: #c2410c;
  background: #fff7ed;
  border-color: #fed7aa;
}
.file-type-json {
  color: #6941c6;
  background: #f4f3ff;
  border-color: #d9d6fe;
}
.file-type-markdown,
.file-type-text {
  color: #475467;
  background: #f9fafb;
  border-color: #d0d5dd;
}
.file-type-doc {
  color: #175cd3;
  background: #eff8ff;
  border-color: #b2ddff;
}
.file-type-image {
  color: #0e7490;
  background: #ecfeff;
  border-color: #a5f3fc;
}
.file-type-archive {
  color: #854a0e;
  background: #fef7c3;
  border-color: #fde68a;
}
.drive-tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 13px;
}
.drive-tree-meta {
  color: var(--muted);
  font-size: 11px;
}
.drive-tree-delete,
.drive-tree-ref {
  position: absolute;
  top: 4px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 6px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  box-shadow: none;
}
.drive-tree-delete { right: 7px; }
.drive-tree-ref { right: 34px; }
.drive-tree-delete .ui-icon,
.drive-tree-ref .ui-icon {
  width: 14px;
  height: 14px;
}
.drive-tree-node:hover > .drive-tree-delete,
.drive-tree-delete:focus-visible,
.drive-tree-node:hover > .drive-tree-ref,
.drive-tree-ref:focus-visible {
  opacity: 1;
}
.drive-tree-delete:hover {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.18);
  color: var(--danger);
}
.drive-tree-ref:hover {
  background: var(--accent-soft);
  border-color: rgba(194, 65, 12, 0.18);
  color: var(--accent-2);
}
.drive-tree-empty {
  padding: 6px 8px 6px calc(50px + var(--depth) * 16px);
  color: var(--muted);
  font-size: 12px;
}

.profile-menu-wrap {
  margin: 8px 10px 12px;
  position: relative;
  flex-shrink: 0;
}

.app-rail .profile-menu-wrap {
  margin: auto 0 0;
  width: 48px;
}

.profile-card {
  width: 100%;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.profile-card:hover { background: var(--paper-2); }

.app-rail .profile-card {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  box-shadow: none;
}

.app-rail .profile-card:hover {
  background: transparent;
  transform: translateY(0);
}

.app-rail .profile-card .avatar {
  width: 38px;
  height: 38px;
  border-color: var(--chrome-border);
}

.app-rail .profile-card .profile-main {
  display: none;
}

.profile-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 8;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}

.app-rail .profile-menu {
  left: calc(100% + 10px);
  right: auto;
  bottom: 0;
  width: 276px;
}
.profile-menu[hidden] { display: none; }
.profile-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.profile-menu button:hover { background: var(--paper-2); }
.profile-menu-summary {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0;
}

.profile-menu-summary:hover {
  background: var(--paper-2) !important;
}

.profile-menu-summary .avatar.large {
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.profile-menu-summary .profile-name {
  font-size: 14px;
}

.profile-menu .menu-action {
  justify-content: flex-start;
  gap: 8px;
}
.profile-menu .menu-action .ui-icon {
  width: 15px;
  height: 15px;
  color: var(--muted);
}
.profile-menu .danger-menu-action {
  color: var(--danger);
}
.profile-menu .danger-menu-action .ui-icon {
  color: currentColor;
}

.profile-main { min-width: 0; display: grid; gap: 2px; }
.profile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 999px;
  display: inline-grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  font-family: var(--font-serif);
  font-size: 16px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 60px; height: 60px; font-size: 24px; }

/* ============ MAIN CHAT ============ */
.main {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--paper);
  position: relative;
}

.main::before {
  content: "";
  position: absolute; inset: 0;
  background-image: var(--grain);
  opacity: 0.4;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.main > * { position: relative; z-index: 1; }

.main .topbar { background: var(--paper); }
.main .topbar .brand { font-size: 18px; }

.conversation-sidebar-toggle {
  position: absolute;
  top: 17px;
  left: 18px;
  z-index: 3;
}

.conversation-sidebar-collapsed .main .topbar {
  padding-left: 58px;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 32px 24px 8px;
  scroll-behavior: auto;
  overflow-anchor: none;
}

.drive-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 24px 24px;
  gap: 14px;
  overflow: hidden;
}

.drive-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.drive-breadcrumbs, .drive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.drive-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  max-width: 100%;
  min-width: 0;
}

.drive-actions .btn {
  flex: 0 0 auto;
}

.drive-actions .btn-label,
.row-actions .btn-label {
  overflow: visible;
  text-overflow: clip;
}

.drive-crumb {
  background: transparent;
  border-color: transparent;
  padding: 6px 8px;
}
.drive-crumb::after {
  content: "/";
  margin-left: 8px;
  color: var(--muted-2);
}
.drive-crumb:last-child::after { content: ""; margin: 0; }

.drive-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.drive-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

.drive-table th, .drive-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}
.drive-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
}
.drive-table tbody tr[draggable="true"] {
  cursor: grab;
}
.drive-table tbody tr.dragging {
  opacity: 0.45;
}
.drive-table tbody tr.drag-over {
  background: var(--accent-soft);
  outline: 1px solid rgba(194, 65, 12, 0.28);
  outline-offset: -1px;
}
.drive-table tr:last-child td { border-bottom: 0; }

.drive-name {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  padding: 4px 0;
  text-align: left;
  box-shadow: none;
}
.drive-name:hover { background: transparent; color: var(--accent); }
.drive-name .ui-icon { color: var(--muted); width: 17px; height: 17px; }
.drive-name .file-type-badge { flex: 0 0 auto; }

.drive-error { margin: 0; }

.workspace-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 24px 24px;
  gap: 14px;
  overflow: auto;
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tasks-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.tasks-toolbar h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
}
.tasks-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.task-form-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.task-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.task-form-head strong {
  color: var(--ink);
  font-size: 15px;
}
.task-form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(150px, 0.7fr) minmax(180px, 1fr);
  gap: 12px;
}
.task-form-panel textarea {
  resize: vertical;
  min-height: 120px;
}
.task-list {
  display: grid;
  gap: 12px;
}
.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  position: relative;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.task-main {
  min-width: 0;
}
.task-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-right: 370px;
}
.task-title-row strong {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-card p {
  margin: 8px 0 12px;
  padding-right: 370px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-status {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}
.task-status.scheduled,
.task-status.running {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.task-status.paused {
  background: var(--paper-2);
  color: var(--ink-3);
}
.task-status.error {
  background: var(--danger-soft);
  color: var(--danger);
}
.task-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.task-meta-grid span {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-meta-grid b {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.task-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.task-skills span {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 12px;
}
.task-error {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}
.task-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 360px;
}
.task-actions .btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12.5px;
}

.workspace-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
}

.workspace-stat strong {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
}

.workspace-panel {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.skills-workspace .skills-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-content: start;
  gap: 14px;
  padding: 16px;
}

.skills-page > .skills-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 420px));
  align-content: start;
  justify-content: start;
  gap: 12px;
  padding: 0;
  overflow: visible;
}

.skills-workspace .skill-group {
  margin: 0;
  min-width: 0;
}

.workspace-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.workspace-action,
.settings-tile {
  min-height: 92px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 16px;
  text-align: left;
  background: var(--surface);
  border-color: var(--line);
  border-radius: var(--r-lg);
}

.workspace-action .ui-icon,
.settings-tile .ui-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.workspace-action strong,
.workspace-action em,
.settings-tile strong,
.settings-tile em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-action strong,
.settings-tile strong {
  color: var(--ink);
  font-size: 14px;
  font-style: normal;
}

.workspace-action em,
.settings-tile em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.message {
  max-width: 820px;
  margin: 0 auto 26px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  animation: msg-in 360ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 36px; height: 36px;
  border-radius: 999px;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.message-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.message.user .message-avatar { background: var(--accent); color: white; }
.message.assistant .message-avatar { background: var(--ink); color: var(--paper); }
.message.tool .message-avatar { background: var(--olive); color: white; }
.message.system .message-avatar { background: var(--danger); color: white; }

.message-stack { max-width: min(700px, calc(100% - 50px)); min-width: 0; }
.message.user .message-stack { display: grid; justify-items: end; }

.message-label {
  color: var(--muted);
  font-size: 11.5px;
  margin: 0 2px 6px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 13px 16px;
  white-space: pre-wrap;
  line-height: 1.7;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-1);
}

.message.assistant .bubble { border-top-left-radius: 4px; }
.message.user .bubble {
  border-top-right-radius: 4px;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: var(--user-bubble-shadow);
}
.message.tool .bubble {
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.bubble.markdown { white-space: normal; }
.bubble.streaming-text { white-space: pre-wrap; }
.bubble.markdown > :first-child { margin-top: 0; }
.bubble.markdown > :last-child { margin-bottom: 0; }
.bubble.markdown p { margin: 0 0 10px; }
.bubble.markdown h2,
.bubble.markdown h3,
.bubble.markdown h4,
.bubble.markdown h5,
.bubble.markdown h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  margin: 18px 0 10px;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.bubble.markdown h2 { font-size: 22px; }
.bubble.markdown h3 { font-size: 18px; }
.bubble.markdown h4 { font-size: 16px; }
.bubble.markdown h5,
.bubble.markdown h6 {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink-2);
}
.bubble.markdown ul, .bubble.markdown ol { margin: 8px 0 12px; padding-left: 22px; }
.bubble.markdown li { margin: 4px 0; }
.bubble.markdown .task-list {
  list-style: none;
  padding-left: 0;
}
.bubble.markdown .task-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.bubble.markdown .task-list-item input {
  width: 15px;
  height: 15px;
  margin: 5px 0 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.bubble.markdown blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-2);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-style: italic;
  font-family: var(--font-serif);
  font-size: 16px;
}
.bubble.markdown hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}
.bubble.markdown del {
  color: var(--muted);
}
.bubble.markdown mark {
  background: var(--warn-soft);
  color: var(--ink-2);
  border-radius: 4px;
  padding: 0 3px;
}
.bubble.markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
.bubble.markdown pre {
  margin: 12px 0;
  padding: 14px 16px;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--r-md);
  line-height: 1.55;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.bubble.markdown pre code { padding: 0; border: 0; background: transparent; color: inherit; font-size: inherit; }
.bubble.markdown a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin-top: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}
.message:hover .message-actions,
.message:focus-within .message-actions {
  opacity: 1;
  pointer-events: auto;
}
.message.user .message-actions { justify-content: flex-end; }
.message-tool {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.message-tool:hover,
.message-tool:active {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink);
  transform: none;
}
.message-tool .ui-icon {
  width: 17px;
  height: 17px;
}
.message-versions {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}
.message-versions .message-tool {
  width: 24px;
  height: 24px;
  min-height: 24px;
  border: 0;
  background: transparent;
}

@media (hover: none) {
  .message-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.md-table-wrap {
  max-width: 100%;
  overflow: auto;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.bubble.markdown table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bubble.markdown th, .bubble.markdown td {
  padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
.bubble.markdown th { background: var(--paper-2); font-weight: 600; color: var(--ink-2); }
.bubble.markdown tr:last-child td { border-bottom: 0; }
.bubble.markdown img {
  display: block;
  max-width: min(100%, 520px);
  max-height: 360px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.message-refs {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.message-ref {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: min(320px, 100%);
  max-width: 100%;
  padding: 8px;
  border: 1px solid rgba(194, 65, 12, 0.18);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.58);
  color: inherit;
  text-decoration: none;
}
.message-ref:hover {
  border-color: rgba(194, 65, 12, 0.34);
  background: rgba(255, 255, 255, 0.76);
}
.message-ref img,
.message-ref .file-type-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}
.message-ref img {
  object-fit: cover;
}
.message-ref .file-type-badge {
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.message-ref span {
  min-width: 0;
}
.message-ref strong,
.message-ref em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-ref strong {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}
.message-ref em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  font-style: normal;
}
.message-image-ref {
  width: fit-content;
  max-width: min(360px, 100%);
  display: block;
  border: 1px solid rgba(194, 65, 12, 0.18);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-decoration: none;
}
.message-image-ref:hover {
  border-color: rgba(194, 65, 12, 0.38);
  box-shadow: var(--shadow-2);
}
.message-image-ref img {
  display: block;
  max-width: min(360px, 100%);
  max-height: 260px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.drive-inline-link {
  color: var(--accent-2);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.drive-inline-link:hover { color: var(--ink); }

.stream-cursor {
  display: inline-block;
  width: 6px; height: 1em;
  margin-left: 2px;
  vertical-align: -0.14em;
  border-radius: 1px;
  background: var(--accent);
  animation: stream-cursor 900ms steps(2, start) infinite;
}

.loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
  padding: 14px 18px !important;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
}
.loading-bubble i {
  width: 5px; height: 5px;
  border-radius: 999px;
  background: var(--accent);
  animation: loading-dot 1.1s infinite ease-in-out;
  opacity: 0.6;
}
.loading-bubble i:nth-child(3) { animation-delay: 0.18s; }
.loading-bubble i:nth-child(4) { animation-delay: 0.36s; }

@keyframes stream-cursor { 50% { opacity: 0.15; } }
@keyframes loading-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0) scale(0.8); }
  40% { opacity: 1; transform: translateY(-3px) scale(1); }
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Empty state — editorial */
.empty-chat {
  height: 100%;
  min-height: 320px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 56px 32px;
}
.empty-chat::before {
  content: "";
  width: 116px;
  height: 116px;
  border-radius: 28px;
  background: url("/her.jpg") center / cover no-repeat;
  box-shadow: var(--shadow-2);
  margin-bottom: 8px;
}
.empty-title {
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 32px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.empty-title em { color: var(--accent); font-style: italic; }
.empty-subtitle {
  max-width: 420px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.composer { padding: 12px 24px 22px; background: transparent; }
.composer-inner {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow-2);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.composer-inner:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px var(--accent-tint), var(--shadow-2);
}
.composer-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 4px 8px 0;
}
.composer-ref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border-color: rgba(194, 65, 12, 0.18);
  color: var(--accent-2);
  font-size: 12px;
  cursor: default;
}
.composer-ref span {
  color: var(--muted);
  font-weight: 600;
}
.composer-ref strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-ref-remove {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(154, 52, 18, 0.12);
  color: var(--accent-2);
  line-height: 1;
}
.composer-ref-remove .ui-icon {
  width: 12px;
  height: 12px;
}
.composer-ref-remove:hover {
  background: rgba(154, 52, 18, 0.22);
  color: var(--ink);
}
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer-row textarea {
  min-height: 38px; max-height: 200px;
  resize: none;
  border: 0; padding: 8px 4px;
  background: transparent;
  line-height: 1.6;
  font-size: 14.5px;
}
.composer-row textarea:focus { box-shadow: none; }
.composer-row button {
  height: 40px; min-width: 84px;
  flex-shrink: 0;
  border-radius: var(--r-md);
}
.composer-row .send-button .ui-icon {
  width: 17px;
  height: 17px;
}

.error {
  margin-top: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(180, 35, 24, 0.18);
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
}

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 19, 15, 0.46);
  backdrop-filter: blur(6px);
  animation: fade-in 200ms ease;
}
.modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: modal-in 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.wide-modal { width: min(940px, 100%); }
.compact-modal { width: min(480px, 100%); }
.modal-header {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-body { padding: 20px; overflow: auto; }
.profile-preview {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.avatar-upload:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.avatar-upload span {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.avatar-upload strong {
  font-size: 13px;
  color: var(--ink-2);
}
.avatar-upload em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}
.modal-message {
  margin: 0 0 16px;
  color: var(--ink-3);
  line-height: 1.6;
}
.modal-message.danger {
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: var(--r-md);
  background: var(--danger-soft);
  color: var(--danger);
}
.drive-preview-modal .modal-body {
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}
.drive-preview-modal {
  width: min(1100px, calc(100vw - 40px));
  height: min(840px, calc(100vh - 40px));
  max-height: calc(100vh - 40px);
}
.drive-preview-markdown,
.drive-preview-text,
.drive-preview-image,
.drive-preview-frame,
.drive-preview-empty {
  max-height: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  min-height: 0;
}
.drive-preview-markdown {
  padding: 18px;
  line-height: 1.75;
}
.drive-preview-markdown > :first-child { margin-top: 0; }
.drive-preview-markdown > :last-child { margin-bottom: 0; }
.drive-preview-markdown p { margin: 0 0 12px; }
.drive-preview-markdown h1,
.drive-preview-markdown h2,
.drive-preview-markdown h3,
.drive-preview-markdown h4,
.drive-preview-markdown h5,
.drive-preview-markdown h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  margin: 20px 0 10px;
  line-height: 1.2;
}
.drive-preview-markdown h1 { font-size: 28px; }
.drive-preview-markdown h2 { font-size: 23px; }
.drive-preview-markdown h3 { font-size: 19px; }
.drive-preview-markdown h4 { font-size: 16px; }
.drive-preview-markdown h5,
.drive-preview-markdown h6 {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}
.drive-preview-markdown ul,
.drive-preview-markdown ol {
  margin: 8px 0 14px;
  padding-left: 24px;
}
.drive-preview-markdown li { margin: 4px 0; }
.drive-preview-markdown .task-list {
  list-style: none;
  padding-left: 0;
}
.drive-preview-markdown .task-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.drive-preview-markdown .task-list-item input {
  width: 15px;
  height: 15px;
  margin: 6px 0 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.drive-preview-markdown blockquote {
  margin: 14px 0;
  padding: 11px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-2);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.drive-preview-markdown blockquote > :first-child { margin-top: 0; }
.drive-preview-markdown blockquote > :last-child { margin-bottom: 0; }
.drive-preview-markdown hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}
.drive-preview-markdown del { color: var(--muted); }
.drive-preview-markdown mark {
  background: var(--warn-soft);
  color: var(--ink-2);
  border-radius: 4px;
  padding: 0 3px;
}
.drive-preview-markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
.drive-preview-markdown pre {
  margin: 12px 0;
  padding: 14px 16px;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--r-md);
  line-height: 1.55;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.drive-preview-markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}
.drive-preview-markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.drive-preview-markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.drive-preview-markdown th,
.drive-preview-markdown td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.drive-preview-markdown th {
  background: var(--paper-2);
  font-weight: 600;
  color: var(--ink-2);
}
.drive-preview-markdown tr:last-child td { border-bottom: 0; }
.drive-preview-markdown img {
  display: block;
  max-width: min(100%, 760px);
  max-height: 560px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 14px auto;
  border-radius: var(--r-md);
}
.drive-preview-text {
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
}
.drive-preview-image {
  display: grid;
  place-items: center;
  padding: 14px;
}
.drive-preview-image img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
}
.drive-preview-frame {
  width: 100%;
  height: 100%;
}
.drive-preview-modal .modal-actions {
  flex-wrap: wrap;
  margin-top: 0;
}
.drive-preview-empty {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 180px;
  color: var(--muted);
}
.drive-preview-empty strong { color: var(--ink); }
.theme-options {
  display: grid;
  gap: 10px;
}
.theme-option {
  width: 100%;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  text-align: left;
  background: var(--surface-2);
  border-radius: var(--r-lg);
}
.theme-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
}
.theme-option > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.theme-option strong {
  font-size: 13.5px;
  color: var(--ink-2);
}
.theme-option em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.theme-swatches {
  display: flex;
  align-items: center;
}
.theme-swatches i {
  width: 22px;
  height: 22px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line);
}
.theme-swatches i + i { margin-left: -7px; }
[data-theme-option="classic"] .theme-swatches i:nth-child(1) { background: #FBF3E6; }
[data-theme-option="classic"] .theme-swatches i:nth-child(2) { background: #B85224; }
[data-theme-option="classic"] .theme-swatches i:nth-child(3) { background: #14130F; }
[data-theme-option="wechat"] .theme-swatches i:nth-child(1) { background: #F3F5F7; }
[data-theme-option="wechat"] .theme-swatches i:nth-child(2) { background: #07C160; }
[data-theme-option="wechat"] .theme-swatches i:nth-child(3) { background: #EAF8F0; }
[data-theme-option="simple"] .theme-swatches i:nth-child(1) { background: #FFFFFF; }
[data-theme-option="simple"] .theme-swatches i:nth-child(2) { background: #3A3A3A; }
[data-theme-option="simple"] .theme-swatches i:nth-child(3) { background: #F8F8F8; }
.choice-select {
  position: relative;
}
.choice-trigger {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow-1);
}
.choice-trigger::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  justify-self: center;
}
.choice-trigger[aria-expanded="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.choice-trigger span,
.choice-option {
  min-width: 0;
}
.choice-trigger span,
.choice-option span {
  display: block;
  min-width: 0;
}
.choice-trigger strong,
.choice-option strong {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.choice-trigger em,
.choice-option em {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-style: normal;
  font-size: 11.5px;
}
.choice-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, var(--paper) 6%);
  box-shadow: 0 18px 44px rgba(20, 19, 15, 0.16), 0 2px 8px rgba(20, 19, 15, 0.06);
  max-height: 220px;
  overflow: auto;
}
.choice-menu[hidden] { display: none; }
.choice-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.choice-option::after {
  content: "";
  width: 8px;
  height: 12px;
  border-right: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(45deg) translateY(-1px);
  justify-self: center;
}
.choice-option:hover,
.choice-option:focus-visible {
  background: var(--paper-2);
  border-color: var(--line);
  outline: none;
  transform: translateY(-1px);
}
.choice-option.active {
  background: linear-gradient(180deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 74%, var(--surface) 26%));
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line) 72%);
}
.choice-option.active strong {
  color: var(--accent-2);
}
.choice-option.active::after {
  border-color: var(--accent-2);
}
.admin-user-modal {
  width: min(700px, calc(100vw - 40px));
}
.admin-user-modal .modal-body {
  overflow: visible;
}
.admin-user-modal .admin-form {
  overflow: visible;
}
.admin-user-modal .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}
.admin-user-modal .choice-select {
  min-width: 0;
}
.admin-user-modal .choice-trigger {
  min-height: 48px;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 8px;
  padding: 7px 10px;
}
.admin-user-modal .choice-menu {
  min-width: 100%;
  width: max-content;
  max-width: min(280px, calc(100vw - 72px));
}
.admin-user-modal .choice-option {
  min-width: 0;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 18px;
}
.admin-user-modal .choice-trigger strong,
.admin-user-modal .choice-option strong {
  font-size: 12.5px;
  line-height: 1.25;
}
.admin-user-modal .choice-trigger em,
.admin-user-modal .choice-option em {
  font-size: 11px;
  line-height: 1.3;
}
.admin-skill-modal {
  width: min(980px, calc(100vw - 40px));
  max-height: min(840px, calc(100vh - 40px));
}
.admin-skill-modal .modal-body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 14px;
}
.skill-modal-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.skill-modal-summary span {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.skill-modal-summary strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.skill-modal-description {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-2);
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}
.skill-modal-content {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--code-bg);
}
.skill-modal-content-head {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(250, 246, 236, 0.12);
  color: var(--code-fg);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
}
.skill-modal-content-head span {
  color: rgba(236, 229, 210, 0.62);
}
.skill-modal-content pre {
  margin: 0;
  min-height: 420px;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding: 16px 18px;
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.doc-editor {
  min-height: 420px;
  resize: vertical;
  font-family: var(--font-mono);
  line-height: 1.6;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes drawer-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   ADMIN — SaaS B2B (ink sidebar + warm canvas)
   ============================================================ */
.admin-denied {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--paper);
}

.admin-layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--paper);
}

.admin-sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  border-right: 1px solid var(--chrome-border);
  position: relative;
}
.admin-sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.22;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.admin-sidebar > * { position: relative; z-index: 1; }

.admin-sidebar .brand { color: var(--chrome-fg); }
.admin-sidebar .user,
.admin-sidebar .profile-meta { color: var(--chrome-soft-muted); }

.admin-sidebar-head {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--chrome-border);
}

.admin-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent);
  color: white;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 16px rgba(194, 65, 12, 0.32);
}

/* === Sidebar nav: fixed layout, no stretch === */
.admin-nav {
  padding: 12px 10px;
  display: flex;            /* not grid — avoids align-content stretch */
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-nav-item {
  width: 100%;
  height: 40px;             /* fixed, prevents stretch */
  padding: 0 12px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--chrome-muted);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background 120ms ease, color 120ms ease;
  flex: 0 0 auto;           /* never grow */
}
.admin-nav-item .ui-icon {
  width: 16px;
  height: 16px;
  justify-self: center;
  color: var(--chrome-muted);
}
.admin-nav-item:hover .ui-icon,
.admin-nav-item.active .ui-icon {
  color: var(--selected-fg);
}

.admin-nav-item:hover {
  background: var(--chrome-bg-hover);
  color: var(--ink-2);
}

.admin-nav-item.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  border-color: var(--selected-border);
  box-shadow: inset 2px 0 0 var(--accent);
}

body:is([data-theme=""], :not([data-theme])) .admin-sidebar::after {
  opacity: 0.55;
  mix-blend-mode: overlay;
}

body:is([data-theme=""], :not([data-theme])) .admin-nav-item:hover .ui-icon,
body:is([data-theme=""], :not([data-theme])) .admin-nav-item.active .ui-icon {
  color: var(--paper);
}

body:is([data-theme=""], :not([data-theme])) .admin-nav-item:hover {
  background: rgba(250, 246, 236, 0.06);
  color: var(--paper);
}

body:is([data-theme=""], :not([data-theme])) .admin-nav-item.active {
  background: rgba(250, 246, 236, 0.10);
  color: var(--paper);
  border-color: transparent;
}

.admin-nav-item span {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-nav-item strong {
  display: inline;
  font-weight: 500;
  font-size: 13.5px;
  color: inherit;
}
.admin-nav-item em { display: none; }

.admin-nav-item b {
  justify-self: end;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-feature-settings: "tnum";
}
.admin-nav-item.active b {
  background: var(--accent);
  color: white;
}

.admin-sidebar-foot {
  margin-top: auto;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--chrome-border);
  flex-shrink: 0;
}
.admin-sidebar-foot .avatar {
  background: var(--selected-bg);
  color: var(--selected-fg);
}

/* === Admin main area === */
.admin-main {
  min-width: 0; min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.admin-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}

.admin-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

.admin-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.admin-header .top-actions .btn {
  min-height: 36px;
}

.admin-kicker { display: none; }

.admin-content {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

/* Stats grid */
.admin-stats {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  position: relative;
  transition: border-color 140ms ease, transform 160ms ease, box-shadow 140ms ease;
}
.stat-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-card strong {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.stat-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-card.ok strong { color: var(--success); }
.stat-card.bad strong { color: var(--danger); }
.stat-card.ok::before, .stat-card.bad::before {
  content: "";
  position: absolute;
  top: 18px; right: 18px;
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.16);
}
.stat-card.bad::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.16);
}

/* Cards */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.admin-card-header {
  min-height: 64px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}
.admin-card-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.admin-card-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.admin-card-header select { max-width: 240px; width: auto; }
.admin-card-header .btn {
  min-height: 36px;
}

/* Form */
.admin-form {
  padding: 16px 20px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .field { margin-bottom: 0; }
.admin-form .field { margin-bottom: 12px; }
.admin-form .field:last-of-type { margin-bottom: 0; }
.admin-settings-editor { min-height: 260px; }

/* Table */
.table-wrap { overflow: auto; }
.admin-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.admin-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  color: var(--ink-2);
}
.admin-table tbody tr { transition: background 120ms ease; }
.admin-table tbody tr:hover { background: var(--paper-2); }
.conversation-data-table tbody tr { cursor: pointer; }
.conversation-data-table tbody tr.selected {
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
}
.admin-table tbody tr:last-child td { border-bottom: 0; }

.admin-table td strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 420px;
}
.admin-table td span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-mono);
  max-width: 420px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
  text-align: right;
}
.row-actions button {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}
.row-actions .button-link {
  padding: 5px 11px;
  min-height: 30px;
  font-size: 12.5px;
  border-radius: 7px;
}
.row-actions .btn {
  min-height: 30px;
  gap: 5px;
}
.row-actions .ui-icon {
  width: 14px;
  height: 14px;
}

/* Pills / status */
.status, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
}
.status::before, .pill.role-employee::before, .pill.role-admin::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.status.enabled { color: var(--success); background: var(--success-soft); }
.status.disabled { color: var(--danger); background: var(--danger-soft); }
.pill.role-admin { color: var(--accent-2); background: var(--accent-soft); }
.pill.role-employee { color: var(--ink-3); background: var(--paper-2); }

/* Empty panel */
.empty-panel {
  min-height: 160px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
  padding: 36px;
}
.empty-panel strong {
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.01em;
}

/* Skill table specifics */
.admin-skill-filters {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.admin-skill-upload {
  display: grid;
  grid-template-columns: minmax(150px, 0.6fr) minmax(160px, 0.8fr) minmax(220px, 1fr) auto auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.admin-skill-upload .field {
  margin-bottom: 0;
}
.admin-skill-type-select {
  min-height: 39px;
  border-color: color-mix(in srgb, var(--line-strong) 72%, transparent);
  background-color: var(--surface-2);
  color: var(--ink);
  font-weight: 650;
}
.admin-skill-type-select:hover,
.admin-skill-type-select:focus {
  background-color: var(--surface);
}
.admin-skill-folder-input {
  min-height: 39px;
  padding: 5px 8px;
  border-style: solid;
  background: var(--surface-2);
  color: var(--muted);
}
.admin-skill-folder-input:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}
.admin-skill-folder-input::file-selector-button {
  min-height: 27px;
  margin-right: 10px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.admin-skill-folder-input::file-selector-button:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}
.admin-skill-folder-input::file-selector-button:active {
  transform: translateY(1px);
}
.admin-skill-upload .btn {
  align-self: end;
  min-height: 39px;
  white-space: nowrap;
}
.checkbox-line {
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.checkbox-line input {
  width: 16px;
  height: 16px;
}
.admin-skill-filters .field {
  margin-bottom: 0;
}
.admin-skill-filters button {
  min-height: 39px;
  white-space: nowrap;
}
.admin-skill-filters .btn {
  align-self: end;
}
.admin-skill-table {
  min-width: 980px;
  table-layout: fixed;
}
.admin-skill-table .skill-col-category { width: 170px; }
.admin-skill-table .skill-col-name { width: 320px; }
.admin-skill-table .skill-col-description { width: auto; }
.admin-skill-table .skill-col-user { width: 170px; }
.admin-skill-table .skill-col-action { width: 110px; }
.admin-skill-table td.skill-body {
  position: relative;
}
.admin-skill-table td.skill-body > .skill-description-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0;
}
.admin-skill-table td strong[title],
.admin-skill-table td span[title],
.admin-skill-table .category-tag[title] {
  cursor: help;
}
.admin-skill-table td.skill-body[data-tooltip] {
  cursor: help;
}
.admin-skill-table td.skill-body[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: max-content;
  max-width: min(520px, 62vw);
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(20, 19, 15, 0.96);
  color: var(--paper);
  box-shadow: var(--shadow-3);
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.admin-skill-table td.skill-body[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 18px;
  bottom: calc(100% + 4px);
  z-index: 21;
  width: 10px;
  height: 10px;
  background: rgba(20, 19, 15, 0.96);
  transform: rotate(45deg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}
.admin-skill-table td.skill-body[data-tooltip]:hover::after,
.admin-skill-table td.skill-body[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateY(0);
}
.admin-skill-table td.skill-body[data-tooltip]:hover::before {
  transform: rotate(45deg);
}
.admin-skill-table td.skill-body pre {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.admin-skill-table td details { cursor: pointer; }
.admin-skill-table td details summary {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.admin-skill-table td details summary::-webkit-details-marker { display: none; }
.admin-skill-table td details summary::after {
  content: "→";
  transition: transform 200ms ease;
  font-family: var(--font-serif);
  font-size: 14px;
}
.admin-skill-table td details[open] summary::after { transform: rotate(90deg); }
.admin-skill-table td details[open] summary { margin-bottom: 4px; }

.conversation-data-table { min-width: 1120px; }
.admin-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}
.admin-mode-badge.image {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line) 74%);
  background: var(--accent-soft);
  color: var(--accent-2);
}
.admin-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
  background: rgba(20, 19, 15, 0.34);
  animation: fade-in 160ms ease;
}
.admin-conversation-drawer {
  width: min(900px, calc(100vw - 36px));
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px rgba(20, 19, 15, 0.24);
  animation: drawer-in 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.admin-drawer-header {
  flex: 0 0 auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.admin-drawer-header .brand {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.15;
}
.admin-drawer-header .user {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.admin-drawer-summary {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.admin-drawer-summary span {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-drawer-summary strong {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.admin-drawer-body {
  height: calc(100vh - 154px);
  height: calc(100dvh - 154px);
  min-height: 0;
  max-height: calc(100vh - 154px);
  max-height: calc(100dvh - 154px);
  flex: 0 0 auto;
  overflow-x: hidden !important;
  overflow-y: scroll !important;
  overscroll-behavior: contain;
  padding: 18px 22px 28px;
  display: block;
}
.admin-conversation-message {
  min-width: 0;
  display: block;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.admin-message-head {
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.admin-message-head span:not(.pill) {
  min-width: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-conversation-message pre,
.admin-message-content {
  display: block;
  min-width: 0;
  min-height: 54px;
  max-height: 280px;
  margin: 0;
  padding: 14px 16px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  background: var(--surface);
}
.admin-message-images {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding: 0 16px 14px;
}
.admin-message-image {
  display: block;
  height: clamp(180px, 42vh, 420px);
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper-2);
}
.admin-message-image img {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: contain;
  display: block;
}
.message-data-table { min-width: 980px; }
.message-data-table tbody td { vertical-align: top; }
.message-content-cell { min-width: 360px; max-width: 680px; }
.message-content-cell pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.admin-message-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 14px;
}
.admin-message-ref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}
.admin-message-ref strong {
  flex: 0 0 auto;
  color: var(--accent-2);
}
.admin-message-ref span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--olive);
  background: var(--olive-soft);
  border: 1px solid rgba(107, 122, 60, 0.18);
  font-family: var(--font-mono);
}

/* Audit message */
.audit-message {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.audit-message strong { margin-right: 8px; color: var(--ink); font-weight: 600; }
.audit-message span { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.audit-message pre {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: var(--paper-2);
  border-radius: var(--r-md);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-sans);
  line-height: 1.6;
  font-size: 13px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1180px) {
  .admin-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-user-modal .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-skill-upload,
  .admin-skill-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-form-grid,
  .task-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 56px 240px minmax(0, 1fr); }
  .shell.shell-wide,
  .shell.shell-no-materials { grid-template-columns: 56px minmax(0, 1fr); }
  .shell.conversation-sidebar-collapsed,
  .shell.shell-no-materials.conversation-sidebar-collapsed { grid-template-columns: 56px minmax(0, 1fr); }
  .skills { display: none; }
  .rail-tab { width: 42px; }
  .admin-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .admin-user-modal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-card { grid-template-columns: 1fr; }
  .channel-binding,
  .channel-empty,
  .channel-connected {
    grid-template-columns: 1fr;
  }
  .channel-binding .channel-actions {
    grid-column: auto;
  }
  .channel-facts {
    grid-template-columns: 1fr;
  }
  .task-title-row,
  .task-card p { padding-right: 0; }
  .task-actions {
    position: static;
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 720px) {
  .shell,
  .shell.shell-wide,
  .shell.shell-no-materials,
  .shell.conversation-sidebar-collapsed,
  .shell.shell-no-materials.conversation-sidebar-collapsed { grid-template-columns: 56px minmax(0, 1fr); }
  .sidebar { display: none; }
  .app-rail { padding: 10px 6px; }
  .rail-brand { width: 40px; height: 34px; font-size: 22px; }
  .rail-tab { width: 42px; height: 50px; }
  .app-rail .profile-menu-wrap,
  .app-rail .profile-card { width: 42px; }
  .app-rail .profile-card { height: 42px; }
  .app-rail .profile-card .avatar { width: 36px; height: 36px; }
  .app-rail .profile-menu { width: min(276px, calc(100vw - 74px)); }
  .drive-view, .workspace-view { padding: 14px; }
  .channel-card-head,
  .channel-body {
    padding: 14px;
  }
  .channel-qr {
    width: min(260px, 100%);
    height: auto;
    aspect-ratio: 1;
  }
  .task-form-grid,
  .task-meta-grid { grid-template-columns: 1fr; }
  .drive-actions, .drive-actions button, .drive-actions .button-link { width: 100%; }
  .drive-toolbar { align-items: stretch; }
  .admin-layout {
    height: auto; min-height: 100vh;
    grid-template-columns: 1fr;
  }
  .admin-sidebar { min-height: auto; }
  .admin-sidebar-head, .admin-sidebar-foot { display: none; }
  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }
  .admin-nav-item { min-width: 130px; }
  .admin-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }
  .admin-content { padding: 14px; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-card-header { align-items: flex-start; flex-direction: column; }
  .admin-skill-upload,
  .admin-skill-filters { grid-template-columns: 1fr; }
  .admin-user-modal {
    width: min(100%, calc(100vw - 28px));
  }
  .admin-user-modal .form-grid {
    grid-template-columns: 1fr;
  }
  .skill-modal-summary {
    grid-template-columns: 1fr;
  }
  .admin-skill-modal .modal-body {
    padding: 14px;
  }
  .skill-modal-content pre {
    min-height: 320px;
  }
  .admin-card-header select, .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
}
