:root {
    --primary-color: oklch(62% 0.18 280);
    --primary-hover: oklch(58% 0.20 280);
    --accent-color: oklch(70% 0.15 240);
    --error-color: oklch(65% 0.22 25);
    --primary-glow: oklch(62% 0.18 280 / 0.35);
    --primary-active-bg: oklch(35% 0.1 280);

    --text-primary: oklch(92% 0.01 280);
    --text-secondary: oklch(70% 0.02 280);
    --text-muted: oklch(55% 0.02 280);

    --surface-bg: oklch(18% 0.015 280);
    --surface-1: oklch(22% 0.018 280);
    --surface-2: oklch(26% 0.02 280);
    --surface-3: oklch(30% 0.022 280);
    --border-color: oklch(34% 0.02 280);

    --sidebar-width: 280px;
    --border-radius: 10px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--surface-bg);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color-scheme: dark;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;

    @supports (font-variation-settings: normal) {
        font-family: "InterVariable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    }
}

::selection {
    background-color: var(--primary-active-bg);
    color: var(--text-primary);
}

input, textarea, button, select {
    font: inherit;
}

h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--surface-1);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;

    @media (max-width: 800px) {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
}

#main-content {
    flex: 1;
    padding: 0 4rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;

    @media (max-width: 800px) {
        padding: 5rem 1.5rem 2rem;
    }
}

#welcome-view, #summary-view {
    width: 100%;
    max-width: 70ch;
    margin: 3rem 0;

    @media (max-width: 800px) {
        margin-top: 0;
        max-width: 100%;
    }
}

#welcome-view {
    header {
        text-align: center;
        margin-bottom: 3rem;

        @media (max-width: 800px) {
            margin-bottom: 2rem;
        }

        h1 {
            font-size: 3rem;
            font-weight: 700;
            margin-bottom: 0.75rem;
            background: linear-gradient(120deg, var(--accent-color) 0%, var(--primary-color) 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;

            @media (max-width: 800px) {
                font-size: 2.5rem;
            }
        }

        p {
            color: var(--text-secondary);
            font-size: 1.125rem;
            max-width: 560px;
            margin-inline: auto;
            line-height: 1.7;
        }
    }
}

#summary-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;

    @media (max-width: 800px) {
        flex-direction: column;
    }

    input[type="url"] {
        flex: 1;
        font-size: 1rem;
        border-radius: var(--border-radius);
        background: var(--surface-2);
        color: var(--text-primary);
        padding: 0.9rem 1rem 0.9rem 2.75rem;
        transition: var(--transition);
        border: 1px solid var(--border-color);
        outline: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23817e90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 0.8rem center;

        &:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px var(--primary-glow);
        }
    }

    button {
        background: var(--primary-color);
        color: white;
        font-weight: 600;
        border: none;
        cursor: pointer;
        padding: 0.9rem 1.5rem;
        border-radius: var(--border-radius);
        transition: var(--transition);

        &:hover {
            background: var(--primary-hover);
            transform: translateY(-1px);
        }
    }
}

/* Components */
[data-lucide] {
    width: 1.1em;
    height: 1.1em;
    stroke-width: 2;
    vertical-align: middle;
    pointer-events: none;
    flex-shrink: 0;
}

#new-summary-btn {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px -5px var(--primary-glow);

    &:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px -5px var(--primary-glow);
    }

    @media (max-width: 800px) {
        flex: 1;
        margin-right: 0.5rem;
    }
}

#saved-summaries-section {
    flex: 1;
    overflow-y: auto;
    margin: 2rem -0.5rem 0;

    h2 {
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        margin-bottom: 1rem;
        padding: 0 1.25rem;
    }
}

#saved-summaries-list {
    li {
        display: flex;
        align-items: center;
        margin: 0.25rem 0.5rem;
        border-radius: var(--border-radius);
        transition: var(--transition);
        position: relative;

        a {
            display: flex;
            align-items: center;
            padding: 0.75rem 2.5rem 0.75rem 1.25rem;
            color: var(--text-secondary);
            text-decoration: none;
            transition: var(--transition);
            font-weight: 500;
            font-size: 0.9rem;
            gap: 0.75rem;
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            mask-image: linear-gradient(to right, black 80%, transparent 90%);
        }

        &:hover:not(.active) {
            background: var(--surface-2);

            a {
                color: var(--text-primary);
            }
        }

        &.active {
            background: var(--primary-active-bg);
            box-shadow: 0 0 15px -5px var(--primary-glow);

            a {
                color: var(--text-primary);
                font-weight: 600;
            }
        }

        &:hover .delete-summary-btn {
            opacity: 0.8;
            pointer-events: auto;
            color: var(--error-color);
        }
    }
}

.delete-summary-btn {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: calc(var(--border-radius) * 0.6);
    transition: var(--transition);
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0;
    pointer-events: none;

    &:hover {
        opacity: 1;
        background: oklch(65% 0.22 25 / 0.15);
    }
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: calc(var(--border-radius) * 0.6);
    transition: var(--transition);
    font-size: 0.95rem;
    line-height: 1;

    &:hover {
        color: var(--text-primary);
        background: var(--surface-3);
    }
}

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

#clear-summaries-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    &:hover {
        background: oklch(65% 0.25 25 / 0.1);
        color: var(--error-color);
        border-color: oklch(65% 0.25 25 / 0.5);
    }
}

