:root {
  --bg-main: #181817;
  --bg-sidebar: #20201e;
  --bg-panel: #222320;
  --bg-elevated: #262724;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text-main: rgba(255, 255, 255, 0.88);
  --text-muted: rgba(255, 255, 255, 0.52);
  --text-faint: rgba(255, 255, 255, 0.34);
  --accent-teal: #18c7c4;
  --accent-teal-soft: rgba(24, 199, 196, 0.16);
  --accent-purple: #8b5cf6;
  --accent-purple-soft: rgba(139, 92, 246, 0.14);
  --shadow-soft: 0 18px 60px rgba(0, 0, 0, 0.35);
}

html,
body {
  overflow-x: hidden;
}

.ai-desktop-app-shell {
  display: none;
}

@media (min-width: 1024px) {
  html.ai-desktop-app-mode,
  html.ai-desktop-app-mode body {
    background: var(--bg-main) !important;
    color: var(--text-main);
  }

  html.ai-desktop-app-mode:not(.ai-workspace-active) #root {
    position: fixed;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
  }

  html.ai-desktop-app-mode.ai-workspace-active .ai-desktop-app-shell {
    opacity: 0;
    pointer-events: none;
  }

  .ai-desktop-app-shell {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    min-width: 0;
    min-height: 100dvh;
    background:
      radial-gradient(circle at 52% 18%, rgba(24, 199, 196, 0.09), transparent 34%),
      radial-gradient(circle at 86% 78%, rgba(139, 92, 246, 0.08), transparent 34%),
      var(--bg-main);
    color: var(--text-main);
    z-index: 20;
    pointer-events: auto;
    transition: opacity 180ms ease;
    font-family: Inter, Space Grotesk, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  .ai-desktop-app-shell button,
  .ai-desktop-app-shell textarea,
  .ai-desktop-app-shell input,
  .ai-desktop-app-shell [role="menu"],
  .ai-desktop-app-shell .ai-model-menu {
    pointer-events: auto;
  }

  .ai-desktop-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 18px 14px;
    background: color-mix(in srgb, var(--bg-sidebar) 94%, #000 6%);
    border-right: 1px solid var(--border-subtle);
  }

  .ai-desktop-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 18px;
    color: var(--text-main);
  }

  .ai-desktop-brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: var(--accent-teal-soft);
    color: var(--accent-teal);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
  }

  .ai-desktop-brand strong,
  .ai-workspace-side-brand strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
  }

  .ai-desktop-brand small {
    display: block;
    margin-top: 2px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.2;
  }

  .ai-desktop-menu {
    display: grid;
    gap: 4px;
    margin-top: 8px;
  }

  .ai-provider-group {
    display: grid;
    gap: 3px;
  }

  .ai-provider-list {
    display: grid;
    gap: 2px;
    margin: 2px 0 6px 28px;
  }

  .ai-provider-list.is-collapsed {
    display: none;
  }

  .ai-desktop-menu button,
  .ai-desktop-account,
  .ai-workspace-desktop-sidebar button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    width: 100%;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-muted);
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
  }

  .ai-desktop-menu button span {
    width: 18px;
    color: var(--text-faint);
    text-align: center;
    font-size: 15px;
  }

  .ai-provider-entry {
    min-height: 34px !important;
    padding: 0 10px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    color: var(--text-muted) !important;
  }

  .ai-provider-entry .ai-provider-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
  }

  .ai-provider-entry.is-active {
    color: var(--text-main) !important;
    background: rgba(255, 255, 255, 0.075) !important;
    border-color: var(--border-subtle) !important;
  }

  .ai-provider-entry.is-active .ai-provider-dot {
    background: var(--accent-teal);
    box-shadow: 0 0 0 4px var(--accent-teal-soft);
  }

  .ai-desktop-menu button:hover,
  .ai-desktop-account:hover,
  .ai-workspace-desktop-sidebar button:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.055);
  }

  .ai-desktop-menu button.is-active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-subtle);
    box-shadow: inset 2px 0 0 var(--accent-teal);
  }

  .ai-desktop-account {
    margin-top: auto;
    justify-content: center;
    border-color: var(--border-subtle);
    background: rgba(255, 255, 255, 0.035);
  }

  .ai-desktop-main {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 22px 32px 48px;
  }

  .ai-desktop-topnav {
    display: flex;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
  }

  .ai-desktop-topnav button {
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--text-faint);
    font-size: 13px;
    font-weight: 500;
    transition: background 180ms ease, color 180ms ease;
  }

  .ai-desktop-topnav button:hover,
  .ai-desktop-topnav button.is-active {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.045);
  }

  .ai-desktop-center {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(100%, 1080px);
    margin: 0 auto;
    padding-bottom: 5vh;
  }

  .ai-desktop-kicker {
    margin: 0 0 14px;
    color: var(--text-faint);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
  }

  .ai-desktop-center h1 {
    margin: 0 0 32px;
    color: var(--text-main) !important;
    font-family: Inter, Space Grotesk, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: clamp(44px, 5vw, 56px) !important;
    font-weight: 560 !important;
    line-height: 1.05 !important;
    letter-spacing: 0 !important;
    text-shadow: none !important;
  }

  .ai-desktop-composer {
    width: min(100%, 820px);
    min-height: 150px;
    padding: 16px;
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.025)),
      var(--bg-panel);
    box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, 0.06);
    transition: border-color 180ms ease, background 180ms ease;
  }

  .ai-desktop-composer:focus-within {
    border-color: rgba(24, 199, 196, 0.35);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.03)),
      var(--bg-panel);
  }

  .ai-desktop-prompt {
    display: block;
    width: 100%;
    min-height: 84px;
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.55;
  }

  .ai-desktop-prompt::placeholder {
    color: var(--text-faint);
  }

  .ai-desktop-composer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 8px;
  }

  .ai-desktop-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .ai-icon-button,
  .ai-tool-button,
  .ai-send-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
  }

  .ai-icon-button {
    width: 38px;
    font-size: 18px;
  }

  .ai-tool-button {
    padding: 0 13px;
  }

  .ai-send-button {
    width: 40px;
    height: 40px;
    border-color: rgba(24, 199, 196, 0.28);
    background: var(--accent-teal-soft);
    color: var(--accent-teal);
    font-size: 18px;
  }

  .ai-icon-button:hover,
  .ai-tool-button:hover,
  .ai-send-button:hover {
    color: var(--text-main);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.075);
  }

  .ai-send-button:hover {
    transform: translateY(-1px);
    border-color: rgba(24, 199, 196, 0.42);
  }

  .ai-model-picker {
    position: relative;
  }

  .ai-workspace-model-picker {
    position: relative;
    flex: 0 0 auto;
  }

  .ai-model-menu {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: 304px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 16px;
    background: #222320;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
    transform-origin: bottom right;
    z-index: 50;
  }

  .ai-workspace-model-picker .ai-model-menu {
    top: calc(100% + 8px);
    right: 0;
    bottom: auto;
    transform-origin: top right;
  }

  .ai-model-menu.is-open {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .ai-workspace-model-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    font-weight: 500;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
  }

  .ai-workspace-model-trigger:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
  }

  .ai-model-item {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 50px;
    padding: 7px 10px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    text-align: left;
    transition: background 180ms ease, color 180ms ease;
  }

  .ai-model-item:hover,
  .ai-model-item.is-selected {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.065);
  }

  .ai-model-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
  }

  .ai-model-item.is-selected .ai-model-dot {
    background: var(--accent-teal);
    box-shadow: 0 0 0 4px var(--accent-teal-soft);
  }

  .ai-model-copy strong,
  .ai-model-copy small {
    display: block;
    letter-spacing: 0;
  }

  .ai-model-copy strong {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
  }

  .ai-model-copy small {
    margin-top: 2px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.2;
  }

  .ai-model-check {
    color: var(--accent-teal);
    opacity: 0;
    font-size: 13px;
  }

  .ai-model-item.is-selected .ai-model-check {
    opacity: 1;
  }

  .ai-desktop-task-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    width: min(100%, 820px);
    margin-top: 18px;
  }

  .ai-task-card {
    min-height: 104px;
    padding: 15px;
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.022));
    color: var(--text-muted);
    text-align: left;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
  }

  .ai-task-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.03));
  }

  .ai-task-card strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
  }

  .ai-task-card span {
    display: block;
    color: var(--text-faint);
    font-size: 13px;
    line-height: 1.45;
  }
}

