/* Session library */
.app-root:has(#tabSessions.active) {
  background: var(--hub-page);
  color: var(--hub-ink);
}

.app-root:has(#tabSessions.active) > .app-header,
#tabSessions[hidden] {
  display: none;
}

.app-root:has(#tabSessions.active) > .app-shell {
  width: min(100%, 888px);
  max-width: none;
  padding: 0 var(--hub-nav-inset) calc(24px + env(safe-area-inset-bottom, 0px));
}

#tabSessions.active {
  display: block;
  padding: 0;
}

#geminiDrawer {
  --surface: var(--hub-paper);
  --surface-subtle: var(--hub-tint);
  --text-primary: var(--hub-ink);
  --text-secondary: var(--hub-muted);
  --text-tertiary: var(--hub-muted);
  --divider: var(--hub-rule);
  --chip-bg: var(--hub-tint);
  --chip-hover: var(--hub-tint);
  background: var(--hub-paper);
}

#geminiDrawer:not(.open) {
  box-shadow: none;
}

.hub-library-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(11px + env(safe-area-inset-top, 0px)) 0 0;
}

.hub-nav-button,
.detail-header .detail-back-btn,
.detail-header .detail-term-btn,
.detail-header .detail-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--hub-rule);
  border-radius: 13px;
  background: var(--hub-paper);
  color: var(--hub-green);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
}

.hub-back-mark {
  width: 8px;
  height: 8px;
  margin-left: 3px;
  border: solid currentColor;
  border-width: 0 0 1.6px 1.6px;
  transform: rotate(45deg);
}

.hub-library-title,
.detail-header .detail-title {
  font-family: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "STSong", "SimSun", serif;
  font-weight: 700;
  letter-spacing: -.045em;
  color: var(--hub-ink);
}

.hub-library-title {
  margin: 25px 0 18px;
  font-size: clamp(24px, 6.6vw, 32px);
  line-height: 1.15;
}

.hub-library-search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--hub-rule);
  border-radius: 14px;
  background: var(--hub-paper);
  color: var(--hub-muted);
}

.hub-library-search:focus-within,
.detail-input-wrap:focus-within {
  border-color: var(--hub-ring);
  box-shadow: 0 0 0 1px var(--hub-ring);
}

.hub-library-search .search-icon {
  position: static;
  flex: none;
  margin: 0;
  transform: none;
  color: var(--hub-green);
}

.hub-library-search input {
  min-width: 0;
  width: 100%;
  min-height: 48px;
  padding: 5px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--hub-ink);
  font: inherit;
  font-size: 16px;
}

.hub-library-search input::placeholder,
.detail-input-wrap textarea::placeholder {
  color: var(--hub-muted);
  opacity: 1;
}

