/* Shared Hub colors, followed by the home workspace layout. */
:root {
  --hub-page: #f5f5ef;
  --hub-paper: #fdfdf9;
  --hub-ink: #182820;
  --hub-muted: #58675d;
  --hub-rule: #dce3d9;
  --hub-tint: #eaf0e6;
  --hub-green: #28533e;
  --hub-send-bg: #204833;
  --hub-send-ink: #fbfff6;
  --hub-ring: #4c795c;
  --hub-nav-inset: max(20px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
}

.app-root:has(#tabHome.active) {
  color: var(--hub-ink);
  background: var(--hub-page);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hub-page: #141a17;
    --hub-paper: #1e2721;
    --hub-ink: #edf4ea;
    --hub-muted: #aab9ad;
    --hub-rule: #344239;
    --hub-tint: #29382e;
    --hub-green: #bed8b9;
    --hub-send-bg: #c0d8a5;
    --hub-send-ink: #172a1f;
    --hub-ring: #aac58e;
  }
}

body[data-engine="agy"] #statusPill.hub-connection {
  display: none;
}

:root body[data-engine="agy"] .app-root:has(#tabHome.active) > header.app-header,
:root body[data-engine="agy"] .app-root:has(#tabHome.active) > .app-shell {
  background: var(--hub-page) !important;
}

.app-root:has(#tabHome.active) > header.app-header {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 11px;
  width: min(100%, 888px);
  max-width: none;
  padding: calc(env(safe-area-inset-top, 0px) + 11px) var(--hub-nav-inset) 11px;
  border: 0;
}

.app-root:has(#tabHome.active) .app-header-menu {
  width: 44px;
  height: 44px;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 1px solid var(--hub-rule);
  border-radius: 13px;
  background: var(--hub-paper);
}

.app-root:has(#tabHome.active) .menu-line {
  background: var(--hub-green);
}

.app-root:has(#tabHome.active) .app-header-menu .menu-line:first-child {
  width: 17px;
}

.app-root:has(#tabHome.active) .app-header-menu .menu-line.short {
  width: 11px;
  margin-right: 6px;
}

.app-root:has(#tabHome.active) > header.app-header .app-header-title {
  justify-self: start;
  margin: 0;
  color: var(--hub-ink);
  font-size: 21px;
  font-weight: 690;
  letter-spacing: -0.05em;
}

.app-root:has(#tabHome.active) .app-header-actions {
  display: none;
}

body[data-engine="agy"]:has(#tabHome.active) header.app-header #statusPill.hub-connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  margin: 0 -4px 0 0;
  padding: 0 4px 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--hub-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}

body[data-engine="agy"] #statusPill.hub-connection #statusDot.status-dot {
  width: 7px;
  height: 7px;
  margin: 0;
  background: #9b9e86;
  box-shadow: none;
}

body[data-engine="agy"] #statusPill.hub-connection #statusDot.status-dot.online {
  background: #629460;
}

body[data-engine="agy"] #statusPill.hub-connection #statusDot.status-dot.offline {
  background: #b88442;
}

body[data-engine="agy"] #statusPill.hub-connection #statusDot.status-dot.running {
  background: #619795;
}

body:has(#tabHome.active) .app-shell {
  display: block;
  width: min(100%, 888px);
  max-width: none;
  overflow-y: auto;
  padding: 0;
}

#tabHome.tab-panel[hidden] {
  display: none;
}

#tabHome.tab-panel.active {
  display: block;
  height: auto;
  min-height: 100%;
}

.hub-workspace {
  display: grid;
  gap: 17px;
  padding: 4px var(--hub-nav-inset) calc(env(safe-area-inset-bottom, 0px) + 25px);
}

.hub-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: end;
  min-height: clamp(172px, 48vw, 222px);
  overflow: hidden;
  padding: 22px;
  border-radius: 21px;
  background: #10231b;
  color: #f4f7e9;
}

.hub-hero::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, #10231b 0%, #10231b 9%, rgba(16, 35, 27, .8) 37%, transparent 75%),
    linear-gradient(0deg, rgba(9, 26, 18, .7), transparent 55%),
    url("./hub-hero-glass.webp?v=1") right center / auto 135% no-repeat;
  content: "";
}

.hub-hero-copy {
  max-width: 100%;
}

.hub-engine-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  color: #c3d4af;
  font-size: 12px;
  font-weight: 560;
  letter-spacing: .11em;
}

.hub-engine-label::before {
  width: 14px;
  height: 1px;
  background: currentColor;
  content: "";
}

.hub-hero h2 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "STSong", "SimSun", serif;
  font-size: clamp(32px, 9vw, 44px);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.hub-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 17px;
}

.hub-composer {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 14px 15px 10px;
  border: 1px solid var(--hub-rule);
  border-radius: 18px;
  background: var(--hub-paper);
  box-shadow: 0 4px 15px rgba(34, 60, 41, .035);
}

.hub-composer:focus-within {
  border-color: var(--hub-ring);
  box-shadow: 0 0 0 1px var(--hub-ring);
}

.hub-composer-heading,
.hub-composer-actions,
.hub-recent-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hub-composer-heading h3,
.hub-recent-heading h3 {
  margin: 0;
  color: var(--hub-ink);
  font-size: 15px;
  font-weight: 660;
  letter-spacing: -.015em;
}

.hub-composer-model {
  color: var(--hub-muted);
  font-size: 11px;
  font-weight: 540;
  white-space: nowrap;
}

.hub-prompt {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 120px;
  margin: 0;
  padding: 4px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--hub-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
}

