/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --bg: #faf9f7;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    color-scheme: light dark;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #312e81;
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --text: #f0f0f5;
    --text-muted: #9ca3af;
    --border: #2d2d44;
    --danger: #f87171;
    --danger-light: #2d1b1b;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary: #818cf8;
        --primary-dark: #6366f1;
        --primary-light: #312e81;
        --bg: #0f0f1a;
        --surface: #1a1a2e;
        --text: #f0f0f5;
        --text-muted: #9ca3af;
        --border: #2d2d44;
        --danger: #f87171;
        --danger-light: #2d1b1b;
    }
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== Home Page ===== */
.home-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    min-height: 100vh;
}

.home-header {
    text-align: center;
    padding: 3rem 0 2.5rem;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
}

.logo h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 3rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.admin-link {
    position: absolute;
    top: 3rem;
    right: 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.admin-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.create-room-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.form-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: -0.25rem;
}

.form-input {
    padding: 0.8rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== Set Selection Cards ===== */
.set-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.set-card {
    display: block;
    cursor: pointer;
}

.set-card input[type="checkbox"] {
    display: none;
}

.set-card-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    transition: all 0.2s;
}

.set-card:hover .set-card-inner {
    border-color: var(--set-color, var(--primary));
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.set-card input:checked + .set-card-inner {
    border-color: var(--set-color, var(--primary));
    background: color-mix(in srgb, var(--set-color, var(--primary)) 10%, var(--surface));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--set-color, var(--primary)) 15%, transparent);
}

.set-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.set-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.set-name {
    font-weight: 600;
    font-size: 0.95rem;
}

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

.set-check {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
    flex-shrink: 0;
}

.set-check svg {
    width: 14px;
    height: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.set-card input:checked + .set-card-inner .set-check {
    background: var(--set-color, var(--primary));
    border-color: var(--set-color, var(--primary));
}

.set-card input:checked + .set-card-inner .set-check svg {
    opacity: 1;
}

/* ===== Room Options ===== */
.room-options {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
}

.room-options-summary {
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
}

.room-options-summary::-webkit-details-marker {
    display: none;
}

.room-options-summary::before {
    content: '\25B6';
    font-size: 0.65rem;
    transition: transform 0.2s;
}

.room-options[open] .room-options-summary::before {
    transform: rotate(90deg);
}

.room-options-summary:hover {
    color: var(--primary);
}

.room-options-body {
    padding: 0 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.join-section {
    text-align: center;
    padding: 1.5rem 0;
}

.join-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-hero {
    box-shadow: 0 4px 16px rgba(99,102,241,0.35);
    font-size: 1.15rem;
    padding: 1.1rem 2rem;
}

.btn-hero:hover {
    box-shadow: 0 6px 24px rgba(99,102,241,0.45);
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 14px;
    width: 100%;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--danger);
    border-radius: 8px;
    background: var(--danger-light);
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ===== Admin ===== */
.admin-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.admin-header {
    padding: 1rem 0 2rem;
}

.admin-header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    margin-top: 0.5rem;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.admin-set-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-set-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.admin-set-card:hover {
    border-color: var(--set-color, var(--primary));
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.admin-set-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.admin-set-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.admin-set-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.admin-set-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.admin-set-arrow {
    color: var(--text-muted);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.form-row .form-group:first-child {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-color {
    width: 48px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: var(--surface);
}

.form-textarea {
    padding: 0.8rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.form-textarea:focus {
    border-color: var(--primary);
}

.import-details {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    background: var(--surface);
}

.import-summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

/* ===== Question List ===== */
.question-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
}

.question-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    transition: background 0.2s;
}

.question-item:last-child {
    border-bottom: none;
}

.question-item.excluded {
    background: color-mix(in srgb, var(--bg) 80%, var(--surface));
}

.question-item.excluded .question-text-admin {
    opacity: 0.4;
    text-decoration: line-through;
}

.question-text-admin {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
}

.question-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-sm:hover {
    border-color: var(--text-muted);
}

.btn-sm-warning:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-sm-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .home-container {
        padding: 1rem 1rem 3rem;
    }
    .home-header {
        padding: 2rem 0 1.5rem;
    }
    .logo h1 {
        font-size: 2.5rem;
    }
    .admin-link {
        position: static;
        display: inline-block;
        margin-top: 1rem;
    }
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .question-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .question-actions {
        align-self: flex-end;
    }
}

/* ===== Dark Mode Toggle ===== */
.theme-toggle {
    position: fixed;
    bottom: 3.5rem;
    left: 0.75rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}