@media (min-width: 768px) {
  html.ai-desktop-app-mode.ai-workspace-active #root {
    opacity: 1;
    pointer-events: auto;
  }

  html.ai-desktop-app-mode .ai-workspace-overlay {
    position: fixed !important;
    inset: 0 !important;
    display: grid !important;
    grid-template-columns: 248px minmax(0, 1fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
    background: var(--bg-main) !important;
    overflow: hidden !important;
    pointer-events: auto !important;
  }

  html.ai-desktop-app-mode .ai-workspace-overlay button,
  html.ai-desktop-app-mode .ai-workspace-overlay textarea,
  html.ai-desktop-app-mode .ai-workspace-overlay input,
  html.ai-desktop-app-mode .ai-workspace-overlay [role="button"],
  html.ai-desktop-app-mode .ai-workspace-overlay [role="menu"] {
    pointer-events: auto !important;
  }

  html.ai-desktop-app-mode .ai-workspace-desktop-sidebar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 18px 14px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    color: var(--text-muted);
  }

  html.ai-desktop-app-mode .ai-workspace-side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 6px 8px 14px;
    color: var(--text-main);
  }

  html.ai-desktop-app-mode .ai-workspace-side-brand span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 11px;
    background: var(--accent-teal-soft);
    color: var(--accent-teal);
    font-size: 12px;
    font-weight: 700;
  }

  html.ai-desktop-app-mode .ai-workspace-desktop-sidebar p {
    margin: 14px 10px 4px;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  html.ai-desktop-app-mode .ai-workspace-desktop-sidebar .ai-provider-list {
    margin-left: 0;
  }

  html.ai-desktop-app-mode .ai-workspace-desktop-sidebar .ai-provider-entry {
    justify-content: flex-start;
  }

  html.ai-desktop-app-mode .ai-workspace-desktop-sidebar button {
    justify-content: flex-start;
  }

  html.ai-desktop-app-mode .ai-workspace-desktop-sidebar button i {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent-teal);
    opacity: 0.72;
  }

  html.ai-desktop-app-mode .ai-workspace-side-note {
    margin: 0 10px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.45;
  }

  html.ai-desktop-app-mode .ai-workspace-model-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    padding: 10px 22px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(24, 24, 23, 0.88);
    backdrop-filter: blur(18px);
    z-index: 2;
  }

  html.ai-desktop-app-mode .ai-workspace-provider-title {
    display: block;
    color: var(--text-main);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
  }

  html.ai-desktop-app-mode .ai-workspace-provider-subtitle {
    display: block;
    margin-top: 3px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.25;
  }

  html.ai-desktop-app-mode .ai-workspace-header-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
  }

  html.ai-desktop-app-mode .ai-workspace-clear-history {
    height: 38px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-faint);
    font-size: 13px;
    font-weight: 500;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
  }

  html.ai-desktop-app-mode .ai-workspace-clear-history:hover {
    color: var(--text-main);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.075);
  }

  html.ai-desktop-app-mode .ai-workspace-shell {
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--bg-main) !important;
    box-shadow: none !important;
  }

  html.ai-desktop-app-mode .ai-workspace-topbar {
    min-height: 64px !important;
    padding: 12px 22px !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    background: rgba(24, 24, 23, 0.92) !important;
    backdrop-filter: blur(18px);
  }

  html.ai-desktop-app-mode .ai-workspace-model-header + .ai-workspace-topbar {
    min-height: 54px !important;
  }

  html.ai-desktop-app-mode .ai-workspace-topbar h2,
  html.ai-desktop-app-mode .ai-workspace-topbar p {
    text-shadow: none !important;
    letter-spacing: 0 !important;
  }

  html.ai-desktop-app-mode .ai-mobile-mode-segment {
    padding: 3px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.045) !important;
  }

  html.ai-desktop-app-mode .ai-mobile-mode-segment button {
    min-height: 32px !important;
    border-radius: 999px !important;
    font-size: 13px !important;
    box-shadow: none !important;
  }

  html.ai-desktop-app-mode .ai-workspace-scroll {
    padding: 34px clamp(48px, 8vw, 124px) 190px !important;
    background: var(--bg-main) !important;
  }

  html.ai-desktop-app-mode .ai-workspace-shell > .flex.flex-1.overflow-hidden {
    min-width: 0 !important;
    width: 100% !important;
  }

  html.ai-desktop-app-mode .ai-workspace-shell > .flex.flex-1.overflow-hidden > aside:first-child {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    border: 0 !important;
    pointer-events: none !important;
  }

  html.ai-desktop-app-mode .ai-workspace-shell > .flex.flex-1.overflow-hidden > .flex-1.flex.flex-col.overflow-hidden {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  html.ai-desktop-app-mode .ai-workspace-input-area {
    padding: 8px clamp(48px, 8vw, 124px) 24px !important;
    background: linear-gradient(180deg, transparent, rgba(24, 24, 23, 0.92) 28%, var(--bg-main)) !important;
  }

  html.ai-desktop-app-mode .ai-workspace-quick-prompts {
    display: grid;
    gap: 10px;
    width: min(860px, calc(100% - 64px));
    max-width: 860px;
    margin: 0 auto 12px;
  }

  html.ai-desktop-app-mode .ai-workspace-quick-prompts strong {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
  }

  html.ai-desktop-app-mode .ai-workspace-quick-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  html.ai-desktop-app-mode .ai-workspace-quick-chip {
    min-height: 34px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
  }

  html.ai-desktop-app-mode .ai-workspace-quick-chip:hover {
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.10);
    transform: translateY(-1px);
  }

  html.ai-desktop-app-mode .ai-workspace-input-dock {
    max-width: 840px !important;
    margin: 0 auto !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 24px !important;
    background: var(--bg-panel) !important;
    box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, 0.06) !important;
  }

  html.ai-desktop-app-mode .ai-dock-textarea {
    color: var(--text-main) !important;
  }

  html.ai-desktop-app-mode .ai-dock-icon-button,
  html.ai-desktop-app-mode .ai-dock-model-button,
  html.ai-desktop-app-mode .ai-dock-send-button,
  html.ai-desktop-app-mode .ai-mobile-reset,
  html.ai-desktop-app-mode .ai-workspace-close {
    box-shadow: none !important;
  }
}

@media (min-width: 1024px) and (max-width: 1180px) {
  .ai-desktop-task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
