/* ==========================================
   Zoey Prompts — Design System & Styling
   ========================================== */

:root {
    /* Color Palette — deep purple-black backgrounds */
    --bg-primary: #07061a;
    --bg-secondary: #0c0a20;
    --bg-tertiary: #12102e;

    --border-color: rgba(255, 255, 255, 0.07);
    --border-color-hover: rgba(255, 255, 255, 0.18);

    --text-primary: #f5f3ff;
    --text-secondary: #a89fc0;
    --text-muted: #6b6480;

    /* Brand Accents — Purple & Gold */
    --accent-purple: #7C3AED;
    --accent-purple-glow: rgba(124, 58, 237, 0.35);
    --accent-gold: #D4AF37;
    --accent-gold-glow: rgba(212, 175, 55, 0.35);

    --color-success: #10b981;
    --color-success-bg: rgba(16, 185, 129, 0.1);
    --color-warning: #f59e0b;
    --color-warning-bg: rgba(245, 158, 11, 0.1);
    --color-danger: #ef4444;
    --color-danger-bg: rgba(239, 68, 68, 0.1);

    /* Layout & Shadow constants */
    --glass-bg: rgba(12, 10, 32, 0.75);
    --glass-border: rgba(212, 175, 55, 0.06);
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.8);
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden;
    overflow-x: hidden;
    height: 100vh;
    overscroll-behavior-y: contain;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-text-size-adjust: 100%;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color-hover);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* Main Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    margin-bottom: 36px;
}

.brand-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.4rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-zoey {
    color: var(--accent-gold);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    min-height: 48px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-btn:active {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.nav-btn.active {
    color: white;
    background: linear-gradient(90deg, rgba(124, 58, 237, 0.15) 0%, rgba(212, 175, 55, 0.05) 100%);
    border-left: 3px solid var(--accent-purple);
}

.nav-btn i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
    font-size: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-status {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-level {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content Workspace */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    background: radial-gradient(circle at 80% 10%, rgba(124, 58, 237, 0.06) 0%, transparent 45%),
                radial-gradient(circle at 10% 90%, rgba(212, 175, 55, 0.04) 0%, transparent 45%),
                var(--bg-primary);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(8, 9, 13, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.app-header h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.platform-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selector-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.platform-chips {
    display: flex;
    gap: 8px;
}

.platform-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    min-height: 48px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

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

.platform-chip:active {
    opacity: 0.8;
    transform: scale(0.97);
}

.platform-chip.active {
    color: white;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple));
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

.platform-chip.active[data-platform="lovable"] {
    background: #ec4899;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.3);
}

.platform-chip.active[data-platform="claude-code"] {
    background: #d97706;
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.3);
}

.platform-chip.active[data-platform="antigravity"] {
    background: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* Hamburger Menu Button */
.hamburger-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 48px;
    height: 48px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: var(--transition-smooth);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-color-hover);
}

.hamburger-btn:active {
    color: var(--text-primary);
    border-color: var(--border-color-hover);
    background: rgba(255, 255, 255, 0.05);
}

/* Sidebar Overlay Backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 30px 40px;
    flex-grow: 1;
    min-height: 0;
}

.dashboard-grid > * {
    min-width: 0;
}

.dashboard-grid.hidden {
    display: none;
}

/* Panels */
.panel {
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(12px);
    transition: var(--transition-smooth);
}

.panel:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

.full-width-panel {
    grid-column: span 2;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title-desc {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.panel-title-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.05);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-gold);
    border: 1px solid rgba(255,255,255,0.1);
}

.panel h3 {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.panel-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.panel-actions {
    display: flex;
    gap: 8px;
}

/* Panel grouping for column 2 */
.panel-group {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
}

.suggestions-panel {
    flex: 1;
    min-height: 250px;
}

.output-panel {
    flex: 1.2;
    min-height: 300px;
}

/* Form inputs & Textareas */
.textarea-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
}

textarea {
    width: 100%;
    height: 100%;
    min-height: 280px;
    background-color: transparent;
    border: none;
    resize: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    padding: 20px;
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
}

.output-wrapper {
    flex-grow: 1;
    background-color: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.code-preview {
    width: 100%;
    height: 100%;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    outline: none;
    color: #e5e7eb;
    white-space: pre-wrap;
}

.code-preview[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-muted);
}

/* Metrics Bar */
.metrics-bar {
    display: flex;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.01);
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 20px;
    border-right: 1px solid var(--border-color);
}

