/* ═══════════════════════════════════════════════════════════════════════════════
   SMART SENTENCES - Sidebar Layout with Always-Visible Queue
   Scanner HUD Terminal Aesthetic • Component Analyzer-inspired
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════
   CSS VARIABLES - Teal/Cyan theme
   ═══════════════════════════════════════════════════════════════════════════════ */
.smart-sentences-modal {
    --ss-primary: #14b8a6;           /* Teal-500 */
    --ss-primary-light: #2dd4bf;     /* Teal-400 */
    --ss-primary-dark: #0d9488;      /* Teal-600 */
    --ss-primary-glow: rgba(20, 184, 166, 0.3);
    --ss-accent: #06b6d4;            /* Cyan-500 for accents */
    --ss-accent-glow: rgba(6, 182, 212, 0.2);
    --ss-success: #22c55e;
    --ss-success-glow: rgba(34, 197, 94, 0.3);
    --ss-warning: #f59e0b;
    --ss-danger: #ef4444;
    --ss-bg-deep: #0a0f14;
    --ss-bg-panel: #0f1419;
    --ss-bg-card: #151c24;
    --ss-bg-sidebar: #0d1117;
    --ss-border: rgba(20, 184, 166, 0.25);
    --ss-border-subtle: rgba(20, 184, 166, 0.12);
    --ss-text: #e2e8f0;
    --ss-text-muted: #94a3b8;
    --ss-text-dim: #64748b;
    
    /* Sidebar sizing */
    --ss-sidebar-width: 320px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MODAL CONTAINER
   ═══════════════════════════════════════════════════════════════════════════════ */
.smart-sentences-modal {
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 5, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.ss-container {
    position: relative;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    border-radius: 20px;
    border: 1px solid var(--ss-border);
    background: var(--ss-bg-panel);
    box-shadow:
        0 0 80px var(--ss-primary-glow),
        0 25px 50px -12px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SCANLINES OVERLAY
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    border-radius: 20px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(20, 184, 166, 0.012) 2px,
        rgba(20, 184, 166, 0.012) 4px
    );
    animation: ss-scanline-drift 10s linear infinite;
}

@keyframes ss-scanline-drift {
    0% { background-position: 0 0; }
    100% { background-position: 0 100px; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   STACKED LAYOUT (default - history at bottom)
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-layout {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 85vh;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HISTORY SIDEBAR - Always at bottom in stacked layout
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-sidebar {
    width: 100%;
    max-height: 30vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--ss-bg-sidebar);
    border-top: 1px solid var(--ss-border-subtle);
    border-radius: 0 0 20px 20px;
    order: 2; /* Push to bottom */
}

.ss-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ss-border-subtle);
    background: linear-gradient(90deg, rgba(20, 184, 166, 0.06), transparent);
}

.ss-sidebar-header .ss-section-label {
    margin-bottom: 0;
}

.ss-header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ss-font-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ss-font-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--ss-border-subtle);
    background: transparent;
    color: var(--ss-text-dim);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ss-font-btn:hover {
    background: var(--ss-bg-panel);
    border-color: var(--ss-primary);
    color: var(--ss-primary-light);
}

.ss-font-btn:active {
    transform: scale(0.95);
}

.ss-sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--ss-border-subtle);
    background: linear-gradient(180deg, transparent, rgba(20, 184, 166, 0.03));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    order: 1; /* Main content first */
    border-radius: 20px 20px 0 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--ss-border-subtle);
    background: linear-gradient(90deg, 
        rgba(20, 184, 166, 0.06) 0%, 
        transparent 50%, 
        rgba(20, 184, 166, 0.06) 100%
    );
}

.ss-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ss-logo-glyph {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--ss-primary);
    text-shadow: 0 0 25px var(--ss-primary-glow);
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic Pro", sans-serif;
}

.ss-header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ss-text);
    letter-spacing: 0.06em;
}

