html, body { background: var(--c-bg); color: var(--c-fg); }
body { background-image: none; font-family: var(--font-sans); }
button, input, select, textarea { font-family: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--c-info);
  outline-offset: 2px;
}

.app {
  display: flex;
  height: 100dvh;
  min-height: 0;
  position: relative;
  z-index: 10;
}

.workspace {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.sidebar {
  display: flex;
  width: 232px;
  min-width: 232px;
  min-height: 0;
  padding: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--c-border);
  background: var(--c-bg-elevated);
  transition: width 180ms cubic-bezier(.22, 1, .36, 1), min-width 180ms cubic-bezier(.22, 1, .36, 1);
}

.sidebar-brand {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: var(--c-fg);
  text-decoration: none;
}

.brand-svg { width: 32px; height: 32px; flex: 0 0 auto; }
.brand-svg.small { width: 28px; height: 28px; }
.brand-svg .brand-base { fill: var(--c-primary); }
.brand-svg .brand-glyph { fill: var(--c-primary-fg); }
.sidebar-brand-copy { min-width: 0; }
.sidebar-brand-copy strong, .sidebar-brand-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-brand-copy strong { font-size: 11px; font-weight: 500; line-height: 1.35; }
.sidebar-brand-copy span { color: var(--c-primary); font-size: 11px; line-height: 1.35; }

.side-title { display: none; }
#nav { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 0 8px 8px; }
.nav-group { margin-top: 12px; }
.nav-group:first-child { margin-top: 2px; }
.nav-group-label {
  padding: 0 8px 4px;
  color: var(--c-subtle);
  font-size: 10px;
  letter-spacing: .16em;
}
.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-item:hover { background: var(--c-surface); color: var(--c-fg); }
.nav-item.active { border: 0; background: color-mix(in oklab, var(--c-primary) 12%, transparent); color: var(--c-fg); box-shadow: none; }
.nav-item.active::before {
  content: "";
  position: absolute;
  inset-block: 6px;
  left: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--c-primary);
}
.nav-item .ic { display: grid; width: 18px; height: 18px; flex: 0 0 18px; place-items: center; border: 0; border-radius: 0; background: transparent; }
.nav-item .ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active .ic { border: 0; background: transparent; }
.nav-item.active .ic svg { stroke-width: 2.1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-foot { display: none; }
.sidebar-collapse {
  display: grid;
  width: calc(100% - 16px);
  min-height: 32px;
  margin: 8px;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-subtle);
  cursor: pointer;
}
.sidebar-collapse:hover { background: var(--c-surface); color: var(--c-fg); }
.sidebar-collapse svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-collapse .expand-icon { display: none; }

.ui-sidebar-collapsed .sidebar { width: 68px; min-width: 68px; }
.ui-sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 8px; }
.ui-sidebar-collapsed .sidebar-brand-copy, .ui-sidebar-collapsed .nav-group-label, .ui-sidebar-collapsed .nav-label { display: none; }
.ui-sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.ui-sidebar-collapsed .sidebar-collapse .collapse-icon { display: none; }
.ui-sidebar-collapsed .sidebar-collapse .expand-icon { display: block; }

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  height: 48px;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--c-border);
  background: color-mix(in oklab, var(--c-bg-elevated) 88%, transparent);
  backdrop-filter: blur(12px);
}
.topbar-title { display: flex; min-width: 110px; align-items: center; color: var(--c-muted); font-size: 13px; }
.topbar-title strong { color: var(--c-fg); font-weight: 500; }
.topbar-title .divider { margin: 0 7px; color: var(--c-subtle); }
.mobile-brand { display: none; }

.command-trigger {
  display: flex;
  width: 220px;
  height: 32px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-subtle);
  font-size: 12px;
  cursor: pointer;
}
.command-trigger svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.command-trigger kbd { margin-left: auto; padding: 1px 5px; border: 1px solid var(--c-border); border-radius: 4px; color: var(--c-muted); font: 10px var(--font-mono); }