.metric-item:last-child {
    border-right: none;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.score-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.score-text {
    font-size: 1.15rem;
}

.score-bar-bg {
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-gold));
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

/* Buttons */
.panel-footer-actions {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
}

.btn {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 18px;
    min-height: 44px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), rgba(124, 58, 237, 0.8));
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-color-hover);
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:active {
    opacity: 0.85;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 36px;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    min-height: 44px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-color-hover);
    background: rgba(255, 255, 255, 0.03);
}

.action-btn:active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

#clear-input-btn-mobile {
    display: none !important;
}

.text-danger {
    color: var(--color-danger);
}
.text-danger:hover {
    background-color: var(--color-danger-bg);
    color: white;
}

/* Warning Count Badge */
.suggestions-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Suggestion Card States */
.suggestions-list {
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggestion-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.suggestion-card.warning {
    border-left: 4px solid var(--color-warning);
}

.suggestion-card.danger {
    border-left: 4px solid var(--color-danger);
}

.suggestion-card.info {
    border-left: 4px solid var(--accent-gold);
}

.suggestion-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.suggestion-icon.warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

.suggestion-icon.danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.suggestion-body {
    flex-grow: 1;
}

.suggestion-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.suggestion-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    margin: auto;
    max-width: 320px;
}

.empty-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Settings Form elements */
.settings-form {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 600px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, .form-group select {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px var(--accent-purple-glow);
}

.password-input-wrapper {
    position: relative;
    display: flex;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-smooth);
}

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

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Templates list cards */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
}

.template-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.template-card:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium);
}

.template-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.template-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent-gold);
}

.template-platform {
    font-size: 0.75rem;
    background-color: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-secondary);
}

.template-card h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.template-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* History lists UI */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
}

.history-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
}

.history-card:hover {
    border-color: var(--border-color-hover);
}

.history-content {
    flex-grow: 1;
    margin-right: 20px;
}

.history-text {
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
    margin-bottom: 4px;
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-actions {
    display: flex;
    gap: 8px;
}

/* Toast Notification Styles */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--accent-gold);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast i {
    color: var(--accent-gold);
    font-size: 1.2rem;
}

/* Prompt Interviewer Refinement Questions styling */
.interview-question-wrapper {
    margin-top: 14px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.interview-question-wrapper:focus-within {
    border-color: rgba(212, 175, 55, 0.3);
    background-color: rgba(255, 255, 255, 0.03);
}

.question-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.question-input-group {
    display: flex;
    gap: 8px;
}

.question-answer-input {
    flex-grow: 1;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.question-answer-input::placeholder {
    color: var(--text-muted);
}

.question-answer-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.2);
}

/* ==========================================
   Stack Guide Custom Cards & Dashboard Layout
   ========================================== */
.stack-layout {
    display: flex;
    gap: 24px;
    padding: 30px 40px;
    width: 100%;
    align-items: flex-start;
}

.stack-layout.hidden {
    display: none;
}

/* Left Sidebar Navigation */
.stack-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    height: auto;
}

.stack-sidebar-sticky {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stack-progress-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stack-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

#stack-progress-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.stack-progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.stack-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-purple));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.sidebar-category-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding-left: 8px;
}

.category-filters-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-filter-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    text-align: left;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    width: 100%;
    font-family: var(--font-sans);
}

.category-filter-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.category-filter-btn.active {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.2);
    color: var(--accent-gold);
    font-weight: 600;
}

/* Main Content Pane */
.stack-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.stack-main-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stack-main-title-block h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stack-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-grow: 1;
    max-width: 350px;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 36px 10px 36px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.search-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px var(--accent-purple-glow);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.clear-search-btn:hover {
    color: var(--text-primary);
}

.clear-search-btn.hidden {
    display: none;
}

.stack-actions-group {
    display: flex;
    gap: 8px;
}

/* Stack Cards Grid */
.stack-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    /* Without this, expanding one card's Setup Guide stretches every other
       card in the same grid row to match its height. */
    align-items: start;
}

.stack-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.stack-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stack-card-inner {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.stack-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stack-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stack-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
    font-size: 1rem;
}