.ss-header-subtitle {
    font-size: 0.7rem;
    color: var(--ss-primary);
    opacity: 0.7;
    font-family: monospace;
    letter-spacing: 0.02em;
}

.ss-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ss-close-btn {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    border: 1px solid var(--ss-border-subtle);
    background: transparent;
    color: var(--ss-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ss-close-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar */
.ss-content::-webkit-scrollbar {
    width: 6px;
}

.ss-content::-webkit-scrollbar-track {
    background: var(--ss-bg-deep);
}

.ss-content::-webkit-scrollbar-thumb {
    background: var(--ss-border);
    border-radius: 3px;
}

.ss-content::-webkit-scrollbar-thumb:hover {
    background: var(--ss-primary-dark);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION LABELS
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ss-primary);
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.ss-section-label svg {
    width: 1rem;
    height: 1rem;
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PRESET CARDS
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

.ss-preset-card {
    position: relative;
    padding: 1.125rem;
    border-radius: 12px;
    border: 1px solid var(--ss-border-subtle);
    background: var(--ss-bg-card);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    overflow: hidden;
}

.ss-preset-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--ss-primary-glow) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

.ss-preset-card:hover {
    border-color: var(--ss-border);
    transform: translateY(-2px);
}

.ss-preset-card:hover::before {
    opacity: 1;
}

.ss-preset-card.active {
    border-color: var(--ss-primary);
    box-shadow: 0 0 25px var(--ss-primary-glow), inset 0 0 30px rgba(20, 184, 166, 0.05);
}

.ss-preset-card.active::before {
    opacity: 1;
}

.ss-preset-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.ss-preset-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.ss-preset-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ss-preset-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ss-text);
}

