:root {
    --ws-purple: #6557ff;
    --ws-purple-dark: #5546ee;
    --ws-purple-soft: #eeecff;
    --ws-sidebar: #f8f8fc;
    --ws-border: #e3e5ef;
    --ws-text: #252631;
    --ws-muted: #8b8e9e;
    --ws-field: #f5f5f9;
}

body {
    background: #fff;
    color: var(--ws-text);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.topbar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    width: 240px;
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 24px 16px 18px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    border-right: 1px solid var(--ws-border);
    background: var(--ws-sidebar);
}

.brand {
    padding: 0 8px;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--ws-purple);
    box-shadow: 0 8px 18px rgba(101, 87, 255, .22);
    color: #fff;
    font-family: Georgia, serif;
    font-size: 18px;
}

.brand b {
    color: var(--ws-text);
    font-size: 16px;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--ws-muted);
    font-size: 11px;
    letter-spacing: 0;
}

.nav-section-label {
    margin: 34px 12px 9px;
    color: #a4a6b2;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
}

.topbar nav {
    display: grid;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
}

.nav-item {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    width: 100%;
    padding: 11px 12px;
    align-items: center;
    border-radius: 10px;
    color: #676b7b;
    font-size: 14px;
    text-align: left;
}

.nav-item i {
    color: #7d8191;
    font-size: 18px;
    font-style: normal;
    text-align: left;
}

.topbar .nav-item > span {
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
}

.nav-item strong {
    color: #aaaeba;
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    background: var(--ws-purple-soft);
    color: var(--ws-purple);
    box-shadow: none;
    font-weight: 600;
}

.nav-item.active i {
    color: var(--ws-purple);
}

.sidebar-profile {
    display: grid;
    grid-template-columns: 36px 1fr 34px;
    gap: 10px;
    align-items: center;
    margin-top: auto;
    padding: 14px 6px 0;
    border-top: 1px solid var(--ws-border);
}

.sidebar-profile > span {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 10px;
    background: #e9e6ff;
    color: var(--ws-purple);
    font-weight: 700;
}

.sidebar-profile b,
.sidebar-profile small {
    display: block;
}

.sidebar-profile b {
    font-size: 12px;
}

.sidebar-profile small {
    margin-top: 2px;
    color: var(--ws-muted);
    font-size: 10px;
}

.sidebar-profile .icon-button {
    width: 32px;
    height: 32px;
    border-color: var(--ws-border);
    background: #fff;
    color: #777b89;
}

main {
    width: auto;
    max-width: none;
    min-height: 100vh;
    margin: 0 0 0 240px;
    padding: 0;
}

.workspace-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    height: 70px;
    padding: 0 24px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--ws-border);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(12px);
}

.global-search {
    display: flex;
    width: min(390px, 45vw);
    height: 40px;
    padding: 0 14px;
    align-items: center;
    gap: 10px;
    border-radius: 11px;
    background: var(--ws-field);
    color: #9a9dac;
}

.global-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ws-text);
    font-size: 13px;
}

.workspace-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sync-status {
    color: #45a873;
    font-size: 11px;
}

.header-add {
    padding: 11px 17px;
    border: 0;
    border-radius: 9px;
    background: var(--ws-purple);
    box-shadow: 0 7px 16px rgba(101, 87, 255, .18);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.header-add:hover {
    background: var(--ws-purple-dark);
}

.view {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 28px 60px;
}

.hero {
    max-width: none;
    padding: 40px 0 20px;
}

.eyebrow {
    margin: 0 0 7px;
    color: #9a9dac;
    font-size: 9px;
    letter-spacing: .16em;
}

.hero h1,
.section-head h1 {
    margin: 0 0 7px;
    color: var(--ws-text);
    font-family: inherit;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.035em;
}

.hero > p:last-child,
.section-head > div > p:last-child {
    margin: 0;
    color: var(--ws-muted);
    font-size: 12px;
}

.reader-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, .75fr);
    gap: 14px;
}

.paper,
.lookup-card,
.flashcard {
    border-color: var(--ws-border);
    box-shadow: none;
}

.paper,
.lookup-card {
    border-radius: 13px;
}

.paper-toolbar {
    padding: 16px 20px;
    border-color: var(--ws-border);
}

