/* ========== 会话面板 ========== */
.sessions-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 2px;
  border-bottom: 0;
  margin-bottom: 0;
}

.panel-header h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.sessions-header {
  gap: 8px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.session-list {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.session-item-wrapper {
  display: block;
  min-width: 0;
}

.session-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px max-content;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 7px 7px 7px 9px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: all var(--transition-base);
  position: relative;
}

.session-item:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text-muted) 28%, transparent);
  outline-offset: 1px;
}

.session-item:hover,
.session-item:focus-visible,
.session-item.active {
  background: color-mix(in srgb, var(--panel-strong) 58%, var(--bg-subtle));
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border-subtle));
  box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .session-item:hover,
[data-theme="dark"] .session-item:focus-visible,
[data-theme="dark"] .session-item.active {
  background: color-mix(in srgb, var(--bg-subtle) 72%, transparent);
}

.session-key {
  display: block;
  min-width: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-response-spinner {
  width: 12px;
  height: 12px;
  justify-self: center;
  border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
}

.session-item.responding .session-response-spinner {
  opacity: 1;
  visibility: visible;
  animation: session-response-spin 850ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .session-item.responding .session-response-spinner {
    animation: none;
  }
}

@keyframes session-response-spin {
  to {
    transform: rotate(360deg);
  }
}

.session-delete {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  font-size: 14px;
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
}

.session-item-wrapper:hover .session-delete,
.session-item-wrapper:focus-within .session-delete,
.session-delete:hover {
  opacity: 1;
  visibility: visible;
  background: transparent;
}

.session-delete:focus-visible {
  opacity: 1;
  visibility: visible;
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.session-delete.confirming {
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 600;
  opacity: 1;
  visibility: visible;
}

.session-delete.confirming:hover,
.session-delete.confirming:focus-visible {
  background: color-mix(in srgb, var(--danger) 86%, black);
}

/* ========== 系统状态面板 ========== */
.status-panel {
  padding-top: 0;
  border-top: 1px solid var(--border-subtle);
}

.composer-status-panel {
  display: block;
  flex: 1 1 520px;
  min-width: 280px;
  padding-top: 0;
  border-top: 0;
}

.composer-status-panel[hidden] {
  display: none;
}

.status-panel .panel-header {
  padding: 8px 0;
  margin-bottom: 6px;
}

.composer-status-panel .panel-header {
  display: none;
}

.system-status {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel-strong) 48%, var(--bg-subtle));
  overflow: hidden;
}

.composer-status-panel .system-status {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  align-items: center;
  justify-content: start;
  gap: 6px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--panel-strong) 18%, transparent);
  border-radius: 0;
}

.composer-status-panel .status-item {
  min-width: 0;
  justify-content: flex-start;
  gap: 5px;
  padding: 0;
  border: 0;
}

.status-item + .status-item {
  border-top: 1px solid var(--border-subtle);
}

.composer-status-panel .status-item + .status-item {
  border-top: 0;
}

.status-label {
  font-size: 11px;
  color: var(--text-muted);
}

.status-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.composer-status-panel .status-label {
  flex: 0 0 auto;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.composer-status-panel .status-value {
  max-width: 100%;
  font-size: 9px;
}

.composer-status-panel #status-channel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 10px;
  overflow: hidden;
  color: transparent;
  font-size: 0;
}

.composer-status-panel #status-channel::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-subtle);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-subtle) 12%, transparent);
}

.composer-status-panel #status-channel.status-ok::before {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.composer-status-panel #status-channel.status-warn::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* Token Usage Progress Bar */
.usage-item {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.usage-display {
  width: 100%;
}

.composer-status-panel .usage-item {
  flex-direction: row;
  align-items: center;
}

.composer-status-panel .usage-bar-wrapper {
  display: grid;
  grid-template-columns: 40px max-content;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.composer-status-panel .usage-detail,
.composer-status-panel .usage-cached {
  display: none;
}

.composer-status-panel .usage-bar-text {
  display: block;
  min-width: 54px;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

.usage-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.usage-bar-track {
  width: 100%;
  height: 3px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  overflow: hidden;
  position: relative;
}

.usage-bar-fill {
  height: 100%;
  border-radius: var(--radius-xs);
  transition: width var(--transition-base), background-color var(--transition-base);
  position: relative;
}

/* Progress bar colors based on usage ratio */
.usage-bar-safe {
  background: var(--success);
}

.usage-bar-caution {
  background: color-mix(in srgb, var(--success) 62%, var(--warning));
}

.usage-bar-warning {
  background: var(--warning);
}

.usage-bar-danger {
  background: var(--danger);
}

.usage-bar-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 10px;
  font-family: var(--font-mono);
}

.usage-detail {
  color: var(--text-muted);
}

.usage-total {
  color: var(--text);
  font-weight: 500;
}

.usage-cached {
  color: var(--success);
  font-weight: 500;
}

[data-theme="dark"] .usage-bar-track {
  background: var(--bg-subtle);
}

.status-ok {
  color: var(--success);
}

.status-warn {
  color: var(--warning);
}