.stack-card-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

.status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge.active {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.optional {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.stack-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.7em;
}

.stack-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.meta-badge {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.meta-badge.version-badge {
    font-family: var(--font-mono);
}

.meta-badge.env-badge {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.02);
    border-color: rgba(212, 175, 55, 0.08);
}

/* Card Actions */
.stack-card-actions-row {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.stack-card-actions-row .btn {
    padding: 8px 12px;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-grow: 1;
}

.docs-link-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.docs-link-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Card Accordion Guide */
.card-accordion-wrapper {
    border-top: 1px solid var(--border-color);
}

.card-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.1);
    transition: var(--transition-smooth);
    user-select: none;
}

.card-accordion-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.card-accordion-header span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-accordion-header i.chevron-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.card-accordion-wrapper.open i.chevron-icon {
    transform: rotate(180deg);
    color: var(--accent-gold);
}

.card-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.15);
}

.card-accordion-wrapper.open .card-accordion-content {
    max-height: 1200px;
}

.accordion-guide-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.accordion-step-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.accordion-step-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.accordion-step-number {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--accent-gold);
    font-weight: 700;
    flex-shrink: 0;
}

.accordion-step-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.accordion-step-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    padding-left: 26px;
}

.accordion-step-desc a {
    color: var(--accent-gold);
    text-decoration: none;
    font-weight: 500;
}

.accordion-step-desc a:hover {
    text-decoration: underline;
}

.accordion-step-code {
    padding-left: 26px;
    margin-top: 4px;
}

.accordion-step-code pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--accent-gold);
    margin: 0;
}

/* Stack Empty State */
.stack-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    text-align: center;
    gap: 16px;
}

.empty-state-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.stack-empty-state h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.stack-empty-state p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 320px;
    margin: 0;
}

/* Architecture Map Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.modal-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.close-modal-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.svg-map-wrapper {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SVG Map Node & Connection Styling */
.map-connection-line {
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 2;
    fill: none;
    transition: stroke 0.3s ease, stroke-width 0.3s ease;
}

.map-connection-line.active {
    stroke: rgba(16, 185, 129, 0.55);
    stroke-width: 3;
    filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.45));
}

.node-circle {
    fill: var(--bg-tertiary);
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}

.node-circle.main-hub {
    stroke: rgba(255, 255, 255, 0.28);
}

.map-node.active .node-circle {
    stroke: var(--color-success);
    fill: rgba(16, 185, 129, 0.16);
    filter: drop-shadow(0 0 9px rgba(16, 185, 129, 0.55));
    transform: scale(1.12);
    animation: nodePulse 2.4s ease-in-out infinite;
}

.map-node.active .node-circle.main-hub {
    stroke: var(--accent-purple);
    fill: rgba(124, 58, 237, 0.16);
    filter: drop-shadow(0 0 12px rgba(124, 58, 237, 0.6));
    animation: nodePulseHub 2.4s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.45)); }
    50% { filter: drop-shadow(0 0 15px rgba(16, 185, 129, 0.8)); }
}

@keyframes nodePulseHub {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(124, 58, 237, 0.5)); }
    50% { filter: drop-shadow(0 0 18px rgba(124, 58, 237, 0.85)); }
}

@media (prefers-reduced-motion: reduce) {
    .map-node.active .node-circle,
    .map-node.active .node-circle.main-hub { animation: none; }
}

.node-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: var(--transition-smooth);
}

.map-node.active .node-icon {
    color: var(--text-primary);
}

.map-node.active .node-icon i {
    filter: drop-shadow(0 0 5px currentColor);
}

.node-label {
    font-size: 11px;
    fill: var(--text-muted);
    text-anchor: middle;
    font-weight: 500;
    font-family: var(--font-sans);
    transition: fill 0.3s ease, font-weight 0.3s ease;
}

.map-node.active .node-label {
    fill: var(--text-primary);
    font-weight: 600;
}