.ss-preset-check {
    margin-left: auto;
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 50%;
    border: 2px solid var(--ss-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ss-preset-card.active .ss-preset-check {
    background: var(--ss-primary);
    border-color: var(--ss-primary);
}

.ss-preset-check svg {
    width: 0.8rem;
    height: 0.8rem;
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ss-preset-card.active .ss-preset-check svg {
    opacity: 1;
}

.ss-preset-desc {
    position: relative;
    z-index: 1;
    font-size: 0.8rem;
    color: var(--ss-text-muted);
    line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   i+1 FEATURED PRESET - Premium positioning
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-preset-featured {
    grid-column: 1 / -1;
    border: 2px solid transparent;
    background: 
        linear-gradient(var(--ss-bg-card), var(--ss-bg-card)) padding-box,
        linear-gradient(135deg, #06b6d4, #14b8a6, #22c55e) border-box;
    position: relative;
}

.ss-preset-featured::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, 
        rgba(6, 182, 212, 0.1) 0%, 
        rgba(20, 184, 166, 0.06) 50%,
        rgba(34, 197, 94, 0.04) 100%);
    opacity: 1;
    transition: none;
}

.ss-preset-featured::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    background: linear-gradient(135deg, #06b6d4, #14b8a6, #22c55e);
    opacity: 0;
    z-index: -1;
    filter: blur(15px);
    transition: opacity 0.15s ease-out;
}

.ss-preset-featured:hover::after,
.ss-preset-featured.active::after {
    opacity: 0.5;
}

.ss-preset-featured.active {
    box-shadow: 
        0 0 35px rgba(6, 182, 212, 0.35),
        0 0 70px rgba(20, 184, 166, 0.15),
        inset 0 0 30px rgba(20, 184, 166, 0.05);
}

.ss-preset-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 4px;
    background: linear-gradient(135deg, #06b6d4, #14b8a6);
    color: white;
    margin-left: 0.5rem;
}

.ss-preset-featured .ss-preset-name {
    font-size: 1.05rem;
    background: linear-gradient(135deg, #06b6d4, #14b8a6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ss-preset-featured .ss-preset-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(20, 184, 166, 0.08));
    border: 1px solid rgba(6, 182, 212, 0.25);
    padding: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   GENERATE BUTTON
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-generate-section {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.ss-generate-btn {
    width: 100%;
    padding: 1.125rem 1.75rem;
    border-radius: 12px;
    border: 1px solid var(--ss-primary);
    background: linear-gradient(135deg, var(--ss-primary-dark), var(--ss-primary));
    color: white;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    position: relative;
    overflow: hidden;
}

.ss-generate-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.ss-generate-btn:hover:not(:disabled)::before {
    transform: translateX(100%);
}

.ss-generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px var(--ss-primary-glow);
}

.ss-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ss-generate-btn svg {
    width: 1.375rem;
    height: 1.375rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SCANNER HUD - Processing State
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-scanner-hud {
    position: relative;
    padding: 2.5rem;
    border-radius: 14px;
    border: 1px solid var(--ss-border);
    background: var(--ss-bg-card);
    overflow: hidden;
    /* Fill available space when visible */
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
}

/* Ensure hidden state works with flex */
.ss-scanner-hud.hidden {
    display: none !important;
}

.ss-scanner-hud.processing {
    border-color: var(--ss-primary);
    box-shadow: 0 0 40px var(--ss-primary-glow);
}

.ss-scanner-hud.success {
    border-color: var(--ss-success);
    box-shadow: 0 0 40px var(--ss-success-glow);
}

.ss-scanner-hud.error {
    border-color: var(--ss-danger);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.3);
}

/* Scanner beam animation */
.ss-scanner-beam {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--ss-primary), 
        var(--ss-primary-light), 
        var(--ss-primary), 
        transparent
    );
    opacity: 0;
    animation: none;
}

.ss-scanner-hud.processing .ss-scanner-beam {
    opacity: 0.5;
    animation: ss-scan-sweep 1.5s ease-in-out forwards;
}

@keyframes ss-scan-sweep {
    0% { top: 0; opacity: 0.6; }
    100% { top: calc(100% - 2px); opacity: 0; }
}

/* Pulsing corners */
.ss-scanner-corner {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid var(--ss-primary);
    opacity: 0.3;
}

.ss-scanner-corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.ss-scanner-corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.ss-scanner-corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.ss-scanner-corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

.ss-scanner-hud.processing .ss-scanner-corner {
    animation: ss-corner-pulse 1.5s ease-in-out infinite;
}

@keyframes ss-corner-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Scanner content */
.ss-scanner-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.ss-scanner-status {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ss-primary);
    margin-bottom: 0.875rem;
}

.ss-scanner-hud.success .ss-scanner-status {
    color: var(--ss-success);
}

.ss-scanner-hud.error .ss-scanner-status {
    color: var(--ss-danger);
}

.ss-scanner-message {
    font-size: 1.05rem;
    color: var(--ss-primary-light);
    min-height: 1.5em;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px var(--ss-primary-glow);
    line-height: 1.6;
}

.ss-scanner-hud.success .ss-scanner-message {
    color: var(--ss-success);
    text-shadow: 0 0 10px var(--ss-success-glow);
}

.ss-scanner-hud.error .ss-scanner-message {
    color: var(--ss-danger);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

/* Slow state (approaching estimate) */
.ss-scanner-hud.scanner-slow {
    border-color: #f59e0b;
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.3);
}

.ss-scanner-hud.scanner-slow .ss-scanner-status { color: #f59e0b; }
.ss-scanner-hud.scanner-slow .ss-scanner-message { color: #fbbf24; text-shadow: 0 0 10px rgba(245, 158, 11, 0.3); }
.ss-scanner-hud.scanner-slow .ss-scanner-beam { background: linear-gradient(90deg, transparent, #f59e0b, #fbbf24, #f59e0b, transparent); }
.ss-scanner-hud.scanner-slow .ss-scanner-corner { border-color: #f59e0b; }
.ss-scanner-hud.scanner-slow .ss-scanner-progress-bar { background: linear-gradient(90deg, #d97706, #fbbf24); }

/* Critical state (overrun) */
.ss-scanner-hud.scanner-critical {
    border-color: #ef4444;
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.3);
}

.ss-scanner-hud.scanner-critical .ss-scanner-status { color: #ef4444; }
.ss-scanner-hud.scanner-critical .ss-scanner-message { color: #f87171; text-shadow: 0 0 10px rgba(239, 68, 68, 0.3); }
.ss-scanner-hud.scanner-critical .ss-scanner-beam { background: linear-gradient(90deg, transparent, #ef4444, #f87171, #ef4444, transparent); }
.ss-scanner-hud.scanner-critical .ss-scanner-corner { border-color: #ef4444; animation-duration: 0.75s; }
.ss-scanner-hud.scanner-critical .ss-scanner-progress-bar { background: linear-gradient(90deg, #dc2626, #f87171); }

/* Error state progress bar */
.ss-scanner-hud.error .ss-scanner-progress-bar { background: linear-gradient(90deg, #dc2626, #f87171); }

.ss-scanner-timer {
    font-size: 0.7rem;
    font-family: monospace;
    color: var(--ss-text-dim);
    opacity: 0.7;
}

.ss-scanner-progress {
    margin-top: 1.25rem;
    height: 4px;
    border-radius: 2px;
    background: var(--ss-bg-deep);
    overflow: hidden;
}

.ss-scanner-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ss-primary-dark), var(--ss-primary-light));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Cancel button - subtle, only visible during processing */
.ss-cancel-btn {
    margin-top: 1.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ss-text-muted);
    background: transparent;
    border: 1px solid var(--ss-border-subtle);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.ss-cancel-btn:hover {
    opacity: 1;
    color: var(--ss-danger);
    border-color: var(--ss-danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Hide cancel button when not processing */
.ss-scanner-hud.success .ss-cancel-btn,
.ss-scanner-hud.error .ss-cancel-btn {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   QUEUE - SIDEBAR LAYOUT
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-queue-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.5rem;
    border-radius: 8px;
    background: var(--ss-bg-card);
    border: 1px solid var(--ss-border-subtle);
}

.ss-queue-count {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--ss-primary);
    font-family: monospace;
}

/* Queue List */
.ss-queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* Custom scrollbar for queue */
.ss-queue-list::-webkit-scrollbar {
    width: 5px;
}

.ss-queue-list::-webkit-scrollbar-track {
    background: transparent;
}

.ss-queue-list::-webkit-scrollbar-thumb {
    background: var(--ss-border);
    border-radius: 3px;
}

.ss-queue-list::-webkit-scrollbar-thumb:hover {
    background: var(--ss-primary-dark);
}

/* Queue Item Card */
.ss-queue-item {
    position: relative;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    background: var(--ss-bg-card);
    border: 1px solid var(--ss-border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ss-queue-item:hover {
    border-color: var(--ss-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Next item highlight */
.ss-queue-item-next {
    border-color: var(--ss-primary);
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.08), var(--ss-bg-card));
    box-shadow: 0 0 20px var(--ss-primary-glow);
}

/* NEXT items: show the header with badge */
.ss-queue-item-next .ss-queue-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

/* Non-NEXT items: hide header, position delete absolutely */
.ss-queue-item:not(.ss-queue-item-next) .ss-queue-item-header {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.ss-queue-item:not(.ss-queue-item-next) {
    position: relative;
}

.ss-queue-item-badge {
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--ss-primary-dark), var(--ss-primary));
    color: white;
    text-transform: uppercase;
}

.ss-queue-item-delete {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--ss-text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s ease;
    margin-left: auto;
}

.ss-queue-item:hover .ss-queue-item-delete {
    opacity: 1;
}

.ss-queue-item-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.ss-queue-item-delete svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* Japanese sentence */
.ss-queue-item-jp {
    font-size: 1rem;
    color: var(--ss-text);
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic Pro", sans-serif;
    line-height: 1.55;
    letter-spacing: 0.01em;
}

/* Footer with English meaning + TTS button */
.ss-queue-item-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.5rem;
}

/* English meaning */
.ss-queue-item-en {
    font-size: 0.75rem;
    color: var(--ss-text-muted);
    line-height: 1.4;
    flex: 1;
}

/* TTS Play Button */
.ss-queue-item-tts {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    border: 1px solid var(--ss-border-subtle);
    background: transparent;
    color: var(--ss-text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: all 0.15s ease;
}

.ss-queue-item-tts svg {
    width: 1rem;
    height: 1rem;
}

.ss-queue-item-tts .ss-tts-icon-loading {
    display: none;
}

.ss-queue-item:hover .ss-queue-item-tts {
    opacity: 1;
}

.ss-queue-item-tts:hover {
    background: rgba(20, 184, 166, 0.12);
    border-color: var(--ss-primary);
    color: var(--ss-primary);
}

/* Loading state - spinning icon */
.ss-queue-item-tts.loading {
    opacity: 1;
    color: var(--ss-primary);
    border-color: var(--ss-primary);
}

.ss-queue-item-tts.loading .ss-tts-icon-speaker {
    display: none;
}

.ss-queue-item-tts.loading .ss-tts-icon-loading {
    display: block;
    animation: ss-tts-spin 1s linear infinite;
}

@keyframes ss-tts-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Playing state - pulsing glow */
.ss-queue-item-tts.playing {
    opacity: 1;
    color: var(--ss-primary-light);
    border-color: var(--ss-primary);
    background: rgba(20, 184, 166, 0.15);
    animation: ss-tts-pulse 1s ease-in-out infinite;
}

@keyframes ss-tts-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--ss-primary-glow); }
    50% { box-shadow: 0 0 8px 2px var(--ss-primary-glow); }
}

/* i+1 grade indicators */
.ss-queue-item[data-grade="i+1"] {
    border-left: 3px solid #fbbf24;
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.04), transparent 50%);
}

.ss-queue-item[data-grade="i+2"] {
    border-left: 3px solid #f97316;
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.04), transparent 50%);
}

/* Empty state */
.ss-queue-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
}

.ss-queue-empty-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1rem;
    color: var(--ss-text-dim);
    opacity: 0.5;
}

.ss-queue-empty-icon svg {
    width: 100%;
    height: 100%;
}

.ss-queue-empty-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ss-text-muted);
    margin-bottom: 0.375rem;
}

.ss-queue-empty-hint {
    font-size: 0.75rem;
    color: var(--ss-text-dim);
}

/* Queue item removal animation */
.ss-queue-item.removing {
    animation: ss-item-remove 0.25s ease-out forwards;
}

@keyframes ss-item-remove {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-20px) scale(0.95);
        max-height: 0;
        padding: 0;
        margin: 0;
        border: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   QUEUE BUTTONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-queue-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--ss-border-subtle);
    background: transparent;
    color: var(--ss-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.ss-queue-btn svg {
    width: 14px;
    height: 14px;
}

.ss-queue-btn:hover:not(:disabled) {
    background: var(--ss-bg-panel);
    border-color: var(--ss-primary);
}

.ss-queue-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ss-queue-btn.primary {
    background: linear-gradient(135deg, var(--ss-primary-dark), var(--ss-primary));
    border-color: var(--ss-primary);
    color: white;
}

.ss-queue-btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px var(--ss-primary-glow);
}

.ss-queue-btn.primary svg {
    width: 1rem;
    height: 1rem;
}

.ss-queue-btn.secondary {
    background: transparent;
    border-color: var(--ss-border-subtle);
    color: var(--ss-text-muted);
    font-size: 0.75rem;
}

.ss-queue-btn.secondary:hover:not(:disabled) {
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.ss-queue-btn.tertiary {
    background: transparent;
    border-color: transparent;
    color: var(--ss-text-dim);
    font-size: 0.7rem;
}

.ss-queue-btn.tertiary:hover:not(:disabled) {
    border-color: var(--ss-border-subtle);
    color: var(--ss-text-muted);
    background: rgba(100, 116, 139, 0.1);
}

/* Button animations */
.ss-queue-btn.ss-consuming {
    position: relative;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.7;
    transform: scale(0.98);
}

.ss-queue-btn.ss-consumed {
    background: linear-gradient(135deg, var(--ss-success), #16a34a) !important;
    border-color: var(--ss-success) !important;
    box-shadow: 0 0 25px var(--ss-success-glow);
    transform: scale(1.02);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SMART MARKDOWN PILLS IN QUEUE
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Base pill style - cataloged words (in user's study) - purple/indigo */
.ss-queue-item-jp .inline-pill {
    cursor: pointer;
    color: #A5B4FC;  /* indigo-300 - cataloged items */
    border-bottom: 2px solid rgba(129, 140, 248, 0.5);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ss-queue-item-jp .inline-pill:hover {
    background-color: rgba(99, 102, 241, 0.15);
    color: #C7D2FE;  /* indigo-200 */
}

/* Uncataloged words - NOT in user's study yet (cyan = "new word!") */
.ss-queue-item-jp .inline-pill--uncataloged {
    color: #22D3EE;
    border-bottom: 2px solid rgba(34, 211, 238, 0.5);
}

.ss-queue-item-jp .inline-pill--uncataloged:hover {
    background-color: rgba(34, 211, 238, 0.12);
    color: #67E8F9;
}

/* Fortress words - in dictionary but not in user's study
   In Smart Sentences modal, ALL new words are cyan to stand out as "learnable" */
.ss-queue-item-jp .inline-pill--fortress-vocab,
.ss-queue-item-jp .inline-pill--fortress-kanji,
.ss-queue-item-jp .inline-pill--fortress-radicals,
.ss-queue-item-jp .inline-pill--fortress-names {
    color: #22D3EE;  /* cyan-400 - new/learnable word */
    border-bottom: 2px solid rgba(34, 211, 238, 0.5);
}
.ss-queue-item-jp .inline-pill--fortress-vocab:hover,
.ss-queue-item-jp .inline-pill--fortress-kanji:hover,
.ss-queue-item-jp .inline-pill--fortress-radicals:hover,
.ss-queue-item-jp .inline-pill--fortress-names:hover {
    background-color: rgba(34, 211, 238, 0.12);
    color: #67E8F9;  /* cyan-300 */
}

/* Grammar patterns stay yellow (still grammar mode) */
.ss-queue-item-jp .inline-pill--fortress-grammar {
    color: #FACC15;  /* yellow - grammar mode */
    border-bottom: 2px solid rgba(250, 204, 21, 0.5);
}
.ss-queue-item-jp .inline-pill--fortress-grammar:hover {
    background-color: rgba(250, 204, 21, 0.12);
    color: #FDE047;
}

/* Grammar patterns - fixed-form expressions (yellow) */
.ss-queue-item-jp .inline-pill--grammar {
    color: #FACC15;  /* yellow - grammar mode */
    border-bottom: 2px solid rgba(250, 204, 21, 0.6);
    cursor: help;
}
.ss-queue-item-jp .inline-pill--grammar:hover {
    background-color: rgba(250, 204, 21, 0.15);
    color: #FDE047;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SIDEBAR BUTTON (External trigger)
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-sidebar-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--ss-border-subtle);
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.08), transparent);
    color: var(--ss-text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ss-sidebar-btn:hover {
    border-color: var(--ss-primary);
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.15), rgba(20, 184, 166, 0.05));
    box-shadow: 0 4px 15px var(--ss-primary-glow);
}

.ss-sidebar-btn-icon {
    font-size: 1rem;
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE - Smaller screens
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .ss-container {
        max-width: 100%;
        max-height: 95vh;
    }

    .ss-content {
        padding: 1.25rem;
    }
}

@media (max-width: 600px) {
    .smart-sentences-modal {
        padding: 0.5rem;
    }

    .ss-container {
        border-radius: 16px;
    }

    .ss-header {
        padding: 1rem;
    }

    .ss-header-title {
        font-size: 1rem;
    }

    .ss-logo-glyph {
        font-size: 1.75rem;
    }

    .ss-sidebar {
        max-height: 40vh;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   STRATEGY INDICATOR - Shows what the system will target
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-strategy-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.08), rgba(6, 182, 212, 0.04));
    border: 1px solid var(--ss-border-subtle);
}

.ss-strategy-indicator.hidden {
    display: none;
}

.ss-strategy-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 184, 166, 0.1);
    border-radius: 10px;
    border: 1px solid var(--ss-border-subtle);
}

.ss-strategy-info {
    flex: 1;
}

.ss-strategy-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ss-text-dim);
    margin-bottom: 0.25rem;
}

.ss-strategy-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ss-primary-light);
    margin-bottom: 0.15rem;
}

