    :root {
      --bg: #f4f7fb;
      --panel: #ffffff;
      --panel-2: #f8fafc;
      --line: #dbe5f1;
      --line-2: #c7d7ea;
      --text: #0f172a;
      --muted: #5b6b80;
      --accent: #2563eb;
      --accent-2: #0ea5e9;
      --ok: #059669;
      --warn: #d97706;
      --bad: #dc2626;
      --chip: #eef4ff;
      --shadow: 0 18px 40px rgba(15, 23, 42, .08);
      --radius: 16px;
    }
    * { box-sizing: border-box; }
    html, body { margin: 0; min-height: 100%; }
    body {
      font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
      color: var(--text);
      background:
        radial-gradient(circle at 10% 5%, rgba(37,99,235,.08), transparent 36%),
        radial-gradient(circle at 90% 95%, rgba(14,165,233,.07), transparent 40%),
        linear-gradient(180deg, #f7f9fd, #eef3f9);
      overflow-x: hidden;
    }
    body[data-view="panel"] { height: 100dvh; overflow: hidden; }
    .hidden { display: none !important; }
    .wrap { max-width: 1460px; margin: 0 auto; padding: 14px; }
    body[data-view="panel"] .wrap { max-width: none; width: 100%; height: 100dvh; padding: 8px 10px; }
    .auth-shell {
      min-height: calc(100dvh - 36px);
      display: grid;
      place-items: center;
    }
    .auth-grid {
      width: min(1120px, 100%);
      display: grid;
      grid-template-columns: 1.15fr .85fr;
      gap: 16px;
      align-items: stretch;
    }
    .card {
      background: rgba(255,255,255,.94);
      border: 1px solid var(--line);
      border-radius: 22px;
      box-shadow: var(--shadow);
      min-width: 0;
    }
    .auth-brand {
      padding: 22px;
      background:
        radial-gradient(circle at 10% 12%, rgba(37,99,235,.10), transparent 42%),
        radial-gradient(circle at 85% 85%, rgba(14,165,233,.10), transparent 46%),
        linear-gradient(180deg, rgba(255,255,255,.97), rgba(248,250,252,.95));
    }
    .badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      border: 1px solid var(--line-2);
      color: var(--muted);
      background: #fff;
      padding: 6px 10px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 600;
    }
    .badge i {
      width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
      box-shadow: 0 0 0 5px rgba(37,99,235,.12);
    }
    .auth-title { margin: 14px 0 8px; font-size: clamp(24px, 4vw, 40px); line-height: 1.05; }
    .auth-copy { color: var(--muted); line-height: 1.55; font-size: 14px; }
    .auth-list { margin-top: 14px; display: grid; gap: 10px; }
    .auth-item {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(255,255,255,.75);
      padding: 10px 12px;
      font-size: 13px;
      color: var(--muted);
      display: flex;
      gap: 10px;
      align-items: flex-start;
    }
    .auth-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
    .auth-item strong { color: var(--text); }
    .auth-form { padding: 18px; display: grid; gap: 12px; align-content: start; }
    .auth-form h2 { margin: 2px 0; font-size: 18px; }
    .muted { color: var(--muted); }
    .small { font-size: 12px; }
    label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
    input, select, textarea, button {
      font: inherit;
      border-radius: 10px;
      border: 1px solid var(--line-2);
      background: #fff;
      color: var(--text);
    }
    input, select, textarea { width: 100%; padding: 7px 9px; font-size: 12.5px; }
    textarea { min-height: 84px; resize: vertical; }
    button {
      cursor: pointer;
      padding: 0 10px;
      min-height: 28px;
      transition: .16s ease;
      background: #fff;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      font-size: 12px;
      font-weight: 600;
      line-height: 1;
    }
    button:hover { border-color: #9db4d2; }
    button:disabled { opacity: .55; cursor: not-allowed; }
    .btn-primary {
      background: linear-gradient(180deg, #2563eb, #1d4ed8);
      color: #fff;
      border-color: #1d4ed8;
      box-shadow: 0 8px 18px rgba(37,99,235,.16);
    }
    .btn-primary:hover { filter: brightness(1.03); }
    .btn-ghost { background: #fff; color: var(--text); }
    .btn-danger { background: #fff5f5; color: var(--bad); border-color: #fecaca; }
    .btn-soft { background: #f8fbff; color: #1f3f66; }
    .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
    .row > * { min-width: 0; }
    .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
    .grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 10px; }
    .chip {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 6px 10px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line);
      color: #304861; font-size: 12px; font-weight: 600;
    }
    .chip.ok { color: var(--ok); background: #ecfdf5; border-color: #a7f3d0; }
    .chip.bad { color: var(--bad); background: #fef2f2; border-color: #fecaca; }
    .chip.warn { color: var(--warn); background: #fff7ed; border-color: #fed7aa; }
    .auth-banner, .banner {
      min-height: 18px; font-size: 12px;
    }
    .banner.ok { color: var(--ok); }
    .banner.bad { color: var(--bad); }
    .banner.warn { color: var(--warn); }

    .app-shell {
      display: grid;
      grid-template-columns: 280px minmax(0,1fr);
      gap: 8px;
      min-height: calc(100dvh - 16px);
      align-items: stretch;
      transition: grid-template-columns .18s ease;
    }
    .app-shell.sidebar-collapsed {
      grid-template-columns: 80px minmax(0,1fr);
    }
    .sidebar {
      display: flex; flex-direction: column; min-height: 0;
      padding: 10px;
      position: sticky; top: 8px; height: calc(100dvh - 16px);
    }
    .app-shell.sidebar-collapsed .brandtext,
    .app-shell.sidebar-collapsed .sidebar-footer .panel-note,
    .app-shell.sidebar-collapsed .nav-group-title,
    .app-shell.sidebar-collapsed .nav button span:last-child {
      display: none;
    }
    .app-shell.sidebar-collapsed .nav button {
      justify-content: center;
      padding: 8px 6px;
    }
    .brandline { display: flex; gap: 10px; align-items: center; }
    .logo {
      width: 42px; height: 42px; border-radius: 14px;
      display: grid; place-items: center;
      color: #fff; font-weight: 800; letter-spacing: .3px;
      background: linear-gradient(180deg, #2563eb, #0ea5e9);
      box-shadow: 0 12px 24px rgba(37,99,235,.22);
      flex: 0 0 auto;
    }
    .brandtext h1 { margin: 0; font-size: 15px; }
    .brandtext p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
    .nav {
      margin-top: 12px; display: grid; gap: 6px;
      overflow-y: auto; padding-right: 2px; min-height: 0; flex: 1;
    }
    .nav-group {
      display: grid;
      gap: 6px;
    }
    .nav-group-title {
      font-size: 11px;
      color: var(--muted);
      font-weight: 700;
      letter-spacing: .02em;
      text-transform: uppercase;
      padding: 2px 4px;
    }
    .nav-sub { display: grid; gap: 6px; }
    .nav button {
      text-align: left;
      border-radius: 12px;
      padding: 8px 10px;
      border: 1px solid transparent;
      background: transparent;
      font-weight: 600;
      color: #31465e;
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
    }
    .nav button:hover { background: #f7faff; border-color: var(--line); }
    .nav button.active {
      background: linear-gradient(180deg, #eff6ff, #e8f1ff);
      border-color: #bfdbfe;
      color: #1d4ed8;
    }
    .sidebar-footer {
      margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
      display: grid; gap: 8px;
    }
    .sidebar-footer .panel-note {
      font-size: 11px; color: var(--muted); line-height: 1.4;
    }

    .main {
      min-width: 0; display: flex; flex-direction: column; min-height: 0; height: calc(100dvh - 16px); overflow: hidden;
    }
    .main-header {
      position: sticky; top: 8px; z-index: 3;
      display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
      padding: 8px 10px;
      border-radius: 14px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,.86);
      backdrop-filter: blur(8px);
      box-shadow: 0 8px 20px rgba(15,23,42,.05);
      margin-bottom: 8px;
      flex: 0 0 auto;
    }
    .main-header .title { margin: 0; font-size: 16px; }
    .main-header .subtitle { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
    .mobile-tabbar {
      display: none;
      gap: 8px; overflow-x: auto; padding-bottom: 2px;
      width: 100%;
    }
    .mobile-tabbar button {
      white-space: nowrap; border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 700;
      background: #fff; border: 1px solid var(--line);
    }
    .mobile-tabbar button.active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

    .tab-page {
      min-height: 0;
      display: none;
      grid-template-rows: minmax(0,1fr);
      gap: 8px;
      flex: 1 1 auto;
      overflow: hidden;
    }
    .tab-page.active { display: grid; }
    .panel-grid {
      min-height: 0;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 8px;
      align-items: stretch;
      height: 100%;
      overflow: hidden;
    }
    .panel-grid-single {
      max-width: 1160px;
      margin: 0 auto;
      width: 100%;
    }
    #tab-chat .panel-grid {
      grid-template-columns: 1fr;
      grid-template-rows: minmax(0, 1fr);
      align-content: stretch;
      max-width: 1280px;
      margin: 0 auto;
      width: 100%;
    }
    .panel-grid > * { min-width: 0; }
    #tab-chat .panel-grid > .chat-box {
      min-height: clamp(620px, calc(100dvh - 190px), 920px);
      max-height: calc(100dvh - 180px);
    }
    .section {
      min-width: 0;
      display: flex;
      flex-direction: column;
      min-height: 0;
      background: rgba(255,255,255,.94);
      border: 1px solid var(--line);
      border-radius: 14px;
      box-shadow: 0 8px 20px rgba(15,23,42,.04);
      overflow: hidden;
    }
    .section > .section-head {
      padding: 9px 10px;
      border-bottom: 1px solid var(--line);
      display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
    }
    .section > .section-head h2,
    .section > .section-head h3 { margin: 0; font-size: 13px; }
    .section > .section-body { padding: 10px; min-width: 0; min-height: 0; }
    .section.scroll > .section-body { min-height: 0; overflow-y: auto; }

    .chat-layout {
      min-height: 0;
      display: grid;
      grid-template-columns: minmax(0,1fr);
      gap: 12px;
    }
    .chat-box {
      min-height: 0;
      display: grid;
      grid-template-rows: auto minmax(0,1fr) auto;
      gap: 0;
      height: 100%;
    }
    .chat-statusbar {
      padding: 8px 10px;
      border-bottom: 1px solid var(--line);
      display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    }
    .chat-messages {
      min-height: 0;
      overflow-y: auto;
      padding: 10px;
      background:
        radial-gradient(circle at 12% 8%, rgba(37,99,235,.04), transparent 35%),
        radial-gradient(circle at 88% 86%, rgba(14,165,233,.05), transparent 45%),
        linear-gradient(180deg, #fbfdff, #f6f9fc);
      display: grid;
      gap: 8px;
      align-content: start;
      scroll-behavior: smooth;
      min-height: 360px;
    }
    .msg {
      border-radius: 14px;
      border: 1px solid var(--line);
      background: #fff;
      padding: 8px 10px;
      box-shadow: 0 4px 12px rgba(15,23,42,.03);
      max-width: min(1080px, 100%);
      min-width: 0;
    }
    .msg.user { margin-left: auto; background: #eef6ff; border-color: #cfe3ff; }
    .msg.assistant { margin-right: auto; background: #ffffff; }
    .msg-head {
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
      margin-bottom: 6px;
      font-size: 11px;
      color: var(--muted);
    }
    .msg-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
    .msg-role {
      font-weight: 700;
      color: #1f2937;
      border: 1px solid var(--line);
      padding: 2px 7px;
      border-radius: 999px;
      background: #fff;
    }
    .msg.user .msg-role { color: #1d4ed8; border-color: #bfdbfe; background: #f7fbff; }
    .msg-content {
      font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
    }
    .msg-file {
      margin-top: 8px;
      border: 1px dashed var(--line-2);
      background: #fbfdff;
      border-radius: 12px;
      padding: 8px 10px;
      font-size: 12px;
      color: #31465e;
    }
    .msg-actions { display: flex; gap: 6px; align-items: center; }
    .msg-actions button { padding: 4px 8px; border-radius: 10px; font-size: 11px; min-height: 26px; }

    .composer {
      padding: 8px 10px;
      border-top: 1px solid var(--line);
      background: #fff;
      display: grid;
      gap: 10px;
    }
    .composer textarea { min-height: 74px; max-height: 112px; resize: none; overflow-y: auto; line-height: 1.35; }
    .composer-toolbar {
      display: grid;
      grid-template-columns: 1fr auto auto;
      gap: 8px;
      align-items: center;
    }
    .composer-left { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
    .file-pill {
      display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
      border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 6px 10px;
      font-size: 12px;
    }
    .file-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .hidden-input { display: none; }

    .list-scroll {
      max-height: min(58dvh, 460px);
      overflow-y: auto;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
    }
    .list-row {
      display: grid; gap: 6px;
      padding: 8px 10px;
      border-bottom: 1px solid #eef2f7;
      font-size: 12px;
    }
    .list-row:last-child { border-bottom: 0; }
    .list-row .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
    .list-row .content { color: #334155; white-space: pre-wrap; word-break: break-word; }
    .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

    .table { width: 100%; border-collapse: collapse; font-size: 12px; }
    .table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #edf2f7; vertical-align: top; }
    .table th { color: var(--muted); font-weight: 700; }
    .table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }

    .kv-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
    .toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; }
    .toggle input { width: auto; }
    .stack { display: grid; gap: 10px; }
    .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    .mini-toolbar { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
    .btn-icon { width:32px; min-width:32px; padding:0; }
    .friend-columns { display:grid; grid-template-columns: 1fr; gap:8px; align-items:start; }
    .avatar-card { display:flex; gap:10px; align-items:flex-start; }
    .avatar-preview {
      width:68px; height:68px; border-radius:18px; border:1px solid var(--line); background:#f8fafc;
      object-fit:cover; flex:0 0 auto;
    }
    .avatar-fallback {
      width:68px; height:68px; border-radius:18px; border:1px solid var(--line);
      display:grid; place-items:center; background:#eef4ff; color:#1d4ed8; font-weight:700; flex:0 0 auto;
    }
    .friend-row-actions { display:flex; gap:6px; flex-wrap:wrap; }
    .friend-row-actions button { min-height: 28px; padding: 0 8px; font-size: 11px; }
    .friend-col {
      min-width: 0;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
      display: grid;
      grid-template-rows: auto minmax(0,1fr);
      min-height: 0;
    }
    .friend-col-head {
      padding: 8px 10px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      font-size: 12px;
      font-weight: 700;
    }
    .friend-col-body {
      padding: 0;
      min-height: 0;
    }
    .friend-col .list-scroll {
      border: 0;
      border-radius: 0 0 14px 14px;
      max-height: min(48dvh, 360px);
      background: transparent;
    }
    .bot-profile-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 10px;
    }
    .bot-profile-top {
      display: grid;
      grid-template-columns: minmax(0,1fr);
      gap: 10px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
    }
    .bot-meta-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0,1fr));
      gap: 10px;
    }
    .compact-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    .compact-actions button { min-height: 32px; }
    .subtle-box {
      border: 1px solid var(--line);
      background: #fbfdff;
      border-radius: 14px;
      padding: 10px;
    }
    .small-input { min-height: 32px; }
    .bot-avatar-actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
    .bot-avatar-note { font-size:11px; color:var(--muted); }
    .tight-list .list-row { padding: 8px 9px; }

    .manager-picker {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
      padding: 10px;
      display: grid;
      gap: 8px;
    }
    .manager-selected {
      display: flex; gap: 8px; flex-wrap: wrap;
    }
    .manager-chip {
      display: inline-flex; align-items: center; gap: 6px;
      border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8;
      border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 600;
    }
    .manager-chip button { padding: 2px 6px; border-radius: 999px; }

    .empty-state {
      border: 1px dashed var(--line-2);
      border-radius: 14px;
      background: #fbfdff;
      padding: 14px;
      color: var(--muted);
      font-size: 13px;
      text-align: center;
    }
    @media (max-width: 1080px) {
      body[data-view="panel"] .wrap { padding: 8px; }
      .app-shell { grid-template-columns: 1fr; min-height: calc(100dvh - 16px); }
      .sidebar { display: none; }
      .mobile-tabbar { display: flex; }
      .panel-grid { grid-template-columns: 1fr; }
      #tab-chat .panel-grid {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(64dvh, 1fr);
      }
      #tab-chat .panel-grid > .chat-box { min-height: 64dvh; max-height: calc(100dvh - 176px); }
      .friend-columns { grid-template-columns: 1fr; }
      .main-header {
        position: static;
        top: auto;
        margin-bottom: 6px;
      }
      .wrap { padding: 10px; }
      .auth-grid { grid-template-columns: 1fr; }
      .main { height: calc(100dvh - 16px); }
    }
    @media (max-width: 700px) {
      .grid-2, .grid-3, .kv-grid, .composer-toolbar { grid-template-columns: 1fr; }
      .bot-meta-grid { grid-template-columns: 1fr; }
      .chat-messages { padding: 10px; }
      #tab-chat .panel-grid { grid-template-rows: minmax(62dvh, 1fr); }
      #tab-chat .panel-grid > .chat-box { min-height: 62dvh; max-height: calc(100dvh - 170px); }
      .composer { padding: 10px; }
      .msg { max-width: 100%; }
      .main-header { padding: 10px 12px; }
      .section > .section-head, .section > .section-body { padding: 10px 12px; }
      .wrap { padding: 10px; }
      .toolbar { width: 100%; }
      .toolbar > * { flex: 1 1 auto; }
      .toolbar > .chip { flex: 0 0 auto; }
    }
