:root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-muted: #f9fafb;
    --surface-subtle: #e5e7eb;
    --border: #d1d5db;
    --text: #111827;
    --text-muted: #4b5563;
    --text-subtle: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --indigo: #4f46e5;
    --indigo-hover: #4338ca;
    --purple: #7c3aed;
    --purple-hover: #6d28d9;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --warning-border: #f59e0b;
    --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

html.dark {
    --bg: #111827;
    --surface: #1f2937;
    --surface-muted: #273244;
    --surface-subtle: #374151;
    --border: #4b5563;
    --text: #f9fafb;
    --text-muted: #d1d5db;
    --text-subtle: #9ca3af;
    --warning-bg: rgba(245, 158, 11, 0.14);
    --warning-text: #fcd34d;
    --warning-border: rgba(245, 158, 11, 0.45);
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 1rem 3rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.page-center {
    justify-content: center;
}

.hidden {
    display: none !important;
}

.top-bar {
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 20;
}

.top-bar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
}

.icon-btn,
.nav-btn {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover,
.nav-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.page-title {
    font-size: 1.85rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    text-align: center;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-subtle);
    margin: 0 0 2rem;
    text-align: center;
}

.home-actions {
    width: 100%;
    max-width: 24rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.card {
    width: 100%;
    max-width: 28rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-top: 2.25rem;
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    text-align: center;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--text-subtle);
    margin: 0 0 1.25rem;
    text-align: center;
    line-height: 1.45;
}

.section-divider {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.4rem;
    margin-bottom: 1.4rem;
}

.section-divider-top {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin-top: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.btn {
    width: 100%;
    border: none;
    border-radius: 0.65rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-lg {
    padding: 1.1rem 1.25rem;
    font-size: 1.05rem;
    box-shadow: var(--shadow);
}

.btn-sm {
    width: auto;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 0.45rem;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-indigo {
    background: var(--indigo);
    color: #ffffff;
}

.btn-indigo:hover:not(:disabled) {
    background: var(--indigo-hover);
}

.btn-purple {
    background: var(--purple);
    color: #ffffff;
}

.btn-purple:hover:not(:disabled) {
    background: var(--purple-hover);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-secondary {
    background: var(--surface-subtle);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
    color: var(--primary);
    border-color: var(--primary);
}

.field-group {
    margin-bottom: 0.85rem;
    text-align: left;
}

.field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 0.55rem;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.textarea {
    font-size: 0.8rem;
    resize: vertical;
}

.row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.row > .grow {
    flex: 1;
}

.row-center {
    justify-content: center;
}

.mb-sm {
    margin-bottom: 0.75rem;
}

.btn-connect {
    width: 34%;
}

.options-panel {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
    font-size: 0.85rem;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-subtle);
    white-space: nowrap;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 7.5rem;
    padding: 0.85rem;
    border: 2px dashed var(--border);
    border-radius: 0.7rem;
    background: var(--surface-muted);
    color: var(--text-subtle);
    font-size: 0.86rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    margin-bottom: 0.85rem;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.drop-zone-indigo {
    border-color: rgba(79, 70, 229, 0.55);
}

.file-name-display {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.tabs {
    width: 100%;
    max-width: 28rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2.25rem;
    margin-bottom: -1.25rem;
}

.badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    background: rgba(0, 0, 0, 0.25);
    color: #e0e7ff;
}

.code-box {
    margin-top: 1rem;
    text-align: center;
}

.code-guide {
    font-size: 0.82rem;
    color: var(--text-subtle);
    margin: 0 0 0.35rem;
}

.code-value {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: 0.25rem;
    color: var(--primary);
    margin: 0;
}

.code-value-indigo {
    color: var(--indigo);
}

.code-input {
    text-align: center;
    font-size: 1.2rem;
    letter-spacing: 0.25rem;
    font-weight: 700;
}

.status-text {
    margin: 0.65rem 0 0;
    font-size: 0.84rem;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
    min-height: 1.2rem;
}

.status-text.status-error {
    color: var(--danger);
}

.status-text.status-success {
    color: var(--success);
}

.status-text.status-purple {
    color: var(--purple);
}

.notice-banner {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
    border-radius: 0.6rem;
    padding: 0.65rem 0.8rem;
    font-size: 0.78rem;
    line-height: 1.45;
    margin-bottom: 1rem;
}

.video-card {
    margin-top: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    background: var(--surface-muted);
}

.video-thumb {
    width: 100%;
    border-radius: 0.55rem;
    margin-bottom: 0.75rem;
    display: block;
    background: var(--surface-subtle);
}

.video-title {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 0 0 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.progress-list {
    margin-top: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.progress-item {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    padding: 0.7rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    margin-bottom: 0.45rem;
}

.progress-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.progress-pct {
    color: var(--primary);
    font-weight: 700;
}

.progress-track {
    width: 100%;
    height: 0.45rem;
    border-radius: 9999px;
    background: var(--surface-subtle);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 9999px;
    transition: width 0.1s linear;
}

.progress-actions {
    margin-top: 0.55rem;
    display: flex;
    justify-content: flex-end;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.modal-box {
    width: 100%;
    max-width: 21rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.65rem;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--text-subtle);
    font-size: 1.1rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.stack-sm {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.card-wide {
    max-width: 42rem;
}

.admin-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.admin-panel {
    margin-top: 0.5rem;
}

.info-box {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.84rem;
}

.info-label {
    color: var(--text-subtle);
    font-weight: 600;
    flex-shrink: 0;
}

.info-val {
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

.btn-auto {
    width: auto;
    white-space: nowrap;
}

.qr-wrapper {
    margin: 0.85rem auto 0.5rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    background: #ffffff;
    padding: 0.6rem;
    border-radius: 0.7rem;
    border: 1px solid var(--border);
}

.share-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 0.7rem 0.85rem;
}

.file-item-meta {
    min-width: 0;
    flex: 1;
}

.file-item-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-sub {
    font-size: 0.75rem;
    color: var(--text-subtle);
    margin-top: 0.2rem;
}

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

.dl-progress-wrap {
    margin-top: 0.85rem;
}

.cookie-viewer-bar {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.cookie-preview {
    margin: 0 0 1rem;
    padding: 0.75rem;
    max-height: 14rem;
    overflow: auto;
    border-radius: 0.55rem;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.45;
    white-space: pre;
}

.modal-wide {
    max-width: 34rem;
    max-height: 85vh;
    overflow-y: auto;
}

.guide-body {
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
}

.guide-heading {
    margin: 0.9rem 0 0.35rem;
    font-size: 0.92rem;
    color: var(--text);
}

.guide-list {
    margin: 0 0 0.5rem;
    padding-left: 1.25rem;
}

.guide-list li {
    margin-bottom: 0.35rem;
}

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

    .file-item {
        flex-direction: column;
        align-items: stretch;
    }

    .file-item-actions {
        justify-content: flex-end;
    }
}
