html, body { height: 100%; margin: 0; overflow: hidden; }
    .xl-app {
      height: 100%;
      min-height: 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
      color: #0f172a;
      background: #f6f8fc;
    }
    .xl-appbar {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 8px 14px;
      background: #fff;
      border-bottom: 1px solid #e2e4e8;
    }
    .xl-appbar-brand {
      font-weight: 700;
      font-size: 15px;
      white-space: nowrap;
    }
    .xl-use-cases {
      font-size: 13px;
      color: #5c5c5c;
      text-decoration: none;
      white-space: nowrap;
    }
    .xl-use-cases:hover { color: #217346; }
    .xl-appbar-meta {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 13px;
      color: #5c5c5c;
    }
    .xl-appbar-auth {
      display: inline-flex;
      align-items: center;
      padding: 5px 12px;
      border-radius: 6px;
      background: #217346;
      color: #fff !important;
      font-weight: 650;
      font-size: 13px;
      text-decoration: none;
    }
    .xl-appbar-auth:hover { background: #1a5c38; }
    .xl-page {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
      overflow: hidden;
      padding: 0.5rem 1rem 0.85rem;
      width: calc(100% - 24px);
      margin: 0 auto;
    }
    .xl-work {
      flex: 1;
      min-height: 0;
      height: auto;
      max-height: none;
      display: flex;
      flex-direction: row;
      align-items: stretch;
      border: 1px solid #c5c5c5;
      background: #fff;
      overflow: hidden;
      position: relative;
      --xl-chat-h: 36vh;
    }
    .xl-chat-expand {
      display: inline-flex;
      align-items: center;
      flex-shrink: 0;
      border: 1px solid #c5c5c5;
      border-radius: 6px;
      background: #fff;
      padding: 4px 10px;
      font-size: 12px;
      cursor: pointer;
    }
    .xl-work.is-chat-expanded .xl-book,
    .xl-work.is-chat-expanded .xl-split {
      display: none;
    }
    .xl-work.is-chat-expanded .xl-chat {
      flex: 1 1 auto;
      width: auto !important;
      max-width: none;
    }
    .xl-rail {
      flex: 0 0 220px;
      width: 220px;
      min-width: 0;
      display: flex;
      flex-direction: column;
      background: #f3f2f1;
      border-right: 1px solid #c5c5c5;
      min-height: 0;
    }
    .xl-work.is-rail-collapsed .xl-rail {
      flex-basis: 48px;
      width: 48px;
    }
    .xl-rail-hd {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 8px 6px;
      flex-shrink: 0;
    }
    .xl-rail-icon {
      width: 32px;
      height: 32px;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: #3d3d3d;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .xl-rail-icon:hover { background: #e6e6e6; }
    .xl-rail-new {
      flex: 1;
      min-width: 0;
      height: 32px;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: #217346;
      font: 650 13px/1 inherit;
      cursor: pointer;
      text-align: left;
      padding: 0 6px;
      overflow: hidden;
      white-space: nowrap;
    }
    .xl-rail-new:hover { background: #e6e6e6; }
    .xl-work.is-rail-collapsed .xl-rail-new {
      display: inline-flex;
      flex: none;
      width: 32px;
      padding: 0;
      justify-content: center;
      font-size: 18px;
      font-weight: 700;
    }
    .xl-work.is-rail-collapsed .xl-rail-hd { flex-direction: column; }
    .xl-rail-list {
      flex: 1;
      overflow: auto;
      padding: 4px 8px 12px;
      min-height: 0;
    }
    .xl-work.is-rail-collapsed .xl-rail-list { display: none; }
    .xl-rail-group {
      margin: 10px 4px 4px;
      font-size: 11px;
      color: #6b6b6b;
      font-weight: 650;
    }
    .xl-rail-item {
      display: flex;
      align-items: center;
      gap: 2px;
      border-radius: 6px;
      min-width: 0;
    }
    .xl-rail-item:hover,
    .xl-rail-item:focus-within { background: #e6e6e6; }
    .xl-rail-item.is-on { background: #fff; }
    .xl-rail-item.is-on:hover,
    .xl-rail-item.is-on:focus-within { background: #fff; }
    .xl-rail-item-open {
      flex: 1;
      min-width: 0;
      text-align: left;
      border: 0;
      border-radius: 6px;
      background: transparent;
      padding: 8px 6px 8px 10px;
      font: 13px/1.3 inherit;
      color: #1f1f1f;
      cursor: pointer;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .xl-rail-item.is-on .xl-rail-item-open { font-weight: 650; }
    .xl-rail-item-rename {
      flex: none;
      display: none;
      border: 0;
      border-radius: 4px;
      background: transparent;
      color: #217346;
      font: 650 11px/1 inherit;
      padding: 4px 6px;
      margin-right: 4px;
      cursor: pointer;
      white-space: nowrap;
    }
    .xl-rail-item-rename:hover { background: #d9eadb; }
    .xl-rail-item-delete {
      flex: none;
      display: none;
      border: 0;
      border-radius: 4px;
      background: transparent;
      color: #c42b1c;
      font: 650 11px/1 inherit;
      padding: 4px 6px;
      margin-right: 4px;
      cursor: pointer;
      white-space: nowrap;
    }
    .xl-rail-item-delete:hover { background: #fde7e9; }
    .xl-rail-item:hover .xl-rail-item-rename,
    .xl-rail-item:focus-within .xl-rail-item-rename,
    .xl-rail-item:hover .xl-rail-item-delete,
    .xl-rail-item:focus-within .xl-rail-item-delete { display: inline-flex; }
    .xl-rail-item-input {
      flex: 1;
      min-width: 0;
      margin: 4px 6px;
      height: 28px;
      border: 1px solid #217346;
      border-radius: 4px;
      padding: 0 8px;
      font: 13px/1.3 inherit;
      background: #fff;
    }
    @media (hover: none) {
      .xl-rail-item.is-on .xl-rail-item-rename,
      .xl-rail-item.is-on .xl-rail-item-delete { display: inline-flex; }
    }
    .xl-rail-mask {
      display: none;
      position: absolute;
      inset: 0;
      z-index: 3;
      border: 0;
      padding: 0;
      background: rgba(15, 23, 42, 0.18);
      cursor: pointer;
    }
    .xl-book {
      flex: 1 1 auto;
      min-width: 360px;
      display: flex;
      flex-direction: column;
      min-height: 0;
      height: 100%;
      max-height: 100%;
      overflow: hidden;
    }
    .xl-split {
      width: 6px;
      flex-shrink: 0;
      cursor: col-resize;
      background: #e4e4e4;
      border-left: 1px solid #c5c5c5;
      border-right: 1px solid #c5c5c5;
    }
    .xl-split:hover,
    .xl-split.is-drag { background: #217346; }
    .xl-fxbar {
      display: flex;
      align-items: stretch;
      border-bottom: 1px solid #c5c5c5;
      background: #f3f2f1;
      flex-shrink: 0;
    }
    .xl-fxbar input {
      border: 0;
      background: #fff;
      height: 32px;
      font: 14px/1.2 Consolas, "Sarasa Mono SC", "Microsoft YaHei", monospace;
      padding: 0 10px;
    }
    #xl-name {
      width: 76px;
      border-right: 1px solid #c5c5c5;
      text-align: center;
      flex-shrink: 0;
    }
    .xl-fx-label {
      width: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      font: italic 15px Georgia, serif;
      color: #217346;
      flex-shrink: 0;
    }
    #xl-fx { flex: 1; min-width: 0; }
    .xl-dl {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      border: 0;
      border-left: 1px solid #1a5c38;
      background: #217346;
      color: #fff;
      padding: 0 14px;
      font-size: 13px;
      font-weight: 650;
      cursor: pointer;
      flex-shrink: 0;
    }
    .xl-dl:hover { background: #1a5c38; }
    .xl-dl svg { flex-shrink: 0; }
    .xl-grid-wrap {
      flex: 1;
      overflow: hidden;
      min-height: 0;
      background: #fff;
    }
    .xl-grid-wrap .jexcel_container {
      display: block;
      width: 100%;
      height: 100%;
      padding-right: 0;
    }
    .xl-grid-wrap .jexcel_content {
      display: block;
      padding-right: 0;
    }
    .xl-grid-wrap .jexcel,
    .xl-grid-wrap .jexcel > tbody > tr > td {
      background-color: #fff;
    }
    .xl-grid-wrap .jexcel > thead > tr > td,
    .xl-grid-wrap .jexcel > tbody > tr > td.jexcel_row {
      background-color: #f3f3f3;
    }
    .xl-tabbar {
      display: flex;
      background: #f3f2f1;
      border-top: 1px solid #c5c5c5;
      min-height: 30px;
      flex-shrink: 0;
    }
    .xl-tab {
      position: relative;
      display: inline-flex;
      align-items: center;
      border: 0;
      border-right: 1px solid #c5c5c5;
      background: transparent;
      padding: 0 22px 0 16px;
      min-height: 30px;
      font-size: 12px;
      cursor: pointer;
    }
    .xl-tab.is-on { background: #fff; border-top: 2px solid #217346; font-weight: 600; }
    .xl-tab-add { color: #217346; font-weight: 700; padding: 0 16px; }
    .xl-tab-close {
      position: absolute;
      top: 1px;
      right: 2px;
      width: 14px;
      height: 14px;
      font-size: 12px;
      line-height: 14px;
      text-align: center;
      color: #8a8a8a;
      border-radius: 2px;
    }
    .xl-tab-close:hover { color: #c42b1c; background: #f3d6d2; }
    .xl-dlg {
      position: fixed;
      inset: 0;
      z-index: 20;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(15, 23, 42, 0.32);
    }
    .xl-dlg[hidden] { display: none; }
    .xl-dlg-card {
      width: min(360px, calc(100vw - 32px));
      background: #fff;
      border: 1px solid #c5c5c5;
      border-radius: 8px;
      padding: 18px 18px 14px;
      box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    }
    .xl-dlg-card h3 {
      margin: 0;
      font-size: 15px;
      font-weight: 650;
      color: #1f1f1f;
    }
    .xl-dlg-card p {
      margin: 10px 0 0;
      font-size: 13px;
      line-height: 1.5;
      color: #3d3d3d;
    }
    .xl-dlg-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 16px;
    }
    .xl-dlg-cancel,
    .xl-dlg-ok {
      border: 0;
      border-radius: 6px;
      height: 30px;
      padding: 0 14px;
      font: 650 12px/1 inherit;
      cursor: pointer;
    }
    .xl-dlg-cancel { background: #eee; color: #3d3d3d; }
    .xl-dlg-cancel:hover { background: #e2e2e2; }
    .xl-dlg-ok { background: #217346; color: #fff; }
    .xl-dlg-ok:hover { background: #1a5c38; }
    .xl-chat {
      flex: 0 0 380px;
      width: 380px;
      min-width: 260px;
      max-width: 56%;
      display: flex;
      flex-direction: column;
      min-height: 0;
      height: 100%;
      max-height: 100%;
      overflow: hidden;
      background: #f7f7f7;
    }
    .xl-chat-hd {
      padding: 0.5rem 0.7rem 0.5rem;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .xl-chat-hd-top {
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
    }
    #xl-chat-title {
      flex: 1;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 0.88rem;
      font-weight: 650;
    }
    .xl-quota {
      flex: none;
      font-weight: 400;
      color: var(--muted);
      font-size: 0.75rem;
      white-space: nowrap;
    }
    .xl-lead {
      margin: 0.35rem 0 0;
      color: var(--muted);
      font-size: 0.75rem;
      font-weight: 400;
      line-height: 1.4;
    }
    .xl-help {
      margin-top: 0.45rem;
      color: #3d3d3d;
      font-size: 0.75rem;
      line-height: 1.5;
      font-weight: 400;
    }
    .xl-help p { margin: 0; }
    .xl-help-toggle {
      display: inline-flex;
      align-items: center;
      gap: 2px;
      border: 0;
      border-radius: 4px;
      background: transparent;
      color: #217346;
      font: 650 12px/1 inherit;
      padding: 4px 6px;
      cursor: pointer;
      flex-shrink: 0;
    }
    .xl-help-toggle:hover { background: #e6e6e6; }
    .xl-help-toggle svg { transition: transform 0.15s ease; }
    .xl-help-toggle.is-open svg { transform: rotate(180deg); }
    #xl-chat-log {
      flex: 1 1 0;
      overflow-x: hidden;
      overflow-y: auto;
      padding: 0.7rem 0.8rem;
      display: flex;
      flex-direction: column;
      gap: 0.55rem;
      min-height: 0;
    }
    .xl-msg { font-size: 0.82rem; line-height: 1.5; padding: 0.5rem 0.6rem; border-radius: 6px; }
    .xl-msg-user { background: var(--primary-soft); align-self: flex-end; max-width: 92%; }
    .xl-msg-ai { background: #fff; border: 1px solid var(--border); }
    .xl-msg-sys { color: var(--muted); font-size: 0.78rem; }
    .xl-msg-sys a { color: #217346; font-weight: 650; }
    .xl-msg-pending {
      color: var(--muted);
      font-style: italic;
      animation: xl-pending-pulse 1.2s ease-in-out infinite;
    }
    @keyframes xl-pending-pulse {
      0%, 100% { opacity: 0.35; }
      50% { opacity: 1; }
    }
    @media (prefers-reduced-motion: reduce) {
      .xl-msg-pending { animation: none; opacity: 0.7; }
    }
    .jexcel td.xl-formula-err,
    .xl-grid-wrap .jexcel > tbody > tr > td.xl-formula-err {
      background: #fde8e8;
    }
    #xl-chat-form {
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
      padding: 0.6rem;
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      background: #fff;
    }
    .xl-attach-list {
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem;
    }
    .xl-attach-chip {
      display: flex;
      align-items: center;
      gap: 0.3rem;
      font-size: 0.75rem;
      background: #eef6f1;
      border: 1px solid #cfe3d6;
      border-radius: 4px;
      padding: 0.15rem 0.35rem;
      max-width: 100%;
    }
    .xl-attach-chip img {
      width: 28px;
      height: 28px;
      object-fit: cover;
      border-radius: 3px;
    }
    .xl-attach-chip button {
      border: 0;
      background: transparent;
      cursor: pointer;
      color: var(--muted);
      font-size: 0.9rem;
      line-height: 1;
    }
    .xl-chat-toolbar {
      display: flex;
      align-items: center;
      gap: 0.35rem;
    }
    .xl-attach-icon {
      width: 32px;
      height: 32px;
      padding: 0;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: #5c5c5c;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .xl-attach-icon:hover { background: #eee; color: #217346; }
    .xl-send {
      margin-left: auto;
      border: 0;
      border-radius: 6px;
      background: #217346;
      color: #fff;
      font: 600 12px/1 inherit;
      height: 28px;
      padding: 0 10px;
      cursor: pointer;
    }
    .xl-send:hover { background: #1a5c38; }
    #xl-chat-input {
      width: 100%;
      min-height: 88px;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 0.5rem 0.6rem;
      font: inherit;
      font-size: 0.85rem;
      line-height: 1.45;
      resize: none;
      min-width: 0;
      box-sizing: border-box;
    }
    .xl-appbar-ws {
      display: none;
      flex-shrink: 0;
      border: 1px solid #e2e4e8;
      border-radius: 6px;
      background: #eef6f1;
      color: #217346;
      font: 650 13px/1 inherit;
      padding: 5px 12px;
      cursor: pointer;
    }
    @media (max-width: 900px) {
      html, body {
        height: auto;
        min-height: 100%;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
      }
      .xl-app {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
      }
      .xl-appbar {
        position: sticky;
        top: 0;
        z-index: 20;
      }
      .xl-page {
        flex: 1 0 auto;
        height: auto;
        min-height: 0;
        overflow: visible;
        width: 100%;
        margin: 0;
        padding: 0;
      }
      .xl-appbar-ws {
        display: inline-flex;
        align-items: center;
      }
      .xl-work {
        flex-direction: column;
        height: auto;
        max-height: none;
        min-height: 0;
        overflow: visible;
        border-left: 0;
        border-right: 0;
      }
      .xl-split { display: none; }
      .xl-book {
        flex: 0 0 auto;
        min-width: 0;
        min-height: 42vh;
        height: auto;
        max-height: none;
      }
      .xl-grid-wrap {
        flex: 1 1 auto;
        min-height: 240px;
        max-height: min(56vh, 480px);
        overflow: auto;
      }
      .xl-grid-wrap .jexcel {
        border-bottom: 0;
      }
      .xl-tabbar {
        flex-shrink: 0;
        border-top: 1px solid #c5c5c5;
      }
      .xl-chat {
        width: auto !important;
        flex: 0 0 auto;
        height: auto;
        min-height: 48vh;
        max-height: none;
        max-width: none;
        overflow: visible;
      }
      #xl-chat-log {
        flex: 0 1 auto;
        max-height: 40vh;
        min-height: 4rem;
      }
      #xl-chat-form {
        padding-bottom: max(0.6rem, env(safe-area-inset-bottom, 0px));
      }
      #xl-chat-input {
        min-height: 56px;
      }
      .xl-work.is-chat-expanded .xl-book { display: none; }
      .xl-work.is-chat-expanded .xl-chat {
        flex: 0 0 auto;
        height: auto;
        min-height: calc(100dvh - 52px);
      }
      .xl-lead { display: none; }
      .xl-chat.is-help-open .xl-lead { display: block; }
      .xl-rail {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 4;
        width: min(280px, 85vw);
        box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
      }
      .xl-work.is-rail-collapsed .xl-rail { display: none; }
      .xl-work:not(.is-rail-collapsed) .xl-rail-mask { display: block; }
    }