.status-dot {
    background: var(--ws-purple);
}

.manual-form {
    padding: 24px;
}

.manual-form textarea {
    min-height: 138px;
    border-color: var(--ws-border);
    border-radius: 10px;
    background: #fafafd;
    font-size: 20px;
}

.manual-form textarea:focus {
    border-color: #a9a1ff;
    box-shadow: 0 0 0 3px rgba(101, 87, 255, .09);
}

.quick-examples button {
    background: var(--ws-field);
    color: #737687;
}

.quick-examples button:hover {
    background: var(--ws-purple-soft);
    color: var(--ws-purple);
}

.primary-button {
    background: var(--ws-purple);
    box-shadow: 0 6px 14px rgba(101, 87, 255, .15);
}

.primary-button:hover {
    background: var(--ws-purple-dark);
}

.lookup-card {
    top: 88px;
    min-height: 340px;
    padding: 24px;
}

.big-icon,
.empty-state > span {
    background: var(--ws-purple-soft);
    color: var(--ws-purple);
}

.sound-button {
    background: var(--ws-purple-soft);
    color: var(--ws-purple);
}

.structure-role,
.inline-role {
    color: var(--ws-purple);
}

.structure-role {
    background: var(--ws-purple-soft);
}

.structure-box {
    background: #fafafd;
}

.section-head {
    padding: 40px 0 22px;
}

.section-head h1 {
    font-size: 28px;
}

.stat-card {
    padding: 10px 14px;
    border-color: var(--ws-border);
    border-radius: 10px;
}

.stat-card b {
    font-family: inherit;
    font-size: 30px;
}

.word-toolbar {
    padding: 10px;
    border-color: var(--ws-border);
    border-radius: 12px;
}

.search-box,
select {
    background: var(--ws-field);
}

.word-list {
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}

.word-row,
.word-row.has-structure {
    margin-bottom: 9px;
    padding: 18px 16px;
    border: 1px solid var(--ws-border);
    border-radius: 12px;
    background: #fff;
}

.word-row:hover {
    border-color: #b9b3ff;
    box-shadow: 0 5px 16px rgba(74, 66, 160, .05);
}

.word-main b,
.inline-text {
    color: var(--ws-text);
    font-size: 18px;
}

.mastery {
    border-radius: 6px;
}

.mastery.new {
    background: #fff3dc;
    color: #b97917;
}

.mastery.learning {
    background: var(--ws-purple-soft);
    color: var(--ws-purple);
}

.mastery.mastered {
    background: #e7f7ee;
    color: #32845a;
}

.flashcard {
    border-radius: 14px;
}

.review-actions button {
    border-color: var(--ws-border);
}

.toast {
    background: #353641;
}

body.dark {
    --ws-sidebar: #191a22;
    --ws-border: #2e303b;
    --ws-text: #f2f2f5;
    --ws-muted: #9b9daa;
    --ws-field: #242630;
    background: #15161d;
}

body.dark .workspace-header,
body.dark .word-row,
body.dark .header-add {
    background-color: #1d1f28;
}

body.dark .topbar {
    background: var(--ws-sidebar);
}

@media (max-width: 850px) {
    .topbar {
        position: sticky;
        top: 0;
        width: 100%;
        height: 64px;
        padding: 0 14px;
        flex-direction: row;
        align-items: center;
        border-right: 0;
        border-bottom: 1px solid var(--ws-border);
    }

    .brand {
        display: flex;
        padding: 0;
    }

    .brand span:last-child,
    .nav-section-label,
    .sidebar-profile {
        display: none;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
    }

    .topbar nav {
        display: flex;
        margin-left: auto;
    }

    .nav-item {
        display: block;
        width: auto;
        padding: 8px 10px;
        font-size: 12px;
        text-align: center;
    }

    .nav-item i,
    .nav-item strong {
        display: none;
    }

    main {
        margin-left: 0;
    }

    .workspace-header {
        height: 60px;
        padding: 0 16px;
    }

    .sync-status {
        display: none;
    }

    .view {
        padding: 0 16px 45px;
    }
}

@media (max-width: 560px) {
    .global-search {
        width: 48vw;
    }

    .header-add {
        padding: 10px 12px;
    }

    .hero {
        padding-top: 28px;
    }
}