/* Explanation Cards in Settings */
.explanation-box {
    background: rgba(255, 255, 255, 0.015);
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.explanation-box:hover {
    border-color: var(--border-color-hover);
    background: rgba(255, 255, 255, 0.03);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.explanation-box h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.explanation-box h4.cyan {
    color: var(--accent-gold);
}

.explanation-box h4.purple {
    color: var(--accent-purple);
}

.explanation-box h4.success {
    color: var(--color-success);
}

.explanation-box p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.explanation-box p:not(:last-child) {
    margin-bottom: 8px;
}

.explanation-box ul {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.explanation-box a {
    color: var(--accent-gold);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.explanation-box a:hover {
    color: var(--accent-purple);
    text-decoration: underline;
}

/* Panel Content Layout */
.panel-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

/* Non-workspace views fill remaining height and scroll their own content */
#stack-view,
#templates-view,
#history-view,
#settings-view,
#auth-view,
#admin-view {
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* ==========================================
   Responsiveness
   ========================================== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .full-width-panel {
        grid-column: span 1;
    }
    .stack-cards-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Hamburger visible on mobile */
    .hamburger-btn {
        display: flex;
    }

    /* Sidebar becomes a fixed drawer (hidden off-screen by default) */
    .app-container {
        flex-direction: row;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        height: 100dvh;
        width: 280px;
        max-width: 85vw;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid var(--border-color);
        padding: 24px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-container .sidebar.open,
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }

    /* Revert sidebar internals back to column layout */
    .sidebar-nav {
        flex-direction: column;
        overflow-x: initial;
        padding-bottom: 0;
    }

    .brand {
        margin-bottom: 36px;
    }

    .sidebar-footer {
        display: block;
    }

    /* Header on mobile */
    .app-header {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-left {
        width: 100%;
    }

    .header-right {
        width: 100%;
        overflow-x: auto;
    }

    .platform-selector-wrapper {
        flex-wrap: wrap;
        gap: 8px;
    }

    .platform-chips {
        flex-wrap: wrap;
    }

    .dashboard-grid {
        padding: 16px;
        gap: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .templates-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }

    .stack-layout {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        min-width: 0;
    }

    .stack-sidebar {
        width: 100%;
        min-width: 0;
        position: static;
        height: auto;
    }

    .stack-main {
        min-width: 0;
    }

    /* Let the search input shrink instead of forcing the layout wider */
    .search-input,
    #stack-search {
        min-width: 0;
    }

    .stack-sidebar-sticky {
        gap: 16px;
    }

    .category-filters-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
        width: 100%;
        scrollbar-width: none;
    }

    .category-filters-list::-webkit-scrollbar {
        display: none;
    }

    .category-filter-btn {
        flex-shrink: 0;
        width: auto;
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .stack-main {
        gap: 16px;
    }

    .stack-main-header {
        padding: 16px;
    }

    .stack-controls-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input-wrapper {
        max-width: 100%;
    }

    .stack-actions-group {
        flex-wrap: wrap;
    }

    /* Mobile-specific button alignment for draft prompt actions */
    #clear-input-btn {
        display: none !important;
    }
    #clear-input-btn-mobile {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0;
        flex-shrink: 0;
    }
    .input-panel {
        overflow: visible;
    }

    .textarea-wrapper {
        flex-grow: 0;
    }

    textarea {
        min-height: 150px;
        max-height: 200px;
    }

    .panel-footer-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
        flex-shrink: 0;
    }
    .panel-footer-actions .btn {
        padding: 10px 16px;
        font-size: 0.8rem;
        flex: 1 1 0%;
        min-width: 0;
        white-space: normal;
        justify-content: center;
        text-align: center;
        min-height: 44px;
    }
}

/* Optimizations for very small mobile devices */
@media (max-width: 480px) {
    .dashboard-grid {
        padding: 12px;
        gap: 16px;
    }
    .templates-grid {
        padding: 12px;
        gap: 12px;
    }
    .stack-layout {
        padding: 12px;
    }
    .stack-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Authentication View Compact & Premium Styles
   ========================================== */
#auth-view {
    display: none; /* Toggled to flex in JS */
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 24px;
    width: 100%;
    box-sizing: border-box;
}

#auth-view .panel {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    border-color: var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-premium);
    border-radius: 16px;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

#auth-view .panel:hover {
    border-color: rgba(124, 58, 237, 0.25);
    transform: translateY(-2px);
}

#auth-view .panel-header {
    border-bottom: none;
    padding: 24px 24px 8px 24px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

#auth-view .panel-title-desc h3 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

