/* ── OPTIONAL GEMINI API KEY BOX ──
   Collapsible card sitting between the file chip and the Generate button.
   Sized the same way as every other control on this screen
   (width: min(420px, 100%)) so it never looks too small on desktop or
   too cramped on mobile. */
.api-key-box {
    width: min(420px, 100%);
    margin-top: 16px;
    background: #1a1a1e;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.api-key-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: "Poppins", sans-serif;
    color: var(--text-mid);
    -webkit-tap-highlight-color: transparent;
}

.api-key-toggle-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.api-key-icon {
    flex-shrink: 0;
    width: clamp(18px, 4.5vw, 20px);
    height: clamp(18px, 4.5vw, 20px);
    color: var(--text-mid);
}

.api-key-toggle-label {
    font-size: clamp(0.82rem, 3.5vw, 0.92rem);
    font-weight: 600;
    color: var(--text-mid);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.api-key-active-check {
    flex-shrink: 0;
    color: #2e7d32;
    display: none;
}

.api-key-active-check--visible {
    display: inline-block;
}

.api-key-spinner {
    flex-shrink: 0;
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #b9a1ff;
    border-radius: 50%;
    animation: api-key-spin 0.7s linear infinite;
}

.api-key-spinner--visible {
    display: inline-block;
}

@keyframes api-key-spin {
    to {
        transform: rotate(360deg);
    }
}

.api-key-chevron {
    flex-shrink: 0;
    width: clamp(18px, 4.5vw, 20px);
    height: clamp(18px, 4.5vw, 20px);
    color: var(--text-soft);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.api-key-chevron--open {
    transform: rotate(180deg);
}

/* Panel is height-animated via grid-template-rows so it can go from
   0 to auto smoothly without a hardcoded max-height. The single
   .api-key-panel-inner child is what actually gets clipped. */
.api-key-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.22s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.18s ease;
}

.api-key-panel--open {
    grid-template-rows: 1fr;
    opacity: 1;
}

.api-key-panel-inner {
    overflow: hidden;
    min-height: 0;
}

.api-key-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 14px;
    padding: 10px 8px 10px 14px;
    background: #0f0f11;
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.15s ease;
}

.api-key-input-row--valid {
    border-color: #2e7d32;
}

.api-key-input-row--invalid {
    border-color: #EA3323;
}

.api-key-input-row--checking {
    border-color: #b9a1ff;
}

.api-key-input-row--unverified {
    border-color: #c9a227;
}

.api-key-input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--text-mid);
    font-family: "Poppins", sans-serif;
    font-size: clamp(0.82rem, 3.5vw, 0.9rem);
    letter-spacing: 0.5px;
}

.api-key-input::placeholder {
    color: var(--text-soft);
    letter-spacing: normal;
}

.api-key-eye-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 4px;
    background: none;
    border: none;
    color: var(--text-soft);
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.api-key-eye-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dark);
}

.api-key-eye-btn .eye-icon {
    width: clamp(17px, 4.5vw, 19px);
    height: clamp(17px, 4.5vw, 19px);
    display: block;
}

/* Closed (crossed-out) eye shows by default — key starts masked. */
.api-key-eye-btn .eye-icon--open {
    display: none;
}

.api-key-eye-btn--visible .eye-icon--closed {
    display: none;
}

.api-key-eye-btn--visible .eye-icon--open {
    display: block;
}

.api-key-hint {
    margin: 10px 14px 14px;
    font-size: clamp(0.68rem, 3vw, 0.75rem);
    line-height: 1.5;
    color: var(--text-soft);
    transition: color 0.15s ease;
}

.api-key-hint a {
    color: #8b93ff;
    text-decoration: none;
}

.api-key-hint a:hover {
    text-decoration: underline;
}

.api-key-hint--invalid {
    color: #EA3323;
}