:root {
    --bg: #0F172A;
    --bg-card: rgba(15, 23, 42, 0.8);
    --bg-input: rgba(10, 18, 35, 0.9);
    --text: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --primary: #06B6D4;
    --primary-glow: rgba(6, 182, 212, 0.15);
    --accent: #10B981;
    --accent-glow: rgba(16, 185, 129, 0.12);
    --border: rgba(6, 182, 212, 0.1);
    --border-focus: rgba(6, 182, 212, 0.4);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --font: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: linear-gradient(135deg, var(--primary), #0891B2);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-lg {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Main */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.section-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* Capture */
.capture-options {
    display: flex;
    gap: 1.5rem;
    align-items: stretch;
}

.capture-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.capture-divider {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
}

.capture-divider span {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

/* Webcam */
.webcam-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

.webcam-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.webcam-overlay {
    position: absolute;
    inset: 20px;
    border: 2px dashed rgba(6, 182, 212, 0.4);
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary);
    border-style: solid;
}

.corner.tl {
    top: -2px;
    left: -2px;
    border-width: 3px 0 0 3px;
    border-radius: 4px 0 0 0;
}

.corner.tr {
    top: -2px;
    right: -2px;
    border-width: 3px 3px 0 0;
    border-radius: 0 4px 0 0;
}

.corner.bl {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 3px 3px;
    border-radius: 0 0 0 4px;
}

.corner.br {
    bottom: -2px;
    right: -2px;
    border-width: 0 3px 3px 0;
    border-radius: 0 0 4px 0;
}

.capture-snap {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
}

/* Upload */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 200px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 1.5rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.upload-text {
    font-size: 0.88rem;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.72rem;
}

/* Process */
.process-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.image-container {
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Process Status */
.process-status {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.status-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.status-step.active {
    border-color: var(--primary);
    color: var(--primary);
}

.status-step.done {
    border-color: var(--accent);
    color: var(--accent);
}

.step-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.65rem;
    background: var(--bg-input);
}

.status-step.active .step-icon {
    background: var(--primary-glow);
}

.status-step.done .step-icon {
    background: var(--accent-glow);
}

/* Progress */
.progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0;
}

/* Results */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

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

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 150px;
}

.note-item {
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: grab;
    transition: var(--transition);
    position: relative;
}

.note-item:hover {
    border-color: var(--primary);
}

.note-item.dragging {
    opacity: 0.5;
}

.note-color {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.note-text {
    font-size: 0.85rem;
    line-height: 1.5;
    padding-left: 8px;
    outline: none;
    min-height: 1.5em;
}

.note-text[contenteditable]:focus {
    border-left: 2px solid var(--primary);
    padding-left: 6px;
}

.note-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.4rem;
    padding-left: 8px;
}

.note-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    transition: var(--transition);
}

.note-action-btn:hover {
    background: var(--bg-card);
    color: var(--text);
}

/* Export */
.export-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    padding: 2px;
}

.etab {
    flex: 1;
    padding: 0.4rem;
    background: none;
    border: none;
    border-radius: 4px;
    font-family: var(--font);
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.etab:hover {
    color: var(--text-secondary);
}

.etab.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.export-preview {
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent);
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

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

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
}

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

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.session-item {
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-item:hover {
    border-color: var(--primary);
}

.session-name {
    font-weight: 500;
    font-size: 0.88rem;
}

.session-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.session-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 3px;
}

.session-del:hover {
    color: #F87171;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .capture-options {
        flex-direction: column;
    }

    .capture-divider {
        justify-content: center;
        padding: 0.5rem 0;
    }

    .process-grid,
    .results-grid {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 0.75rem;
    }
}