.hub-prompt::placeholder {
  color: var(--hub-muted);
  opacity: 1;
}

.hub-composer .img-preview-bar {
  padding: 4px 0;
}

.hub-attach,
.hub-send,
.hub-shortcuts button,
.hub-all-sessions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 570;
  color: var(--hub-green);
  cursor: pointer;
}

.hub-attach {
  margin-left: -5px;
  padding: 0 8px 0 5px;
  border-radius: 8px;
  background: transparent;
}

.hub-send {
  flex: none;
  padding: 0 12px;
  border-radius: 11px;
  background: var(--hub-send-bg);
  color: var(--hub-send-ink);
}

.hub-composer:has(.hub-prompt:placeholder-shown):not(:has(.img-preview-bar:not([hidden]))) .hub-send {
  background: var(--hub-tint);
  color: var(--hub-green);
}

.hub-send:disabled {
  opacity: .65;
  cursor: progress;
}

.hub-attach svg {
  width: 19px;
  height: 19px;
}

.hub-send svg,
.hub-shortcuts svg {
  width: 16px;
  height: 16px;
}

.hub-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.hub-shortcuts button {
  padding: 0 10px;
  border: 1px solid var(--hub-rule);
  border-radius: 11px;
  background: transparent;
}

.hub-recent-heading {
  padding: 0 1px 2px;
}

.hub-recent-heading h3 {
  font-size: 16px;
}

.hub-all-sessions {
  gap: 5px;
  padding: 0 3px 0 8px;
  border-radius: 8px;
  background: transparent;
  white-space: nowrap;
}

.hub-all-sessions span {
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}

.hub-recent-list {
  padding: 0 11px;
  border: 1px solid var(--hub-rule);
  border-radius: 16px;
  background: var(--hub-paper);
}

.hub-recent-list .session-item.single-line-item {
  min-height: 53px;
  padding: 6px 0;
  gap: 8px;
  background: none;
  color: var(--hub-ink);
}

.hub-recent-list .session-item.single-line-item + .session-item.single-line-item {
  border-top: 1px solid var(--hub-rule);
}

.hub-recent-list .session-item.single-line-item::before {
  display: none;
}

.hub-recent-list .session-code-idx,
.hub-recent-list .session-code-state.idle {
  display: none;
}

.hub-recent-list .session-main {
  gap: 9px;
}

.hub-recent-list .session-main::before {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  background:
    linear-gradient(var(--hub-green), var(--hub-green)) center 11px / 12px 1px no-repeat,
    linear-gradient(var(--hub-green), var(--hub-green)) 8px 16px / 8px 1px no-repeat,
    var(--hub-tint);
  content: "";
}

.hub-recent-list .hub-session-running .session-main::before {
  background:
    radial-gradient(circle, var(--hub-green) 0 3px, transparent 3.5px),
    var(--hub-tint);
}

.hub-recent-list .session-code-state.running {
  order: 1;
  color: var(--hub-green);
  font: inherit;
  font-size: 10px;
  white-space: nowrap;
}

.hub-recent-list .session-title-inline {
  color: var(--hub-ink);
  font-size: 13px;
  font-weight: 550;
}

.hub-recent-list .session-right {
  gap: 6px;
}

.hub-recent-list .session-chevron,
.hub-recent-list .session-time-inline {
  color: var(--hub-muted);
}

.hub-recent-list .session-time-inline {
  font-size: 11px;
  white-space: nowrap;
}

.hub-recent-list .skeleton-row {
  min-height: 53px;
}

.hub-recent-empty {
  margin: 0;
  padding: 19px 3px;
  color: var(--hub-muted);
  font-size: 13px;
  line-height: 1.5;
}

.app-root:has(#tabHome.active) .app-header-menu:focus-visible,
.app-root:has(#tabHome.active) .hub-connection:focus-visible,
.hub-workspace button:focus-visible {
  outline: 2px solid var(--hub-ring);
  outline-offset: 2px;
}

@media (hover: hover) {
  .hub-shortcuts button:hover,
  .hub-recent-list .session-item.single-line-item:hover,
  .hub-attach:hover,
  .hub-all-sessions:hover {
    background: var(--hub-tint);
  }

  .hub-send:hover:not(:disabled) {
    filter: brightness(1.12);
  }
}

@media (min-width: 690px) {
  .app-root:has(#tabHome.active) > header.app-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
    padding-bottom: 16px;
  }

  .hub-workspace {
    gap: 23px;
  }

  .hub-hero {
    min-height: 227px;
    padding: 31px;
    border-radius: 24px;
  }

  .hub-hero::before {
    background:
      linear-gradient(90deg, #10231b 12%, #10231b 36%, transparent 80%),
      linear-gradient(0deg, rgba(9, 26, 18, .38), transparent 68%),
      url("./hub-hero-glass.webp?v=1") right center / auto 155% no-repeat;
  }

  .hub-hero h2 {
    font-size: 48px;
  }

  .hub-engine-label {
    margin-bottom: 13px;
  }

  .hub-workspace-grid {
    grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr);
    gap: 22px;
  }

  .hub-composer {
    padding: 15px 17px 12px;
  }

  .hub-prompt {
    min-height: 71px;
  }

  .hub-recent-heading {
    margin-top: -5px;
  }
}

@media (max-width: 350px) {
  .app-root:has(#tabHome.active) {
    --hub-nav-inset: max(14px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 689px) and (max-height: 720px) {
  .hub-workspace {
    gap: 13px;
  }

  .hub-hero {
    min-height: 162px;
  }

  .hub-workspace-grid {
    gap: 12px;
  }
}
