/* ============================================
   主标题
   ============================================ */
.main-title {
    font-size: clamp(18px, 1.3vw, 22px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 0;
    color: var(--color-text-primary);
    font-family: var(--font-family-display);
    background: none;
    -webkit-background-clip: border-box;
    -webkit-text-fill-color: currentColor;
    background-clip: border-box;
}

.main-title .accent {
    color: var(--color-brand);
    -webkit-text-fill-color: var(--color-brand);
    position: relative;
}

.subtitle {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.58;
    margin-bottom: 0;
    max-width: 70ch;
    letter-spacing: 0;
}

/* ============================================
   模式切换器 - Segmented Control
   ============================================ */
.segmented-control {
    display: flex;
    background: rgba(255, 255, 255, 0.48);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 14px;
    position: relative;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--color-border-soft);
    backdrop-filter: blur(12px);
}

.segment {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast) var(--ease-smooth), background-color var(--transition-fast) var(--ease-smooth);
    position: relative;
    z-index: 2;
    letter-spacing: 0;
}

.segment:hover {
    color: var(--color-text-primary);
}

.segment.active {
    color: var(--color-brand-dark);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 8px 18px rgba(92, 68, 52, 0.08), inset 0 0 0 1px rgba(200, 121, 99, 0.12);
}

/* ============================================
   卡片列表
   ============================================ */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

/* ============================================
   卡片
   ============================================ */
.card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 251, 247, 0.76));
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition:
        border-color var(--transition-fast) var(--ease-smooth),
        background-color var(--transition-fast) var(--ease-smooth),
        box-shadow var(--transition-fast) var(--ease-smooth),
        transform var(--transition-fast) var(--ease-smooth);
    box-shadow: var(--shadow-card);
    user-select: none;
    will-change: auto;
    border: 1px solid var(--color-border-soft);
    position: relative;
    overflow: hidden;
}

.card:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

.card::before,
.card::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.card::before {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 2px 2px 0;
    background: transparent;
    transition: background var(--transition-fast) var(--ease-smooth);
}

.card::after {
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.55) 0%, transparent 58%);
    opacity: 0;
    transition: opacity var(--transition-fast) var(--ease-smooth);
}

.card:active {
    transform: translateY(0);
    transition: transform var(--transition-instant) var(--ease-smooth);
}

.card.active {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(200, 121, 99, 0.15));
    border-color: rgba(200, 121, 99, 0.28);
    box-shadow: 0 14px 34px rgba(92, 68, 52, 0.12);
}

.card.active::before {
    background: var(--color-brand);
}

.card:hover::after {
    opacity: 0.6;
}

.card.active .card-icon {
    transform: scale(1.05);
}

.card-leading {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(200, 121, 99, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-title);
    font-weight: var(--font-weight-title);
    color: var(--color-brand-dark);
    flex-shrink: 0;
    transition: background-color var(--transition-fast) var(--ease-smooth), color var(--transition-fast) var(--ease-smooth);
    box-shadow: inset 0 0 0 1px rgba(200, 121, 99, 0.08);
}

.card.active .card-icon {
    background: rgba(200, 121, 99, 0.18);
    color: var(--color-brand-dark);
    box-shadow: inset 0 0 0 1px rgba(200, 121, 99, 0.14);
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.card-title > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider-readonly-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    line-height: 1;
    color: #6f4b00;
    background: linear-gradient(135deg, rgba(246, 211, 106, 0.32) 0%, rgba(246, 211, 106, 0.2) 100%);
    border: 1px solid rgba(191, 151, 40, 0.35);
    flex-shrink: 0;
}

.card-subtitle {
    font-size: 12px;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
}

.card-subtitle-model {
    font-weight: 500;
    color: var(--color-text-secondary);
    opacity: 1;
}

.card-subtitle-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    opacity: 0.75;
    margin-top: 2px;
}

.card-trailing {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    column-gap: var(--spacing-xs);
    row-gap: 6px;
    align-items: center;
    justify-content: end;
    align-self: center;
}

.card-trailing .card-actions {
    margin-left: 0;
    justify-self: end;
}

.card-trailing .pill,
.card-trailing .latency {
    justify-self: end;
}

/* 卡片操作按钮 - hover 显示 */
.card-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(4px);
    transition: all var(--transition-normal) var(--ease-spring);
}

.card:hover .card-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.card:focus-within .card-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.mode-cards .card-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.card-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(70, 86, 110, 0.22);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.9));
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast) var(--ease-spring);
    box-shadow: inset 0 1px 2px rgba(31, 26, 23, 0.04);
}

.card-action-btn:hover {
    background: linear-gradient(135deg, rgba(200, 121, 99, 0.1) 0%, rgba(255, 255, 255, 0.95) 100%);
    color: var(--color-text-primary);
    transform: translateY(-1px);
}

.card-action-btn.delete:hover {
    background: linear-gradient(135deg, rgba(200, 74, 58, 0.1) 0%, rgba(200, 74, 58, 0.05) 100%);
    color: var(--color-error);
}

.card-action-btn:disabled,
.card-action-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.1);
}

.card-action-btn.delete:disabled:hover,
.card-action-btn.delete.disabled:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.9));
    color: var(--color-text-secondary);
}

.card-action-btn svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   状态徽章
   ============================================ */
.pill {
    padding: 5px 11px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-caption);
    background-color: rgba(255, 255, 255, 0.8);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all var(--transition-fast) var(--ease-smooth);
    box-shadow: inset 0 0.5px 1px rgba(0, 0, 0, 0.04);
}

.pill.configured {
    background: linear-gradient(135deg, rgba(90, 139, 106, 0.15) 0%, rgba(90, 139, 106, 0.08) 100%);
    color: var(--color-success);
    box-shadow: inset 0 0.5px 1px rgba(90, 139, 106, 0.2);
}

.pill.empty {
    background: linear-gradient(135deg, rgba(200, 74, 58, 0.1) 0%, rgba(200, 74, 58, 0.05) 100%);
    color: var(--color-error);
    box-shadow: inset 0 0.5px 1px rgba(200, 74, 58, 0.15);
}

.latency {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-caption);
    background: var(--color-bg);
    color: var(--color-text-tertiary);
    letter-spacing: 0.02em;
    min-width: 64px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.latency.ok {
    color: var(--color-success);
    background: rgba(90, 139, 106, 0.1);
}

.latency.error {
    color: var(--color-error);
    background: rgba(200, 74, 58, 0.08);
}

.card-action-btn.loading svg {
    animation: spin 0.9s linear infinite;
}

/* ============================================
   图标 - SVG 优化
   ============================================ */
.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-chevron-right {
    color: var(--color-text-tertiary);
    opacity: 0.5;
}

.provider-transform-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    font-size: 14px;
    line-height: 1;
    opacity: 0.6;
    flex-shrink: 0;
    cursor: help;
    transition: opacity 0.2s ease;
}

.provider-transform-icon:hover {
    opacity: 1;
}

.card-icon {
    position: relative;
}

.card-icon-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    border: 1.5px solid var(--color-surface);
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.6), 0 0 8px rgba(34, 197, 94, 0.3);
    animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        box-shadow: 0 0 4px rgba(34, 197, 94, 0.6), 0 0 8px rgba(34, 197, 94, 0.3);
    }
    50% {
        box-shadow: 0 0 10px rgba(34, 197, 94, 0.8), 0 0 18px rgba(34, 197, 94, 0.5);
    }
}

.provider-transform-icon {
    display: none;
}