.ss-strategy-desc {
    font-size: 0.8rem;
    color: var(--ss-text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CARD CONTAINER - Houses the SentenceCard web component
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-card-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.ss-card-container.hidden {
    display: none;
}

.ss-card-container sentence-card {
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HISTORY SIDEBAR - Shows recently accepted sentences
   ═══════════════════════════════════════════════════════════════════════════════ */
.ss-history-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.5rem;
    border-radius: 8px;
    background: var(--ss-bg-card);
    border: 1px solid var(--ss-border-subtle);
}

.ss-history-count {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--ss-primary);
    font-family: monospace;
}

.ss-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Custom scrollbar for history */
.ss-history-list::-webkit-scrollbar {
    width: 5px;
}

.ss-history-list::-webkit-scrollbar-track {
    background: transparent;
}

.ss-history-list::-webkit-scrollbar-thumb {
    background: var(--ss-border);
    border-radius: 3px;
}

/* Empty state */
.ss-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem;
    height: 100%;
    opacity: 0.6;
}

.ss-history-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.ss-history-empty-text {
    font-size: 0.9rem;
    color: var(--ss-text-muted);
    margin-bottom: 0.35rem;
}

.ss-history-empty-hint {
    font-size: 0.75rem;
    color: var(--ss-text-dim);
}

