    :root {
      --bg: #070b14;
      --panel: #0f1626;
      --line: #253149;
      --text: #e4ecfa;
      --muted: #8fa1c4;
      --brand: #4f7dff;
      --brand-2: #3f66d4;
      --ok: #3fbe7d;
      --warn: #d8a347;
      --danger: #e57a8a;
      --chip: #152036;
      --mono: #d9e4f8;
    }

    * { box-sizing: border-box; }

    [hidden] {
      display: none !important;
    }

    @font-face {
      font-family: "CodexMono";
      src: local("CodexMono"),
           local("CodexMono-Regular"),
           url("./fonts/CodexMono.woff2") format("woff2"),
           url("./fonts/CodexMono.ttf") format("truetype");
      font-weight: 400;
      font-style: normal;
      font-display: swap;
    }

    @font-face {
      font-family: "CodexMono KR";
      src: local("CodexMono KR"),
           local("CodexMono-KR"),
           url("./fonts/CodexMono-KR.woff2") format("woff2"),
           url("./fonts/CodexMono-KR.ttf") format("truetype");
      font-weight: 400;
      font-style: normal;
      font-display: swap;
    }

    html,
    body {
      margin: 0;
      padding: 0;
      min-width: 100%;
      width: 100%;
      overflow-x: hidden;
    }

    html {
      background:
        radial-gradient(980px 420px at 82% -180px, rgba(72, 120, 255, 0.28) 0%, rgba(72, 120, 255, 0) 72%),
        radial-gradient(760px 360px at -12% 110%, rgba(18, 178, 145, 0.16) 0%, rgba(18, 178, 145, 0) 72%),
        var(--bg);
    }

    body {
      margin: 0;
      min-height: 100vh;
      font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
      background:
        radial-gradient(980px 420px at 82% -180px, rgba(72, 120, 255, 0.28) 0%, rgba(72, 120, 255, 0) 72%),
        radial-gradient(760px 360px at -12% 110%, rgba(18, 178, 145, 0.16) 0%, rgba(18, 178, 145, 0) 72%),
        var(--bg);
      color: var(--text);
      overflow-y: auto;
    }

    /* Scrollbar */
    * {
      scrollbar-color: rgba(112, 128, 160, 0.3) transparent;
      scrollbar-width: thin;
    }
    *::-webkit-scrollbar { width: 6px; height: 6px; }
    *::-webkit-scrollbar-track { background: transparent; }
    *::-webkit-scrollbar-thumb {
      background: rgba(112, 128, 160, 0.3);
      border-radius: 6px;
    }
    *::-webkit-scrollbar-thumb:hover {
      background: rgba(112, 128, 160, 0.5);
    }

    .shell {
      min-height: 100vh;
      width: 100%;
      display: flex;
      flex-direction: column;
    }

    .topbar {
      width: 100%;
      padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
      border-bottom: 1px solid var(--line);
      background: rgba(10, 16, 30, 0.88);
      backdrop-filter: blur(8px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 20;
    }

    .topbar-logo {
      height: 18px;
      width: 95px;
    }

    .topbar-status {
      font-size: 11px;
      color: var(--muted);
      white-space: nowrap;
    }

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

    .top-actions a,
    button {
      border: 1px solid var(--line);
      background: #141f35;
      color: var(--text);
      border-radius: 10px;
      padding: 8px 12px;
      font-size: 13px;
      cursor: pointer;
      text-decoration: none;
    }

    button.primary {
      border-color: var(--brand);
      background: var(--brand);
      color: #fff;
    }

    button.primary:hover { background: var(--brand-2); }

    button.ghost { background: #141f35; }

    button.warn {
      border-color: #5a4523;
      background: #231c12;
      color: var(--warn);
    }

    button.danger {
      border-color: #5a2b35;
      background: #28151a;
      color: var(--danger);
    }

    button:disabled { opacity: 0.5; cursor: default; }

    .layout {
      flex: 1 1 auto;
      min-height: 0;
      width: 100%;
      padding: 12px;
    }

    .work-area {
      min-height: 0;
      min-width: 0;
      width: 100%;
      display: flex;
      gap: 14px;
      align-items: start;
    }

    .work-tab-toggle {
      position: absolute;
      opacity: 0;
      pointer-events: none;
      top: 0;
      left: 0;
      width: 0;
      height: 0;
      margin: 0;
      padding: 0;
      border: 0;
    }

    .work-tab-nav {
      display: none;
      align-items: center;
      gap: 6px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 4px;
      background: #0f1728;
    }

    .work-tab-nav label {
      border: 1px solid transparent;
      border-radius: 8px;
      padding: 7px 11px;
      font-size: 12px;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
      flex: 1 1 0;
      text-align: center;
    }

    #work-tab-workspace:checked ~ .work-tab-nav label[for="work-tab-workspace"],
    #work-tab-session:checked ~ .work-tab-nav label[for="work-tab-session"] {
      background: var(--brand);
      border-color: var(--brand);
      color: #fff;
    }

    .stack {
      min-height: 0;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .left-col {
      flex: 0 0 320px;
      width: 320px;
      max-width: 320px;
      max-height: calc(100vh - 92px);
      overflow: hidden;
      padding-right: 0;
    }

    .main-col {
      flex: 1 1 auto;
      min-width: 0;
      width: 100%;
    }

    body.app-page {
      overflow: hidden;
    }

    body.app-page .shell {
      height: 100dvh;
      min-height: 100dvh;
      overflow: hidden;
    }

    body.app-page .layout {
      overflow: hidden;
    }

    body.app-page .work-area {
      height: 100%;
      align-items: stretch;
    }

    body.app-page .left-col {
      height: 100%;
      max-height: none;
      overflow: auto;
    }

    body.app-page .main-col {
      height: 100%;
      width: auto;
      overflow: hidden;
    }

    .sidebar-tab-toggle {
      position: absolute;
      opacity: 0;
      pointer-events: none;
      top: 0;
      left: 0;
      width: 0;
      height: 0;
      margin: 0;
      padding: 0;
      border: 0;
    }

    .sidebar-tab-nav {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 4px;
      background: #0f1728;
    }

    .sidebar-tab-nav label {
      border: 1px solid transparent;
      border-radius: 8px;
      padding: 7px 11px;
      font-size: 12px;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
      flex: 1 1 0;
      text-align: center;
    }

    #sidebar-tab-inventory:checked ~ .sidebar-tab-nav label[for="sidebar-tab-inventory"],
    #sidebar-tab-config:checked ~ .sidebar-tab-nav label[for="sidebar-tab-config"] {
      background: var(--brand);
      border-color: var(--brand);
      color: #fff;
    }

    .sidebar-pane {
      display: none;
      min-height: 0;
      overflow: auto;
      flex-direction: column;
      gap: 12px;
    }

    #sidebar-tab-inventory:checked ~ .pane-inventory {
      display: flex;
    }

    #sidebar-tab-config:checked ~ .pane-config {
      display: flex;
    }

    .card {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 12px;
    }

    .card h2 {
      margin: 0 0 8px;
      font-size: 14px;
      letter-spacing: -0.02em;
    }

    .muted {
      color: var(--muted);
      font-size: 12px;
      margin: 0;
    }

    .grid-2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    label {
      display: block;
      margin: 0 0 4px;
      font-size: 12px;
      color: var(--muted);
    }

    input, textarea, select {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 8px 10px;
      font: inherit;
      color: var(--text);
      background: #0d1525;
    }

    textarea {
      resize: vertical;
      min-height: 84px;
      line-height: 1.4;
    }

    .row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .mono {
      font-family: "CodexMono KR", "CodexMono", "CodexMono-Traditional", "CodexMono-Emoji", "SF Mono", Menlo, Consolas, ui-monospace, monospace;
    }

    .chips {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 8px;
    }

    .chip {
      display: inline-flex;
      align-items: center;
      border-radius: 999px;
      background: var(--chip);
      color: #9db3de;
      border: 1px solid #2b3b5d;
      font-size: 11px;
      padding: 3px 9px;
      line-height: 1.5;
    }

    .chip.ok {
      background: #11281f;
      border-color: #1f523d;
      color: var(--ok);
    }

    .chip.warn {
      background: #2a2013;
      border-color: #5a4321;
      color: var(--warn);
    }

    .chip.danger {
      background: #2c161b;
      border-color: #5e2d37;
      color: var(--danger);
    }

    .sessions {
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 280px;
      overflow: auto;
      padding-right: 2px;
    }

    .inventory-status {
      font-size: 11px;
      color: var(--muted);
      padding: 0 2px 6px;
    }

    .inventory-actions {
      gap: 6px;
      padding: 4px 0 8px;
    }

    .inventory-list {
      max-height: none;
      overflow: visible;
    }

    .inventory-debug {
      margin-top: 8px;
      border-top: 1px solid var(--line);
      padding-top: 8px;
    }

    .inventory-debug summary {
      font-size: 12px;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
    }

    .config-status-bar {
      display: flex;
      gap: 8px;
      padding: 8px 12px;
      font-size: 11px;
      color: var(--muted);
      background: rgba(20, 31, 53, 0.5);
      border-bottom: 1px solid var(--line);
    }

    .config-status-bar .chip {
      background: none;
      border: none;
      padding: 0;
      font-size: 11px;
    }

    .config-section {
      padding: 10px 12px;
      border-top: 1px solid var(--line);
    }

    .config-section h3 {
      margin: 0 0 8px;
      font-size: 13px;
      font-weight: 600;
    }

    .config-details {
      border-top: 1px solid var(--line);
    }

    .config-details summary {
      font-size: 12px;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
      padding: 8px 12px;
    }

    .machine-group-header {
      font-size: 11px;
      font-weight: 600;
      color: var(--muted);
      padding: 6px 0 2px;
      border-bottom: 1px solid var(--line);
      margin-bottom: 2px;
    }

    .session-item {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #121b2d;
      padding: 8px;
      cursor: pointer;
    }

    .session-radio-item {
      display: flex;
      align-items: flex-start;
      gap: 0;
      position: relative;
    }

    .session-radio-item:focus-within {
      border-color: #5377c2;
      box-shadow: 0 0 0 1px #5377c2 inset;
    }

    .session-radio-input {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: 0;
      padding: 0;
      opacity: 0;
      pointer-events: none;
      border: 0;
    }

    .session-radio-body {
      min-width: 0;
      flex: 1 1 auto;
    }

    .session-check-item {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      position: relative;
    }

    .session-check-item:focus-within {
      border-color: #5377c2;
      box-shadow: 0 0 0 1px #5377c2 inset;
    }

    .session-check-input {
      width: 14px;
      height: 14px;
      margin: 2px 0 0;
      accent-color: var(--brand);
      flex: 0 0 auto;
      cursor: pointer;
    }

    .session-check-body {
      min-width: 0;
      flex: 1 1 auto;
    }

    .session-item.active {
      border-color: #5377c2;
      background: #192745;
    }

    .session-item .sid {
      font-size: 12px;
      font-weight: 600;
      margin: 0 0 4px;
      word-break: break-all;
    }

    .session-item .meta {
      margin: 0;
      color: var(--muted);
      font-size: 11px;
    }

    .output {
      min-height: 0;
      display: grid;
      grid-template-rows: auto auto 1fr;
      gap: 8px;
      height: 100%;
    }

    .output-tab-strip {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: nowrap;
      overflow-x: auto;
      overflow-y: hidden;
      padding: 2px 0 6px;
    }

    .output-tab-strip[hidden] {
      display: none;
    }

    .output-tab-btn {
      flex: 0 0 auto;
      border: 1px solid var(--line);
      background: #121b2d;
      color: var(--muted);
      border-radius: 9px;
      padding: 6px 10px;
      font-size: 12px;
      line-height: 1.2;
      cursor: pointer;
      white-space: nowrap;
      max-width: 220px;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .output-tab-btn.active {
      border-color: #5377c2;
      background: #192745;
      color: #dce8ff;
    }

    body.app-page .output {
      display: flex;
      flex-direction: column;
      flex: 1 1 auto;
      min-height: 0;
      height: auto;
    }

    .output-meta {
      color: var(--muted);
      font-size: 12px;
    }

    .output-view {
      min-height: 260px;
      height: calc(100vh - 350px);
      overflow: hidden;
      position: relative;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #0d1220;
      color: #d7e3ff;
      padding: 0;
    }

    body.app-page .output-view {
      flex: 1 1 auto;
      min-height: 0;
      height: auto;
    }

    .output-view .xterm {
      height: 100%;
      width: 100%;
      padding: 10px;
    }

    .output-xterm-pane {
      position: absolute;
      inset: 0;
      overflow: hidden;
      visibility: hidden;
      pointer-events: none;
    }

    .output-xterm-pane.active {
      visibility: visible;
      pointer-events: auto;
    }

    .composer textarea {
      min-height: 108px;
      font-size: 14px;
      border-color: #2c3f63;
      background: #0b1423;
    }

    .composer textarea.terminal-active {
      opacity: 0.5;
      cursor: not-allowed;
    }

    body.app-page .composer {
      flex: 0 0 auto;
    }

    .composer-status {
      margin-left: auto;
      justify-content: flex-end;
      min-width: 0;
      max-width: 100%;
    }

    #sse-state {
      min-width: 0;
      max-width: 220px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: inline-block;
    }

    .activitylog-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(5, 9, 18, 0.56);
      z-index: 44;
      display: none;
    }

    .activitylog-backdrop.open {
      display: block;
    }

    .activitylog-panel {
      position: fixed;
      right: 18px;
      bottom: 68px;
      width: min(560px, calc(100vw - 28px));
      max-height: min(60vh, 560px);
      flex-direction: column;
      gap: 8px;
      z-index: 45;
      display: none;
    }

    .activitylog-panel.open {
      display: flex;
    }

    .activitylog-panel .log {
      min-height: 220px;
      max-height: none;
      flex: 1 1 auto;
    }

    .activitylog-tools {
      justify-content: flex-end;
      gap: 6px;
      margin-top: 2px;
      padding-top: 8px;
      border-top: 1px solid var(--line);
    }

    .activitylog-fab {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--line);
      background: #141f35;
      color: var(--text);
      border-radius: 10px;
      padding: 8px 12px;
      font-size: 13px;
      cursor: pointer;
      user-select: none;
      transition: filter 0.12s ease, background 0.12s ease, border-color 0.12s ease;
    }


    .hint {
      font-size: 11px;
      color: var(--muted);
    }

    .log {
      min-height: 180px;
      max-height: 320px;
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #111827;
      color: #d7e3ff;
      padding: 10px;
      font-size: 11px;
      line-height: 1.4;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .state-grid {
      display: grid;
      grid-template-columns: 92px 1fr;
      gap: 6px 8px;
      font-size: 12px;
      align-items: center;
    }

    .state-grid code {
      border: 1px solid var(--line);
      background: #0f1a2f;
      border-radius: 8px;
      padding: 5px 8px;
      overflow: auto;
      white-space: nowrap;
      display: block;
    }

    a:hover,
    button:hover {
      filter: brightness(1.06);
    }

    @media (max-width: 1200px) {
      .left-col {
        flex-basis: 280px;
        width: 280px;
        max-width: 280px;
      }
    }

    @media (max-width: 860px) {
      .layout {
        padding: 10px;
      }

      .work-area {
        display: block;
      }

      body.app-page .layout {
        overflow: hidden;
      }

      body.app-page .work-area {
        height: 100%;
      }

      .work-tab-nav {
        display: inline-flex;
        margin-bottom: 10px;
      }

      #work-tab-workspace:checked ~ .left-col {
        display: none;
      }

      #work-tab-session:checked ~ .main-col {
        display: none;
      }

      .left-col {
        flex: none;
        max-height: none;
        overflow: visible;
        padding-right: 0;
        min-width: 0;
        width: 100%;
        max-width: none;
      }

      body.app-page .left-col,
      body.app-page .main-col {
        height: calc(100% - 52px);
        overflow: auto;
      }

      .main-col {
        flex: none;
        min-width: 0;
        width: 100%;
      }

      .sidebar-pane {
        overflow: visible;
        padding-right: 0;
      }

      body.app-page .sidebar-pane {
        overflow: auto;
      }

      .output-view {
        height: 360px;
      }

      body.app-page .output-view {
        height: min(42dvh, 420px);
        min-height: 200px;
      }

      .activitylog-panel {
        right: 12px;
        bottom: 62px;
        width: calc(100vw - 24px);
        max-height: 56vh;
      }

      .topbar {
        position: static;
      }

      #sse-state {
        max-width: 140px;
      }
    }

    /* Terminal Scrollbar (from Tauri) */
    .output-view { position: relative; }

    .terminal-scrollbar-track {
      position: absolute;
      right: 0;
      top: 0;
      bottom: 0;
      width: 6px;
      background: transparent;
      z-index: 10;
      opacity: 0;
      transition: opacity 0.12s ease, width 0.12s ease;
      overflow: visible;
    }
    .terminal-scrollbar-track.is-scrollable { opacity: 0; }
    .terminal-scrollbar-track:hover { opacity: 1; width: 10px; }
    .terminal-scrollbar-thumb {
      position: absolute;
      right: 0;
      width: 10px;
      height: 24px;
      border-radius: 9999px;
      background: transparent !important;
    }
    .terminal-scrollbar-thumb::before {
      content: '';
      position: absolute;
      top: 0; bottom: 0; left: 2px; right: 2px;
      background: rgba(255,255,255,0.25);
      border-radius: inherit;
      opacity: 0;
      transition: opacity 0.12s ease;
    }
    .terminal-scrollbar-track:hover .terminal-scrollbar-thumb::before { opacity: 1; }
    .terminal-scrollbar-thumb:hover::before { background: rgba(255,255,255,0.4); }

    /* Terminal Mode Toggle */
    .terminal-mode-dropdown {
      position: absolute;
      bottom: 4px;
      right: 8px;
      z-index: 20;
    }
    .terminal-mode-toggle-btn {
      font-size: 11px;
      padding: 2px 8px;
      border-radius: 4px;
      border: 1px solid var(--line);
      background: var(--panel);
      color: var(--muted);
      cursor: pointer;
      opacity: 0.6;
      transition: opacity 0.15s;
    }
    .terminal-mode-toggle-btn:hover { opacity: 1; }
    .terminal-mode-dropdown__menu {
      position: absolute;
      bottom: 100%;
      right: 0;
      margin-bottom: 4px;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 6px;
      overflow: hidden;
      min-width: 130px;
    }
    .terminal-mode-dropdown__option {
      padding: 6px 10px;
      font-size: 11px;
      color: var(--muted);
      cursor: pointer;
    }
    .terminal-mode-dropdown__option:hover { background: var(--line); color: var(--text); }
    .terminal-mode-dropdown__option.is-selected { color: var(--accent); }