.settings-details, #transcript-details {
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) * 1.6);
    background: var(--surface-1);
    overflow: hidden;

    summary {
        padding: 1.25rem;
        cursor: pointer;
        font-weight: 500;
        display: flex;
        align-items: center;
        justify-content: space-between;
        list-style: none;
        transition: var(--transition);

        &:hover {
            background: var(--surface-2);
        }
    }

    .chevron {
        color: var(--text-muted);
        transition: transform 0.3s;
    }

    &[open] {
        & > summary {
            border-bottom: 1px solid var(--border-color);
        }

        .chevron {
            transform: rotate(180deg);
        }
    }
}

.settings-details {
    margin-top: 2rem;
}

.settings-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;

    & > div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    input[type="text"], input[type="password"], textarea {
        width: 100%;
        font-size: 0.95rem;
        background: var(--surface-2);
        color: var(--text-primary);
        padding: 0.75rem 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        transition: var(--transition);
        outline: none;

        &:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px var(--primary-glow);
        }
    }

    textarea {
        resize: vertical;
        min-height: 100px;
        line-height: 1.6;
    }

    .checkbox-group {
        flex-direction: row;
        align-items: center;

        label {
            user-select: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 0.25rem;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: 0.95rem;
        }
    }

    input[type="checkbox"] {
        appearance: none;
        width: 1.35em;
        height: 1.35em;
        border: 1px solid var(--border-color);
        background: var(--surface-2);
        border-radius: calc(var(--border-radius) * 0.6);
        cursor: pointer;
        position: relative;
        transition: var(--transition);

        &::before {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0.8em;
            height: 0.8em;
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'/%3e%3c/svg%3e");
            background-position: center;
            background-repeat: no-repeat;
            background-size: 100%;
            transform: translate(-50%, -50%) scale(0);
            transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        &:checked {
            border-color: var(--primary-color);
            background: var(--primary-color);

            &::before {
                transform: translate(-50%, -50%) scale(1);
            }
        }

        &:hover:not(:checked) {
            border-color: var(--text-secondary);
        }
    }
}

#summary-container {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) * 1.6);
    padding: 2.5rem;

    @media (max-width: 800px) {
        padding: 1.5rem;
    }
}

#summary-title {
    font-size: 1.75rem;
    font-weight: 700;
    padding: 0 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;

    @media (max-width: 800px) {
        font-size: 1.5rem;
        padding: 0 0 1rem;
        margin-bottom: 1rem;
    }

    #summary-title-text {
        flex: 1;
        text-align: center;
        margin: 0 1rem;
    }

    [data-lucide] {
        color: var(--primary-color);
        width: 1.3em;
        height: 1.3em;
    }
}

md-block {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-secondary);

    & > * + * {
        margin-top: 1.25em;
    }

    h1, h2, h3, h4 {
        color: var(--text-primary);
        line-height: 1.3;
        margin-bottom: 0.75em;
    }

    h2 {
        padding-bottom: 0.4em;
        border-bottom: 1px solid var(--border-color);
    }

    a {
        color: var(--primary-color);
        text-decoration: none;
        font-weight: 500;
        transition: var(--transition);
        border-bottom: 1px solid transparent;

        &:hover {
            color: var(--accent-color);
            border-bottom-color: var(--accent-color);
        }
    }

    code {
        background: var(--surface-2);
        padding: 0.25em 0.5em;
        border-radius: calc(var(--border-radius) * 0.6);
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.9em;
        color: var(--text-primary);
        border: 1px solid var(--border-color);
    }

    pre {
        background: var(--surface-bg);
        padding: 1.25rem;
        border-radius: var(--border-radius);
        overflow-x: auto;
        border: 1px solid var(--border-color);
        font-size: 0.9rem;

        code {
            background: none;
            padding: 0;
            border: none;
        }
    }

    blockquote {
        border-left: 3px solid var(--primary-color);
        padding-left: 1.5rem;
        font-style: italic;
        color: var(--text-muted);
    }

    ul, ol {
        padding-left: 1.5rem;
    }

    li::marker {
        color: var(--primary-color);
        font-weight: 600;
    }

    hr {
        border: none;
        height: 1px;
        background: var(--border-color);
    }
}

#transcript-section {
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

#transcript-details {
    summary {
        font-size: 1.1rem;

        @media (max-width: 800px) {
            font-size: 1rem;
            padding: 1rem;
        }

        & > span:first-child {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
    }

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

#transcript-text {
    background: var(--surface-bg);
    padding: 1.5rem;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#status-container {
    padding: 3rem 0;
    text-align: center;
}

#loader {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
}

.spinner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 5px solid var(--surface-3);
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#error-message {
    color: var(--error-color);
    font-weight: 500;
    background: oklch(65% 0.22 25 / 0.1);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid oklch(65% 0.22 25 / 0.3);
}

/* Mobile Menu */
#menu-toggle-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1002;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);

    &:hover {
        background: var(--surface-3);
        border-color: var(--primary-color);
    }

    @media (max-width: 800px) {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

body.sidebar-open {
    #menu-toggle-btn {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.1s;
    }

    @media (max-width: 800px) {
        #sidebar {
            transform: translateX(0);
        }

        #sidebar-overlay {
            display: block;
        }
    }
}

#close-sidebar-btn {
    display: none;

    @media (max-width: 800px) {
        display: block;
        padding: 0.8rem;
    }
}

.sidebar-header {
    @media (max-width: 800px) {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: oklch(0 0 0 / 0.5);
    z-index: 1000;
}

.hidden {
    display: none !important;
}