/* History Item */
.ss-history-item {
    position: relative;
    padding: 0.75rem 0.875rem;
    border-radius: 8px;
    background: var(--ss-bg-card);
    border: 1px solid var(--ss-border-subtle);
    transition: border-color 0.15s ease, background 0.15s ease;
    cursor: pointer;
}

.ss-history-item:hover {
    border-color: var(--ss-border);
    background: rgba(20, 184, 166, 0.04);
}

.ss-history-item-text {
    font-size: calc(0.9rem * var(--ss-font-scale, 1));
    color: var(--ss-text);
    margin-bottom: 0.35rem;
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.4;
}

.ss-history-item-meaning {
    font-size: calc(0.75rem * var(--ss-font-scale, 1));
    color: var(--ss-text-muted);
    line-height: 1.3;
    padding-right: 2rem;
}

.ss-history-tts-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ss-text-dim);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ss-history-tts-btn:hover {
    background: rgba(20, 184, 166, 0.1);
    border-color: var(--ss-border);
    color: var(--ss-primary);
}

.ss-history-tts-btn svg {
    width: 14px;
    height: 14px;
}

/* History target badge - shows what word was targeted */
.ss-history-target {
    display: inline-block;
    font-size: calc(0.65rem * var(--ss-font-scale, 1));
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    margin-bottom: 0.3rem;
    font-family: 'Noto Sans JP', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ss-history-target:hover {
    transform: translateY(-1px);
    filter: brightness(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ss-history-target--weak {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.ss-history-target--new {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: #22d3ee;
}

.ss-history-target--solid {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.ss-history-target--mastered {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #a78bfa;
}