#auth-view .panel-content {
    padding: 8px 24px 24px 24px;
    gap: 14px;
    display: flex;
    flex-direction: column;
}

#auth-view .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#auth-view .form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#auth-view .form-group input {
    padding: 10px 14px;
    font-size: 0.9rem;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

#auth-view .form-group input:focus {
    border-color: var(--accent-gold);
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
}

#auth-view .password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#auth-view .password-input-wrapper input {
    width: 100%;
    padding-right: 40px;
}

#auth-view .toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    transition: color 0.2s ease;
}

#auth-view .toggle-password:hover {
    color: var(--accent-gold);
}

#auth-view #auth-submit-btn {
    margin-top: 8px;
    padding: 11px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-purple) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    transition: all 0.25s ease;
}

#auth-view #auth-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.45);
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-purple) 100%);
}

#auth-view #auth-submit-btn:active {
    transform: translateY(1px);
}

#auth-view .auth-toggle-container {
    margin-top: 12px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#auth-view #auth-toggle-mode-btn {
    background: none;
    border: none;
    color: var(--accent-gold);
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

#auth-view #auth-toggle-mode-btn:hover {
    color: var(--accent-purple);
    text-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
}

@media (max-height: 650px) {
    #auth-view {
        padding: 12px;
        align-items: flex-start;
        overflow-y: auto;
    }
    #auth-view .panel {
        margin: 10px auto;
    }
}

/* ==========================================
   Admin Dashboard
   ========================================== */

.admin-view {
    display: flex;
    flex-direction: column;
    padding: 28px 40px 40px;
    gap: 24px;
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
}

.admin-view.hidden { display: none !important; }

/* Header */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.admin-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.admin-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Metrics Grid */
.admin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.admin-metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.admin-metric-card:hover {
    border-color: var(--border-color-hover);
}

.admin-metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.admin-metric-icon--indigo {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.admin-metric-icon--emerald {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--color-success);
}

.admin-metric-icon--red {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

.admin-metric-body { flex: 1; min-width: 0; }

.admin-metric-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.admin-metric-value {
    font-size: 1.75rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-top: 4px;
    line-height: 1;
}

.admin-metric-bg {
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 5rem;
    opacity: 0.04;
    pointer-events: none;
}

/* Tab Navigation */
.admin-tab-nav {
    border-bottom: 1px solid var(--border-color);
}

.admin-tab-nav-inner {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.admin-tab-nav-inner::-webkit-scrollbar { display: none; }

.admin-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 14px 16px;
    min-height: 48px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-smooth);
    margin-bottom: -1px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.admin-tab-btn:hover { color: var(--text-primary); }
.admin-tab-btn:active { color: var(--text-primary); }

.admin-tab-btn.active {
    color: #818cf8;
    border-bottom-color: #818cf8;
}

/* Tab Content */
.admin-tab-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-tab-content.hidden { display: none; }

.admin-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.admin-section-title i { color: #818cf8; }

.admin-section-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Table */
.admin-table-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.admin-table-wrapper > .admin-table { overflow-x: auto; display: block; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 640px;
}

.admin-table thead tr {
    background: var(--bg-primary);
}

.admin-table thead th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.admin-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}

.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.admin-table tbody td {
    padding: 14px 20px;
    vertical-align: middle;
    color: var(--text-secondary);
}

.admin-empty-cell {
    text-align: center;
    padding: 40px !important;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* User profile cell */
.admin-user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #818cf8;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.admin-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.admin-you-badge {
    font-size: 0.65rem;
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 6px;
}

/* Role / status badges */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid;
    white-space: nowrap;
}

.admin-badge--purple {
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent-purple);
    border-color: rgba(168, 85, 247, 0.2);
}

.admin-badge--slate {
    background: rgba(255,255,255,0.03);
    color: var(--text-muted);
    border-color: var(--border-color);
}

.admin-badge--amber {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.2);
}

.admin-badge--green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    border-color: rgba(16, 185, 129, 0.2);
}

.admin-badge--red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.admin-badge--cyan {
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-gold);
    border-color: rgba(212, 175, 55, 0.2);
}

/* Action buttons inside table */
.admin-action-btn {
    padding: 5px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: var(--font-sans);
}

.admin-action-btn:hover:not(:disabled) {
    border-color: #818cf8;
    color: #818cf8;
}