.top-right { min-width: 0; gap: 7px; }
.chip {
  min-height: 30px;
  padding: 5px 9px;
  border-color: var(--c-border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-muted);
}
.chip:hover { background: var(--c-surface); color: var(--c-fg); }
.date-chip, .weather-chip, .top-right > .chip:not(.chip-auth):not(.service-chip) { display: none; }
.service-chip[data-state="server"] { border-color: color-mix(in oklab, var(--c-primary) 35%, transparent); color: var(--c-primary); }
.service-chip[data-state="probing"] { color: var(--c-warn); }
.service-chip[data-state="offline"] { border-color: color-mix(in oklab, var(--c-danger) 35%, transparent); color: var(--c-danger); }
.chip-auth { font-size: 0; }
.chip-auth svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.theme-control { position: relative; }
.theme-toggle {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-muted);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--c-surface); color: var(--c-fg); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-menu {
  position: fixed;
  top: 42px;
  right: 118px;
  z-index: 70;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg-elevated);
  box-shadow: var(--sh-float);
}
.theme-menu[hidden] { display: none; }
.theme-choice { width: 30px; height: 30px; padding: 4px; border: 1px solid transparent; border-radius: 999px; background: transparent; cursor: pointer; }
.theme-choice[aria-pressed="true"] { border-color: var(--c-primary); }
.theme-choice span { display: block; width: 100%; height: 100%; border: 1px solid rgba(127,127,127,.3); border-radius: 999px; }
.theme-choice[data-theme-choice="grid-night"] span { background: #061016; }
.theme-choice[data-theme-choice="paper"] span { background: #efece5; }
.theme-choice[data-theme-choice="slate"] span { background: #11141a; }
.theme-choice[data-theme-choice="mist"] span { background: #e7eef1; }
.theme-choice[data-theme-choice="system"] span { background: linear-gradient(135deg, #061016 0 50%, #e7eef1 50% 100%); }

.connection-strip {
  display: none;
  min-height: 25px;
  align-items: center;
  gap: 8px;
  padding: 3px 16px;
  border-bottom: 1px solid var(--c-border);
  background: color-mix(in oklab, var(--c-primary) 7%, var(--c-bg));
  color: var(--c-muted);
  font-size: 11px;
}
.connection-dot { width: 7px; height: 7px; flex: 0 0 auto; border: 1px solid currentColor; border-radius: 999px; }
.connection-strip[data-state="server"] { color: var(--c-primary); }
.connection-strip[data-state="server"] .connection-dot { background: currentColor; }
.connection-strip[data-state="probing"] { color: var(--c-warn); }
.connection-strip[data-state="offline"] { color: var(--c-danger); }
.connection-detail { color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-truth { margin-left: auto; color: var(--c-subtle); font-family: var(--font-mono); }

.main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 60px;
  background: var(--c-bg);
}
.page { max-width: 1180px; }
.page.on { animation-duration: 180ms; }
.page-head h2 { color: var(--c-fg); font-size: 18px; letter-spacing: 0; }
.page-head .sub { color: var(--c-muted); }

.mobile-nav, .mobile-more-dialog { display: none; }

.command-dialog {
  width: min(520px, calc(100% - 32px));
  max-height: min(620px, 72dvh);
  margin: 18vh auto 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-bg-elevated);
  color: var(--c-fg);
  box-shadow: var(--sh-float);
}
.command-dialog::backdrop { background: color-mix(in oklab, var(--c-bg) 58%, transparent); backdrop-filter: blur(2px); }
.command-search-wrap { display: flex; align-items: center; gap: 9px; padding: 12px 14px; }
.command-search-wrap svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: var(--c-muted); stroke-width: 1.8; stroke-linecap: round; }
.command-search-wrap input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--c-fg); font-size: 14px; }
.command-search-wrap input::placeholder { color: var(--c-muted); opacity: 1; }
.command-results { max-height: 50dvh; overflow-y: auto; padding: 6px; border-top: 1px solid var(--c-border); }
.command-group-title { padding: 8px 8px 4px; color: var(--c-subtle); font-size: 10px; letter-spacing: .12em; }
.command-item { display: flex; width: 100%; min-height: 40px; align-items: center; gap: 9px; padding: 7px 9px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--c-fg); text-align: left; cursor: pointer; }
.command-item:hover, .command-item:focus-visible { background: var(--c-surface); }
.command-item svg { width: 16px; height: 16px; fill: none; stroke: var(--c-muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.command-item small { margin-left: auto; color: var(--c-subtle); font: 10px var(--font-mono); }
.command-empty { padding: 28px 16px; color: var(--c-muted); text-align: center; }

@media (max-width: 1199px) {
  .command-trigger { width: 180px; }
  .top-right .chip-auth:first-of-type { display: none; }
}

@media (max-width: 1023px) {
  body { overflow: hidden; }
  .app { min-height: 100dvh; }
  .sidebar { display: none; }
  .workspace { width: 100%; }
  .topbar {
    min-height: 57px;
    height: auto;
    justify-content: space-between;
    padding: max(10px, env(safe-area-inset-top)) 16px 8px;
    border-bottom: 0;
    background: var(--c-bg);
    backdrop-filter: none;
  }
  .hamburger, .topbar-title, .command-trigger, .top-right .chip-auth, .theme-control { display: none; }
  .mobile-brand { display: flex; min-width: 0; align-items: center; gap: 8px; }
  .mobile-brand-copy { min-width: 0; }
  .mobile-brand-copy span, .mobile-brand-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-brand-copy span { color: var(--c-muted); font-size: 10px; letter-spacing: .12em; }
  .mobile-brand-copy strong { color: var(--c-fg); font-size: 17px; font-weight: 600; line-height: 1.25; }
  .top-right { margin-left: 8px; }
  .topbar .top-right .service-chip { display: flex; min-width: 30px; width: 30px; padding: 0; justify-content: center; border: 0; font-size: 0; }
  .topbar .top-right .service-chip::before { content: ""; width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 999px; }
  .topbar .top-right .service-chip[data-state="server"]::before { background: currentColor; }
  .connection-strip { display: none; }
  .main { padding: 10px 16px calc(66px + env(safe-area-inset-bottom)); }
  .mobile-nav {
    position: relative;
    z-index: 35;
    display: grid;
    min-height: 53px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 4px 0 max(5px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--c-border);
    background: color-mix(in oklab, var(--c-bg-elevated) 88%, transparent);
    backdrop-filter: blur(14px);
  }
  .mobile-nav-item {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-direction: column;
    border: 0;
    background: transparent;
    color: var(--c-muted);
    font-size: 10px;
    cursor: pointer;
  }
  .mobile-nav-item.active { color: var(--c-primary); }
  .mobile-nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-nav-item.active svg { stroke-width: 2.2; }
  .mobile-more-dialog {
    width: 100%;
    max-width: none;
    max-height: min(78dvh, 680px);
    margin: auto 0 0;
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--c-border);
    border-radius: 24px 24px 0 0;
    background: var(--c-bg-elevated);
    color: var(--c-fg);
    box-shadow: var(--sh-float);
  }
  .mobile-more-dialog[open] { display: block; }
  .mobile-more-dialog::backdrop { background: color-mix(in oklab, var(--c-bg) 55%, transparent); }
  .sheet-handle { width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 999px; background: var(--c-border-strong); }
  .sheet-head { display: flex; min-height: 44px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .sheet-head strong { font-size: 14px; font-weight: 500; }
  .sheet-close { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 999px; background: var(--c-surface); color: var(--c-fg); cursor: pointer; }
  .sheet-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .mobile-more-grid { display: grid; max-height: 50dvh; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; overflow-y: auto; }
  .mobile-more-item { display: flex; min-height: 82px; align-items: center; justify-content: center; gap: 7px; padding: 10px 6px; flex-direction: column; border: 0; border-radius: 16px; background: var(--c-bg); color: var(--c-fg); font-size: 11px; text-align: center; cursor: pointer; }
  .mobile-more-item span:first-child { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 14px; background: var(--c-surface); color: var(--c-primary); }
  .mobile-more-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-theme-row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--c-muted); font-size: 12px; }
  .mobile-theme-choices { display: flex; gap: 6px; }
  .mobile-theme-choices .theme-choice { width: 44px; height: 44px; padding: 7px; }
  .command-dialog { margin-top: 10vh; }
}

@media (max-width: 389px) {
  .main { padding-inline: 10px; }
  .mobile-more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
