    :root {
      --ink: #17211f;
      --muted: #63716e;
      --faint: #87928f;
      --line: #d8e0dd;
      --line-strong: #b8c7c2;
      --page: #f6f8f7;
      --surface: #ffffff;
      --surface-soft: #edf3f1;
      --teal: #0b625c;
      --teal-dark: #073f3b;
      --rust: #a84621;
      --rust-dark: #7d3019;
      --amber: #c98722;
      --mint: #2d8d72;
      --danger: #9c3b35;
      --shadow: 0 18px 48px rgba(19, 31, 28, 0.12);
      --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
      --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

    * { box-sizing: border-box; }
    html, body { min-height: 100%; }
    body {
      margin: 0;
      color: var(--ink);
      background: var(--page);
      font-family: var(--font);
      font-size: 15px;
      line-height: 1.48;
    }
    button, textarea, input, select { font: inherit; }
    button { cursor: pointer; }
    button:disabled, textarea:disabled, input:disabled { cursor: not-allowed; opacity: 0.58; }
    a { color: inherit; }

    .app {
      display: grid;
      height: 100svh;
      min-height: 100svh;
      overflow: hidden;
      grid-template-columns: 310px minmax(0, 1fr) 430px;
      grid-template-rows: minmax(0, 1fr) auto;
      background: linear-gradient(180deg, #fbfcfc 0%, var(--page) 100%);
    }

    .rail, .chat, .workbench { min-width: 0; min-height: 0; background: rgba(255, 255, 255, 0.88); }
    .rail {
      display: flex;
      overflow-x: hidden;
      overflow-y: auto;
      flex-direction: column;
      padding: 1.25rem 1.1rem;
      border-right: 1px solid var(--line);
    }
    .brand { display: flex; align-items: center; gap: 0.78rem; margin-bottom: 1.35rem; text-decoration: none; }
    .brand-mark, .avatar {
      display: grid;
      flex: none;
      place-items: center;
      color: #fff;
      background: linear-gradient(145deg, var(--teal), var(--teal-dark));
      font-weight: 850;
    }
    .brand-mark {
      width: 46px;
      height: 46px;
      border: 2px solid rgba(201, 135, 34, 0.72);
      border-radius: 8px;
      font-size: 1.4rem;
    }
    .brand-text strong { display: block; font-size: 1.12rem; line-height: 1.08; }
    .brand-text span, .small, .hint { color: var(--muted); }
    .section-label {
      margin: 0.9rem 0 0.55rem 0.45rem;
      color: #52625e;
      font-size: 0.75rem;
      font-weight: 820;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }
    .tool-list, .result-list, .patch-list, .tool-log-list { display: grid; gap: 0.48rem; margin: 0; padding: 0; list-style: none; }
    .nav-button, .primary-button, .secondary-button, .ghost-button, .icon-button, .send-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.55rem;
      border-radius: 8px;
      border: 1px solid transparent;
      color: var(--ink);
      background: transparent;
      font-weight: 780;
      text-decoration: none;
      transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
    }
    .nav-button {
      width: 100%;
      min-height: 42px;
      justify-content: flex-start;
      padding: 0.62rem 0.7rem;
      font-weight: 720;
    }
    .nav-button:hover, .ghost-button:hover, .icon-button:hover { border-color: var(--line); background: var(--surface-soft); }
    .nav-button.active { color: #fff; background: linear-gradient(135deg, var(--teal), var(--teal-dark)); box-shadow: 0 12px 26px rgba(11, 98, 92, 0.19); }
    svg { width: 18px; height: 18px; flex: none; stroke-width: 1.9; }
    .primary-button, .secondary-button, .ghost-button { min-height: 40px; padding: 0 0.85rem; white-space: nowrap; }
    .primary-button { color: #fff; background: linear-gradient(135deg, var(--teal), var(--teal-dark)); box-shadow: 0 11px 24px rgba(11, 98, 92, 0.22); }
    .secondary-button { color: #fff; background: linear-gradient(135deg, var(--rust), var(--rust-dark)); box-shadow: 0 10px 22px rgba(168, 70, 33, 0.16); }
    .ghost-button { color: var(--teal-dark); background: #fff; border-color: var(--line); }
    .icon-button { width: 40px; height: 40px; padding: 0; }
    .primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
    .folder-panel, .safety-panel {
      display: grid;
      gap: 0.7rem;
      padding: 0.85rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--surface-soft);
    }
    .folder-name { overflow: hidden; color: var(--teal-dark); font-weight: 820; text-overflow: ellipsis; white-space: nowrap; }
    .stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
    .stat {
      min-width: 0;
      padding: 0.58rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .stat strong { display: block; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
    .stat span { font-weight: 820; }

    .chat {
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
      border-right: 1px solid var(--line);
    }
    .chat-header, .workbench-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding: 1.4rem 1.5rem;
      border-bottom: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.94);
    }
    .chat-title h1, .workbench-header h2 { margin: 0; font-size: 1.42rem; line-height: 1.05; }
    .chat-title p, .workbench-header p { margin: 0.36rem 0 0; color: var(--muted); }
    .header-actions, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; }
    .push-bottom { margin-top: auto; }
    .tool-note { margin-top: 0.55rem; }
    .spread { justify-content: space-between; }
    .messages {
      min-height: 0;
      overflow: auto;
      padding: 1.15rem 1.5rem;
    }
    .message {
      display: grid;
      grid-template-columns: 36px minmax(0, 1fr);
      gap: 0.85rem;
      padding: 1rem 0;
      border-bottom: 1px solid var(--line);
    }
    .avatar { width: 32px; height: 32px; border-radius: 6px; font-size: 0.83rem; }
    .message.ai .avatar { background: linear-gradient(145deg, var(--rust), var(--rust-dark)); }
    .message.tool .avatar { background: linear-gradient(145deg, var(--amber), #8a641a); }
    .message-meta { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-bottom: 0.35rem; font-size: 0.83rem; }
    .message-meta strong { color: var(--teal-dark); }
    .message.ai .message-meta strong { color: var(--rust); }
    .message.tool .message-meta strong { color: #755010; }
    .message-time { color: var(--faint); }
    .message-content { overflow-wrap: anywhere; white-space: pre-wrap; }
    .composer {
      padding: 0.95rem 1.5rem 1.15rem;
      border-top: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.96);
    }
    .composer-box {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 0.85rem;
      align-items: end;
      padding: 0.85rem;
      border: 1px solid var(--teal);
      border-radius: 8px;
      background: #fff;
      box-shadow: 0 8px 22px rgba(11, 98, 92, 0.08);
    }
    .composer textarea {
      width: 100%;
      min-height: 74px;
      max-height: 220px;
      resize: vertical;
      color: var(--ink);
      border: 0;
      outline: 0;
      background: transparent;
      line-height: 1.45;
    }
    .send-button { width: 44px; min-height: 44px; padding: 0; color: #fff; border: 0; background: var(--teal); }

    .workbench {
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
    }
    .workbench-body {
      min-height: 0;
      overflow: auto;
      padding: 1.1rem;
      display: grid;
      gap: 1rem;
      align-content: start;
    }
    .panel {
      display: grid;
      gap: 0.75rem;
      padding: 0.9rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .panel h3 { margin: 0; font-size: 1.02rem; }
    .field { display: grid; gap: 0.42rem; }
    .field label { color: #2d3f3c; font-size: 0.87rem; font-weight: 760; }
    .field input, .field textarea, .field select {
      width: 100%;
      min-height: 40px;
      color: var(--ink);
      border: 1px solid var(--line-strong);
      border-radius: 8px;
      background: #fff;
      outline: 0;
      padding: 0.62rem 0.72rem;
    }
    .field textarea { min-height: 126px; resize: vertical; font-family: var(--mono); font-size: 0.86rem; line-height: 1.45; }
    .field input:focus, .field textarea:focus, .composer-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 98, 92, 0.12); }
    .result-item, .patch-item, .log-item {
      display: grid;
      gap: 0.38rem;
      padding: 0.72rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfc;
    }
    .result-item button {
      padding: 0;
      border: 0;
      color: var(--teal-dark);
      background: transparent;
      font-weight: 820;
      text-align: left;
    }
    .snippet, .preview, .patch-text, .log-text {
      overflow: auto;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      font-family: var(--mono);
      font-size: 0.82rem;
      line-height: 1.42;
    }
    .preview, .patch-text {
      max-height: 240px;
      padding: 0.72rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #f8faf9;
    }
    .patch-text del { color: var(--danger); background: rgba(156, 59, 53, 0.09); text-decoration: none; }
    .patch-text ins { color: var(--teal-dark); background: rgba(45, 141, 114, 0.12); text-decoration: none; }
    .badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
    .badge {
      display: inline-flex;
      min-height: 24px;
      align-items: center;
      padding: 0 0.45rem;
      color: #34433f;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
      font-size: 0.76rem;
      font-weight: 760;
    }
    .status-bar {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: minmax(220px, 1.1fr) repeat(4, minmax(150px, 1fr));
      gap: 1px;
      background: var(--line);
      border-top: 1px solid var(--line);
    }
    .status-item { min-width: 0; padding: 0.86rem 1rem; background: rgba(255, 255, 255, 0.94); }
    .status-item strong { display: block; margin-bottom: 0.24rem; color: #40504c; font-size: 0.72rem; font-weight: 820; letter-spacing: 0.08em; text-transform: uppercase; }
    .status-value { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .status-line { display: flex; align-items: flex-start; gap: 0.5rem; }
    .status-line .status-value { overflow: visible; white-space: normal; text-overflow: clip; line-height: 1.35; }
    .status-bar .footer-legal { margin-top: 0.45rem; white-space: normal; line-height: 1.45; }
    .status-bar .footer-legal a { color: var(--teal-dark); text-underline-offset: 0.15em; }
    .dot { width: 9px; height: 9px; flex: none; border-radius: 999px; background: var(--faint); }
    .dot.available { background: var(--mint); }
    .dot.unavailable, .dot.error { background: var(--danger); }
    .dot.pending { background: var(--amber); }
    .toast {
      position: fixed;
      right: 1rem;
      bottom: 1rem;
      z-index: 50;
      max-width: min(380px, calc(100vw - 2rem));
      padding: 0.82rem 0.95rem;
      color: #fff;
      background: var(--teal-dark);
      border-radius: 8px;
      box-shadow: var(--shadow);
      opacity: 0;
      transform: translateY(12px);
      pointer-events: none;
      transition: opacity 0.2s ease, transform 0.2s ease;
    }
    .toast.visible { opacity: 1; transform: translateY(0); }

    @media (max-width: 1180px) {
      .app { grid-template-columns: 290px minmax(0, 1fr); }
      .workbench { grid-column: 1 / -1; min-height: 620px; border-top: 1px solid var(--line); }
      .status-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }
    @media (max-width: 760px) {
      .app { display: block; height: auto; overflow: visible; }
      .rail { border-right: 0; border-bottom: 1px solid var(--line); }
      .chat { min-height: 760px; border-right: 0; }
      .chat-header, .workbench-header { align-items: flex-start; flex-direction: column; }
      .header-actions, .header-actions .primary-button, .header-actions .ghost-button { width: 100%; }
      .composer-box { grid-template-columns: 1fr; }
      .send-button { width: 100%; }
      .status-bar, .stat-grid { grid-template-columns: 1fr; }
    }