.admin-action-btn.amber:hover:not(:disabled) {
    border-color: #f59e0b;
    color: #f59e0b;
}

.admin-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.admin-action-btn.red:hover:not(:disabled) {
    border-color: #ef4444;
    color: #ef4444;
}

.admin-select {
    padding: 5px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
}

.admin-select:hover:not(:disabled) {
    border-color: #818cf8;
    color: #818cf8;
}

.admin-select:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* --- Workspace Meta Row (metrics + mini map) --- */
.workspace-meta-row {
    display: flex;
    flex-direction: column;
}

/* Desktop: architecture map sits beside the quality score */
@media (min-width: 1025px) {
    .workspace-meta-row {
        flex-direction: row;
        align-items: stretch;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
    }
    .workspace-meta-row .metrics-bar {
        border-top: none;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        flex: 0 0 auto;
        flex-direction: column;
        justify-content: center;
    }
    .workspace-meta-row .metric-item {
        border-right: none;
        padding: 8px 20px;
    }
    .workspace-meta-row .mini-map-bar {
        flex: 1;
        margin: 0;
        border: none;
        border-radius: 0;
    }
    .workspace-meta-row #mini-architecture-svg {
        height: 110px;
    }
}

/* --- Workspace Mini Architecture Map --- */
.mini-map-bar {
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 14px 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.mini-map-bar:hover {
    border-color: rgba(124, 58, 237, 0.55);
    background: rgba(124, 58, 237, 0.06);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.mini-map-bar:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

.mini-map-bar:hover .mini-map-expand {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
}

.mini-map-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.mini-map-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mini-map-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.mini-map-title i {
    color: var(--primary-color);
}

.mini-map-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.mini-map-count.active {
    color: #4ade80;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 999px;
    padding: 2px 9px;
}

.mini-map-expand {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
    transition: var(--transition-smooth);
}

.mini-map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 6px 2px 2px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.66rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}

.legend-dot.active {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--color-success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.legend-line {
    width: 16px;
    height: 0;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.legend-line.active {
    border-top-color: rgba(16, 185, 129, 0.6);
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.4);
}

.mini-map-hint {
    font-size: 0.64rem;
    color: var(--text-muted);
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    opacity: 0.85;
}

.mini-map-hint i {
    color: var(--accent-cyan);
}

/* Modal map legend */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    margin: 0 0 14px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.map-legend .legend-item {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

#mini-architecture-svg {
    width: 100%;
    height: 130px;
    display: block;
}

#mini-architecture-svg .node-label.mini {
    font-size: 17px;
    fill: var(--text-muted);
    text-anchor: middle;
    font-family: var(--font-sans);
}

#mini-architecture-svg .map-node.active .node-label.mini {
    fill: #4ade80;
}

.node-icon.mini {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.map-node.active .node-icon.mini {
    color: #4ade80;
}

@media (max-width: 768px) {
    #mini-architecture-svg { height: 100px; }
}

/* --- User Guide --- */
.guide-content {
    padding: 1.5rem;
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.guide-hero {
    text-align: center;
    padding: 1rem 0 0.5rem;
}

.guide-eyebrow {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--primary-color);
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 999px;
    padding: 4px 14px;
    margin-bottom: 0.9rem;
}

.guide-hero h2 {
    font-size: 1.7rem;
    margin-bottom: 0.6rem;
}

.guide-hero p {
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 0.95rem;
    max-width: 640px;
    margin: 0 auto;
}

.guide-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-section-label i {
    color: var(--primary-color);
}

.guide-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.guide-step {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.2rem 1.2rem 1.1rem;
    position: relative;
}

.guide-step-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.guide-step h4 {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.guide-step p {
    color: var(--text-secondary);
    font-size: 0.83rem;
    line-height: 1.6;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    align-items: start;
}

.guide-badge-optional {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 2px 8px;
    margin-left: 6px;
}

@media (max-width: 900px) {
    .guide-steps { grid-template-columns: 1fr; }
    .guide-grid { grid-template-columns: 1fr; }
}

.guide-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
}

.guide-card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.guide-card h3 i {
    color: var(--primary-color);
    font-size: 0.95rem;
}

.guide-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.88rem;
}

.guide-card ul, .guide-card ol {
    margin: 0.7rem 0 0 1.2rem;
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.guide-card strong {
    color: var(--text-primary);
}

.guide-card--tip {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.05);
}