.hub-library-tools,
.hub-library-filters {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hub-library-tools {
  justify-content: space-between;
  min-height: 48px;
  margin: 9px 0 8px;
}

.hub-library-filters {
  flex-wrap: wrap;
}

.hub-library-filters .filter-pill {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: none;
  color: var(--hub-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
  box-shadow: none;
}

.hub-library-filters .filter-pill.active {
  border-color: var(--hub-rule);
  background: var(--hub-tint);
  color: var(--hub-green);
}

.hub-library-count {
  color: var(--hub-muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hub-library-list {
  padding: 0 12px;
  border: 1px solid var(--hub-rule);
  border-radius: 17px;
  background: var(--hub-paper);
}

.hub-library-list .hub-library-row {
  gap: 10px;
  min-height: 74px;
  padding: 10px 0;
  border-radius: 0;
  background: transparent;
}

.hub-library-row + .hub-library-row {
  border-top: 1px solid var(--hub-rule);
}

.hub-library-list .hub-library-row::before {
  display: none;
}

.hub-library-row-icon {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 9px;
  background:
    linear-gradient(var(--hub-green), var(--hub-green)) center 13px / 14px 1px no-repeat,
    linear-gradient(var(--hub-green), var(--hub-green)) 10px 19px / 9px 1px no-repeat,
    var(--hub-tint);
}

.hub-session-running .hub-library-row-icon {
  background:
    radial-gradient(circle, var(--hub-green) 0 3px, transparent 3.5px),
    var(--hub-tint);
}

.hub-library-row-body,
.hub-library-row-end {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.hub-library-row-body {
  flex: 1;
}

.hub-library-row-end {
  justify-items: end;
  color: var(--hub-muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.hub-library-row-title,
.hub-library-row-summary,
.detail-status.running > span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hub-library-row-title {
  color: var(--hub-ink);
  font-size: 14px;
  font-weight: 620;
  line-height: 1.35;
}

.hub-library-row-summary {
  color: var(--hub-muted);
  font-size: 12px;
  line-height: 1.4;
}

.hub-library-row-flags {
  color: var(--hub-green);
  font-size: 10px;
}

.hub-library-empty,
.hub-detail-empty {
  margin: 0;
  padding: 28px 4px;
  color: var(--hub-muted);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}

.hub-library-list .skeleton-row {
  min-height: 67px;
}

/* Conversation reader and composer */
.detail-view {
  --hub-reading-width: 744px;
  background: var(--hub-page);
  color: var(--hub-ink);
}

.detail-header {
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px))
    max(var(--hub-nav-inset), calc((100% - 848px) / 2)) 10px;
  border-bottom: 1px solid var(--hub-rule);
  background: var(--hub-page);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.detail-header .detail-back-btn,
.detail-header .detail-more-btn {
  flex: 0 0 44px;
  padding: 0;
}

.detail-header .detail-more-btn {
  height: 44px;
  width: 44px;
  font-size: 21px;
  line-height: 1;
}

.detail-header-right {
  flex: none;
  gap: 6px;
}

.detail-header .detail-term-btn {
  height: 44px;
  padding: 0 8px;
  gap: 5px;
}

.detail-header .term-ico {
  color: inherit;
  font-size: 12px;
}

.detail-title-group {
  text-align: left;
}

.detail-header .detail-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: clamp(19px, 5.3vw, 24px);
  line-height: 1.18;
  overflow-wrap: anywhere;
  white-space: normal;
}

.detail-header .detail-status {
  display: flex;
  max-width: 100%;
  margin-top: 3px;
  color: var(--hub-muted);
  font-size: 11px;
  line-height: 1.2;
}

.detail-header .detail-status.running {
  color: var(--hub-green);
}

.detail-header .status-pulse-dot {
  background: var(--hub-ring);
}

.detail-messages {
  gap: 23px;
  max-width: var(--hub-reading-width);
  padding: 23px var(--hub-nav-inset) 27px;
}

.detail-messages .msg-row.user .msg-bubble {
  padding: 11px 14px;
  border: 1px solid var(--hub-rule);
  border-radius: 16px 16px 5px 16px;
  background: var(--hub-tint);
  color: var(--hub-ink);
  font-size: 15px;
  line-height: 1.65;
  box-shadow: none;
}

.detail-messages .msg-row.user .msg-bubble.queued {
  border: 1px dashed var(--hub-ring);
}

.detail-messages .queued-pill {
  background: var(--hub-paper);
  color: var(--hub-green);
}

.hub-message-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--hub-green);
  font-size: 12px;
  font-weight: 650;
}

.hub-message-author::before {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--hub-rule);
  border-radius: 8px;
  background: var(--hub-tint);
  color: var(--hub-green);
  content: "✦";
}

.detail-messages .msg-row.assistant .msg-bubble {
  padding: 0 0 4px;
  color: var(--hub-ink);
  font-size: 16px;
  line-height: 1.75;
}

.detail-messages .md-content p {
  margin-bottom: 11px;
}

.detail-messages .md-content p:last-child {
  margin-bottom: 0;
}

.detail-messages .md-content :is(h1, h2, h3) {
  margin-bottom: 7px;
  color: var(--hub-ink);
  font-size: 17px;
  line-height: 1.45;
}

.detail-messages .md-content :is(a, .tool-collapse summary) {
  color: var(--hub-green);
}

.detail-messages .md-content :is(.inline-code, blockquote),
.detail-messages .tool-collapse-list {
  border-color: var(--hub-rule);
  background: var(--hub-tint);
  color: var(--hub-ink);
}

.detail-messages .md-content blockquote {
  border-left-color: var(--hub-ring);
}

.detail-messages .msg-action-bar {
  flex-wrap: wrap;
  gap: 3px;
  padding: 0;
  margin-top: 5px;
}

.detail-messages .msg-time {
  color: var(--hub-muted);
  font-variant-numeric: tabular-nums;
}

.detail-messages .msg-row .msg-act-btn,
.detail-messages .tool-collapse summary {
  min-height: 32px;
  color: var(--hub-muted);
  background: transparent;
}

.detail-messages .msg-act-btn.active,
.detail-messages .msg-act-btn.retry-btn {
  color: var(--hub-green);
}

.detail-messages .tool-collapse summary {
  border: 1px solid var(--hub-rule);
  border-radius: 9px;
  background: var(--hub-paper);
}

.detail-messages .gemini-thinking {
  gap: 6px;
  padding: 4px 5px 4px 9px;
  border: 1px solid var(--hub-rule);
  border-radius: 11px;
  background: var(--hub-paper);
}

.detail-messages :is(.gemini-spark, .thinking-text) {
  background: none;
  color: var(--hub-green);
  -webkit-text-fill-color: currentColor;
}

.detail-messages .thinking-dots span {
  background: var(--hub-ring);
}

.detail-messages .thinking-tool-badge {
  background: var(--hub-tint);
  color: var(--hub-green);
}

.detail-messages .stop-task-inline-btn {
  min-height: 34px;
}

.detail-composer {
  align-items: center;
  padding: 9px var(--hub-nav-inset) calc(9px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hub-rule);
  background: var(--hub-page);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.detail-input-wrap,
.detail-composer .detail-previews {
  max-width: calc(var(--hub-reading-width) - var(--hub-nav-inset) * 2);
  width: 100%;
}

.detail-input-wrap {
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--hub-rule);
  border-radius: 15px;
  background: var(--hub-paper);
}

.detail-input-wrap textarea,
.detail-input-wrap textarea:focus {
  min-height: 44px;
  padding: 11px 1px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--hub-ink);
  font-size: 16px;
  line-height: 1.4;
}

.detail-input-wrap .img-attach-btn,
.detail-input-wrap .detail-send-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--hub-tint);
  color: var(--hub-green);
}

