    :root {
      --ink: #17211f;
      --muted: #63716e;
      --faint: #87928f;
      --line: #d8e0dd;
      --line-strong: #b8c7c2;
      --page: #f6f8f7;
      --surface: #ffffff;
      --surface-soft: #edf3f1;
      --teal: #0b625c;
      --teal-dark: #073f3b;
      --teal-soft: #dff1ee;
      --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,
    select {
      cursor: pointer;
    }

    button:disabled,
    select:disabled,
    textarea:disabled {
      cursor: not-allowed;
      opacity: 0.58;
    }

    a {
      color: inherit;
    }

    .app {
      display: grid;
      height: 100svh;
      min-height: 100svh;
      overflow: hidden;
      grid-template-columns: 300px minmax(0, 1fr) 380px;
      grid-template-rows: minmax(0, 1fr) auto;
      background:
        radial-gradient(circle at 6% 9%, rgba(45, 141, 114, 0.08), transparent 30rem),
        linear-gradient(180deg, #fbfcfc 0%, var(--page) 100%);
    }

    .rail,
    .lab {
      min-width: 0;
      background: rgba(255, 255, 255, 0.82);
      backdrop-filter: blur(12px);
    }

    .rail {
      display: flex;
      min-height: 0;
      overflow-x: hidden;
      overflow-y: auto;
      flex-direction: column;
      padding: 1.35rem 1.15rem;
      border-right: 1px solid var(--line);
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 0.78rem;
      margin-bottom: 1.8rem;
    }

    .brand-mark,
    .avatar {
      display: grid;
      flex: none;
      place-items: center;
      color: #fff;
      background: linear-gradient(145deg, var(--teal), var(--teal-dark));
      box-shadow: 0 9px 22px rgba(11, 98, 92, 0.18);
      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;
      letter-spacing: 0;
    }

    .brand-text strong {
      display: block;
      font-size: 1.15rem;
      line-height: 1.08;
    }

    .brand-text span,
    .small,
    .hint {
      color: var(--muted);
    }

    .section-label {
      margin: 0 0 0.55rem 0.55rem;
      color: #52625e;
      font-size: 0.75rem;
      font-weight: 820;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .session-label {
      margin-bottom: 0;
    }

    .compact-button {
      min-height: 32px;
    }

    .tool-list,
    .session-list,
    .prompt-list {
      display: grid;
      gap: 0.45rem;
      margin: 0;
      padding: 0;
      list-style: none;
    }

    .tool-button,
    .session-button,
    .icon-button,
    .tab-button,
    .primary-button,
    .secondary-button,
    .ghost-button {
      border-radius: 8px;
      border: 1px solid transparent;
      color: var(--ink);
      background: transparent;
      transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
    }

    .tool-button,
    .session-button {
      display: flex;
      width: 100%;
      min-height: 42px;
      align-items: center;
      gap: 0.72rem;
      padding: 0.62rem 0.7rem;
      text-align: left;
    }

    .tool-button svg,
    .session-button svg,
    .icon-button svg,
    .send-button svg,
    .tab-button svg,
    .primary-button svg,
    .secondary-button svg,
    .ghost-button svg {
      width: 18px;
      height: 18px;
      flex: none;
      stroke-width: 1.9;
    }

    .tool-button:hover,
    .session-button:hover,
    .icon-button:hover,
    .tab-button:hover,
    .secondary-button:hover,
    .ghost-button:hover {
      border-color: var(--line);
      background: rgba(237, 243, 241, 0.86);
    }

    .tool-button.active,
    .session-button.active {
      color: #fff;
      background: linear-gradient(135deg, var(--teal), var(--teal-dark));
      box-shadow: 0 12px 26px rgba(11, 98, 92, 0.19);
    }

    .tool-button.active svg,
    .session-button.active svg {
      color: #fff;
    }

    .rail-divider {
      height: 1px;
      margin: 1.1rem 0;
      background: var(--line);
    }

    .rail-spacer {
      flex: 1;
      min-height: 1rem;
    }

    .session-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
    }

    .session-title {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .session-time {
      flex: none;
      color: var(--faint);
      font-size: 0.78rem;
    }

    .privacy-note {
      display: grid;
      gap: 0.5rem;
      padding: 0.85rem;
      color: #2d403c;
      background: var(--surface-soft);
      border: 1px solid var(--line);
      border-radius: 8px;
      font-size: 0.87rem;
    }

    .privacy-note strong {
      color: var(--teal-dark);
    }

    .chat {
      display: grid;
      min-width: 0;
      min-height: 0;
      grid-template-rows: auto minmax(0, 1fr) auto;
      background: #fff;
    }

    .chat-header {
      display: flex;
      min-width: 0;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding: 1.55rem 1.5rem;
      border-bottom: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.93);
    }

    .chat-title h1 {
      margin: 0;
      font-size: 1.55rem;
      line-height: 1.05;
    }

    .chat-title p {
      display: flex;
      align-items: center;
      gap: 0.42rem;
      margin: 0.35rem 0 0;
      color: var(--muted);
    }

    .header-actions,
    .composer-actions,
    .row-actions,
    .button-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.55rem;
    }

    .primary-button,
    .secondary-button,
    .ghost-button,
    .send-button {
      display: inline-flex;
      min-height: 40px;
      align-items: center;
      justify-content: center;
      gap: 0.55rem;
      padding: 0 0.85rem;
      border-radius: 8px;
      font-size: 0.91rem;
      font-weight: 780;
      white-space: nowrap;
    }

    .primary-button {
      color: #fff;
      background: linear-gradient(135deg, var(--teal), var(--teal-dark));
      border-color: transparent;
      box-shadow: 0 11px 24px rgba(11, 98, 92, 0.22);
    }

    .primary-button:hover {
      transform: translateY(-1px);
      box-shadow: 0 15px 30px rgba(11, 98, 92, 0.27);
    }

    .secondary-button {
      color: #fff;
      background: linear-gradient(135deg, var(--rust), var(--rust-dark));
      border-color: transparent;
      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 {
      display: grid;
      width: 40px;
      height: 40px;
      place-items: center;
      color: #34433f;
    }

    .messages {
      min-height: 0;
      overflow: auto;
      padding: 1.35rem 1.5rem 1rem;
      scroll-behavior: smooth;
    }

    .empty-state {
      display: grid;
      min-height: 100%;
      place-items: center;
      padding: 2rem;
      color: var(--muted);
      text-align: center;
    }

    .empty-state-inner {
      width: min(560px, 100%);
      padding: 1.8rem;
      border: 1px dashed var(--line-strong);
      border-radius: 8px;
      background: #fbfcfc;
    }

    .empty-state h2 {
      margin: 0 0 0.7rem;
      color: var(--ink);
      font-size: 1.35rem;
    }

    .message {
      display: grid;
      grid-template-columns: 36px minmax(0, 1fr);
      gap: 0.85rem;
      padding: 1.1rem 0;
      border-bottom: 1px solid var(--line);
    }

    .message:first-child {
      border-top: 0;
    }

    .avatar {
      width: 32px;
      height: 32px;
      border-radius: 6px;
      font-size: 0.83rem;
    }

    .message.ai .avatar {
      background: linear-gradient(145deg, var(--rust), var(--rust-dark));
      box-shadow: 0 8px 18px rgba(168, 70, 33, 0.16);
    }

    .message-meta {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      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-time {
      color: var(--faint);
    }

    .message-content {
      overflow-wrap: anywhere;
      white-space: pre-wrap;
    }

    .message-content ul,
    .message-content ol {
      margin-top: 0.4rem;
      padding-left: 1.4rem;
    }

    .composer {
      padding: 0.95rem 1.5rem 1.2rem;
      border-top: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.96);
    }

    .context-strip {
      display: none;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      margin-bottom: 0.55rem;
      padding: 0.55rem 0.7rem;
      color: #29443f;
      background: var(--teal-soft);
      border: 1px solid rgba(11, 98, 92, 0.2);
      border-radius: 8px;
      font-size: 0.88rem;
    }

    .context-strip.visible {
      display: flex;
    }

    .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: 68px;
      max-height: 210px;
      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);
    }

    .composer-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.8rem;
      margin-top: 0.62rem;
      color: var(--muted);
      font-size: 0.82rem;
    }

    .lab {
      display: grid;
      min-width: 0;
      min-height: 0;
      grid-template-rows: auto minmax(0, 1fr);
      border-left: 1px solid var(--line);
    }

    .lab-header {
      padding: 1.45rem 1.2rem 0.7rem;
      border-bottom: 1px solid var(--line);
    }

    .lab-heading {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      margin-bottom: 1rem;
    }

    .lab-heading h2 {
      display: flex;
      align-items: center;
      gap: 0.6rem;
      margin: 0;
      color: var(--teal-dark);
      font-size: 1.15rem;
    }

    .tabs {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.35rem;
    }

    .tab-button {
      min-height: 40px;
      padding: 0 0.4rem;
      color: #3f4e4b;
      font-size: 0.88rem;
      font-weight: 760;
    }

    .tab-button.active {
      color: var(--teal-dark);
      background: #fff;
      border-color: var(--teal);
      box-shadow: inset 0 -3px 0 var(--teal);
    }

    .lab-body {
      min-height: 0;
      overflow: auto;
      padding: 1.15rem;
    }

    .panel {
      display: none;
    }

    .panel.active {
      display: grid;
      gap: 1rem;
    }

    .panel h3 {
      margin: 0 0 0.32rem;
      font-size: 1.2rem;
      line-height: 1.15;
    }

    .panel p {
      margin: 0;
      color: var(--muted);
    }

    .field {
      display: grid;
      gap: 0.42rem;
    }

    .field label {
      color: #2d3f3c;
      font-size: 0.87rem;
      font-weight: 760;
    }

    .field textarea,
    .field select,
    .field input {
      width: 100%;
      color: var(--ink);
      border: 1px solid var(--line-strong);
      border-radius: 8px;
      background: #fff;
      outline: 0;
    }

    .field textarea {
      min-height: 110px;
      padding: 0.78rem;
      resize: vertical;
    }

    .field select,
    .field input {
      min-height: 42px;
      padding: 0 0.72rem;
    }

    .field textarea:focus,
    .field select:focus,
    .field input:focus,
    .composer-box:focus-within {
      border-color: var(--teal);
      box-shadow: 0 0 0 3px rgba(11, 98, 92, 0.12);
    }

    .result-box {
      min-height: 110px;
      padding: 0.78rem;
      overflow: auto;
      white-space: pre-wrap;
      color: #1f2d2a;
      background: #fff;
      border: 1px solid var(--line-strong);
      border-radius: 8px;
    }

    .rules-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.5rem;
    }

    .check-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      min-height: 34px;
      padding: 0.35rem 0.45rem;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 8px;
      color: #34433f;
      font-size: 0.87rem;
    }

    .check-row input {
      width: 16px;
      height: 16px;
      accent-color: var(--teal);
    }

    .prompt-card {
      display: grid;
      gap: 0.55rem;
      padding: 0.8rem;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 8px;
    }

    .prompt-card strong {
      color: var(--teal-dark);
    }

    .prompt-card p {
      color: #3f4e4b;
      font-size: 0.9rem;
    }

    .status-bar {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: minmax(220px, 1.1fr) repeat(4, minmax(140px, 1fr));
      gap: 1px;
      color: #2d3f3c;
      background: var(--line);
      border-top: 1px solid var(--line);
    }

    .status-item {
      min-width: 0;
      padding: 0.95rem 1.1rem;
      background: rgba(255, 255, 255, 0.93);
    }

    .status-item strong {
      display: block;
      margin-bottom: 0.26rem;
      color: #40504c;
      font-size: 0.72rem;
      font-weight: 820;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .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;
    }

    .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;
    }

    .dot {
      width: 9px;
      height: 9px;
      flex: none;
      border-radius: 999px;
      background: var(--faint);
    }

    .dot.available {
      background: var(--mint);
    }

    .dot.downloadable,
    .dot.downloading {
      background: var(--amber);
    }

    .dot.unavailable,
    .dot.error {
      background: var(--danger);
    }

    .progress-wrap {
      display: none;
      gap: 0.4rem;
      margin-top: 0.45rem;
    }

    .progress-wrap.visible {
      display: grid;
    }

    progress {
      width: 100%;
      height: 9px;
      overflow: hidden;
      border: 0;
      border-radius: 999px;
      background: var(--surface-soft);
    }

    progress::-webkit-progress-bar {
      background: var(--surface-soft);
    }

    progress::-webkit-progress-value {
      background: var(--teal);
    }

    .kbd {
      padding: 0.1rem 0.34rem;
      color: #40504c;
      border: 1px solid var(--line);
      border-bottom-color: var(--line-strong);
      border-radius: 5px;
      background: #fff;
      font-family: var(--mono);
      font-size: 0.75rem;
    }

    .toast {
      position: fixed;
      right: 1rem;
      bottom: 1rem;
      z-index: 50;
      max-width: min(360px, 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);
    }

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

    @media (max-width: 1180px) {
      .app {
        grid-template-columns: 278px minmax(0, 1fr);
      }

      .lab {
        grid-column: 1 / -1;
        min-height: 520px;
        border-top: 1px solid var(--line);
        border-left: 0;
      }

      .status-bar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
    }

    @media (max-width: 760px) {
      .app {
        display: block;
        height: auto;
        overflow: visible;
      }

      .rail {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
      }

      .tool-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .chat {
        min-height: 760px;
      }

      .chat-header {
        align-items: flex-start;
        flex-direction: column;
      }

      .header-actions,
      .header-actions .primary-button,
      .header-actions .ghost-button {
        width: 100%;
      }

      .messages,
      .composer {
        padding-left: 1rem;
        padding-right: 1rem;
      }

      .composer-box {
        grid-template-columns: 1fr;
      }

      .send-button {
        width: 100%;
      }

      .tabs,
      .rules-grid,
      .status-bar {
        grid-template-columns: 1fr;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        scroll-behavior: auto !important;
        transition: none !important;
      }
    }