.guide-card--tip h3 i {
    color: #f59e0b;
}

/* --- Analysis Strengths Panel --- */
.strengths-panel {
    background: rgba(34, 197, 94, 0.06);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
}

.strengths-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #4ade80;
    margin-bottom: 0.55rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.strength-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.strength-item i {
    color: #4ade80;
    font-size: 0.7rem;
}

.admin-actions-cell {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Plans Grid */
.admin-plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.admin-plan-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition-smooth);
}

.admin-plan-card:hover {
    border-color: var(--border-color-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.admin-plan-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.admin-plan-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.admin-plan-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.admin-plan-price-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
}

.admin-plan-price-period {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.admin-plan-delete-btn {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
    line-height: 1;
}

.admin-plan-delete-btn:hover {
    color: var(--color-danger);
    background: rgba(239,68,68,0.08);
}

.admin-plan-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    flex: 1;
}

.admin-plan-features li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.admin-plan-features li i {
    color: #818cf8;
    margin-top: 2px;
    flex-shrink: 0;
}

.admin-plan-id {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* Diagnostics */
.admin-diag-hero {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-diag-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.admin-diag-grid.hidden { display: none; }

.admin-diag-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.admin-diag-col-wide {
    min-height: 320px;
}

.admin-panel-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-terminal {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.7;
    overflow-y: auto;
    min-height: 220px;
    max-height: 360px;
    color: var(--text-secondary);
}

.admin-terminal-line { padding-left: 8px; border-left: 2px solid var(--border-color); }
.admin-terminal-line--success { color: var(--color-success); border-left-color: var(--color-success); }
.admin-terminal-line--error { color: var(--color-danger); font-weight: 700; border-left-color: var(--color-danger); }
.admin-terminal-line--warn { color: var(--color-warning); font-weight: 600; border-left-color: var(--color-warning); }
.admin-terminal-line--info { color: #818cf8; font-weight: 500; border-left-color: #818cf8; }

.admin-diag-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

.admin-diag-status--ok {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--color-success);
}

.admin-diag-status--fail {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--color-danger);
}

.admin-diag-status i { font-size: 1.5rem; flex-shrink: 0; }

.admin-checklist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 4px 0;
}

/* Settings */
.admin-settings-wrap {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    max-width: 560px;
}

.admin-settings-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.admin-settings-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.admin-settings-form.hidden { display: none; }

.admin-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-form-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.admin-form-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
    width: 100%;
}

.admin-form-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.admin-pw-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.admin-pw-wrap .admin-form-input {
    padding-right: 44px;
}

.admin-pw-toggle {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    transition: color 0.2s;
}

.admin-pw-toggle:hover { color: var(--text-primary); }

/* Plan feature rows in modal */
.plan-feature-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.plan-feature-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.plan-feature-input:focus {
    border-color: var(--accent-gold);
}

/* Responsive admin */
@media (max-width: 1200px) {
    .admin-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .admin-diag-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .admin-view { padding: 16px; gap: 16px; }
    .admin-metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-header { flex-direction: column; }
    .admin-tab-btn { font-size: 0.78rem; padding: 12px 10px; }
}

/* ==========================================
   Mobile Touch Optimizations
   ========================================== */

/* Hover-only: transform lifts that cause "stuck hover" on touch */
@media (hover: hover) {
    .btn-primary:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(124, 58, 237, 0.45);
    }

    .template-card:hover {
        transform: translateY(-2px);
    }

    .stack-card:hover {
        transform: translateY(-2px);
    }

    .explanation-box:hover {
        transform: translateY(-2px);
    }

    .admin-plan-card:hover {
        transform: translateY(-2px);
    }
}

/* Remove transforms on touch devices to prevent sticky hover state */
@media (hover: none) {
    .template-card,
    .stack-card,
    .explanation-box,
    .admin-plan-card {
        transform: none !important;
    }
}