.detail-input-wrap .detail-send-btn {
  background: var(--hub-send-bg);
  color: var(--hub-send-ink);
}

.detail-composer:has(.detail-previews[hidden]) .detail-input-wrap:has(textarea:placeholder-shown) .detail-send-btn {
  background: var(--hub-tint);
  color: var(--hub-green);
}

.detail-view .scroll-bottom-btn {
  right: max(var(--hub-nav-inset), calc((100% - var(--hub-reading-width)) / 2 + var(--hub-nav-inset)));
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  width: 44px;
  height: 44px;
  border: 1px solid var(--hub-rule);
  border-radius: 13px;
  background: var(--hub-paper);
  color: var(--hub-green);
  box-shadow: none;
}

/* Detail actions and Bot editor */
.action-sheet-backdrop,
.bot-edit-backdrop {
  background: rgba(10, 26, 18, .42);
  padding-inline: var(--hub-nav-inset);
}

.action-sheet {
  max-height: 100%;
  overflow-y: auto;
}

.action-group,
.action-cancel,
.bot-edit-card {
  background: var(--hub-paper);
  color: var(--hub-ink);
  border: 1px solid var(--hub-rule);
  border-radius: 17px;
}

.hub-action-heading {
  margin: 0;
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--hub-rule);
  color: var(--hub-muted);
  font-size: 13px;
  font-weight: 600;
}

.action-item {
  min-height: 46px;
  padding: 0 16px;
  border-bottom-color: var(--hub-rule);
  color: var(--hub-ink);
  font-size: 14px;
  text-align: left;
}

.action-cancel {
  min-height: 46px;
  padding: 0 16px;
  color: var(--hub-green);
  font-size: 14px;
}

.action-item:active,
.action-cancel:active,
.bot-preset-chip:active {
  background: var(--hub-tint);
}

.bot-edit-backdrop {
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

.bot-edit-card {
  max-height: 100%;
  overflow-y: auto;
  padding: 15px;
}

.bot-edit-head h3 {
  color: var(--hub-ink);
}

.bot-edit-close {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--hub-tint);
  color: var(--hub-green);
}

.bot-edit-desc,
.bot-edit-note {
  color: var(--hub-muted);
}

.bot-preset-chip {
  min-height: 37px;
  border-color: var(--hub-rule);
  border-radius: 9px;
  background: var(--hub-tint);
  color: var(--hub-green);
}

.bot-edit-card textarea {
  border-color: var(--hub-rule);
  background: var(--hub-page);
  color: var(--hub-ink);
  font-size: 16px;
}

.bot-edit-card textarea:focus {
  border-color: var(--hub-ring);
}

.bot-edit-card .bot-edit-save {
  min-height: 44px;
  background: var(--hub-send-bg);
  color: var(--hub-send-ink);
}

#tabSessions button:focus-visible,
.detail-view button:focus-visible,
.action-sheet button:focus-visible,
.bot-edit-card button:focus-visible {
  outline: 2px solid var(--hub-ring);
  outline-offset: -2px;
}

@media (hover: hover) {
  .hub-nav-button:hover,
  .hub-library-list .hub-library-row:hover,
  .hub-library-filters .filter-pill:hover,
  .detail-header button:hover,
  .detail-messages .msg-row .msg-act-btn:hover,
  .action-item:hover {
    background: var(--hub-tint);
  }
}

@media (min-width: 690px) {
  .hub-library-nav {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }

  .hub-library-title {
    margin-top: 29px;
  }

  .hub-library-list {
    padding: 0 16px;
  }

  .hub-library-list .hub-library-row {
    gap: 13px;
  }
}

@media (max-width: 440px) {
  .detail-header .term-txt {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail-view,
  .detail-view .status-pulse-dot,
  .detail-view .thinking-dots span,
  .action-sheet,
  .bot-edit-card {
    animation: none;
  }
}