/* iOS input zoom prevention — inputs must be >= 16px font on mobile */
@media (max-width: 768px) {
    input,
    textarea,
    select,
    .question-answer-input,
    .search-input,
    .admin-form-input,
    .plan-feature-input {
        font-size: 16px !important;
    }

    /* Prevent horizontal overflow on content containers */
    .dashboard-grid,
    .stack-layout,
    .admin-view,
    .panel-content,
    .settings-form {
        overflow-x: hidden;
    }

    /* Comfortable toast position above iOS safe area */
    .toast {
        bottom: max(24px, env(safe-area-inset-bottom, 24px));
        right: 16px;
        left: 16px;
        right: 16px;
    }

    /* Stack search gets full width on mobile */
    .stack-search-input-wrapper {
        max-width: 100%;
    }

    /* Category filter buttons: ensure 44px tap targets */
    .category-filter-btn {
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .category-filter-btn:active {
        background: rgba(212, 175, 55, 0.12);
        color: var(--accent-gold);
    }
}

/* Images always scale within their container */
img {
    max-width: 100%;
    height: auto;
}

/* Smooth scrolling for in-page navigation */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }

    .suggestions-list,
    .output-wrapper,
    #stack-view,
    #templates-view,
    #history-view,
    #settings-view,
    #auth-view,
    #admin-view,
    .admin-tab-nav-inner,
    .category-filters-list {
        scroll-behavior: smooth;
    }
}
/* ==========================================
   Suggestion Fix Preview
   ========================================== */
.fix-preview {
    margin-top: 10px;
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.06);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fix-preview-head {
    font-size: 0.72rem;
    font-weight: 700;
    color: #a78bfa;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fix-preview-code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 10px;
    margin: 0;
    max-height: 140px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.fix-preview .fix-rule-btn {
    align-self: flex-start;
}

/* ==========================================
   Projects
   ========================================== */
.projects-list-panel {
    max-height: 100%;
}

.projects-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-smooth);
    min-height: 44px;
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.project-item.active {
    background: rgba(124, 58, 237, 0.1);
    border-left: 3px solid var(--primary-color);
}

.project-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.project-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.project-item i {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.project-prompts-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-prompt-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
    padding: 14px 16px;
}

.project-prompt-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.project-prompt-title {
    font-weight: 700;
    font-size: 0.9rem;
}

.project-prompt-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.project-prompt-preview {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.project-prompt-actions {
    display: flex;
    gap: 8px;
}

#save-project-modal .form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}

#save-project-modal .form-group input,
#save-project-modal .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    min-height: 44px;
}

/* ==========================================
   Mobile: natural page scrolling + touch targets
   ========================================== */
@media (max-width: 768px) {
    /* The app is locked to the viewport on desktop (inner panels scroll).
       On phones that breaks scrolling under browser toolbars — switch the
       whole document to normal page flow so the page itself scrolls.
       overflow-x uses clip (not hidden): hidden would turn body into its
       own scroll container and break native page scrolling. */
    body {
        overflow: visible;
        overflow-x: clip;
        height: auto;
        min-height: 100dvh;
        overscroll-behavior-y: auto;
    }

    .app-container {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .main-content {
        overflow: visible;
        height: auto;
        min-height: 100dvh;
    }

    .dashboard-grid {
        overflow-y: visible;
        flex-grow: 0;
        height: auto;
        grid-template-columns: 1fr;
    }

    .full-width-panel {
        grid-column: span 1;
    }

    .panel {
        height: auto;
        min-height: 0;
    }

    .stack-layout,
    #admin-view,
    #auth-view {
        overflow: visible;
        height: auto;
    }

    .output-wrapper {
        max-height: 320px;
        min-height: 140px;
    }

    /* Comfortable touch targets everywhere */
    .nav-btn,
    .btn,
    .admin-tab-btn,
    .platform-chip,
    .category-filter-btn,
    .card-accordion-header {
        min-height: 44px;
    }

    .action-btn {
        min-height: 40px;
        padding: 8px 12px;
    }

    .admin-select,
    .admin-action-btn {
        min-height: 40px;
    }

    .question-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .question-answer-input {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom-on-focus */
    }

    textarea {
        font-size: 16px; /* prevents iOS zoom-on-focus */
    }

    /* Mini map compact on phones */
    #mini-architecture-svg {
        height: 96px;
    }

    /* Projects view stacks */
    .projects-list-panel {
        max-height: none;
    }

    .project-prompt-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Modals fit small screens */
    .modal-box {
        width: calc(100vw - 24px);
        max-height: 88dvh;
        overflow-y: auto;
    }
}
