:root {
    color-scheme: light;
    --accent: #5b7d9f;
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-solid: #ffffff;
    --surface-soft: #edf2f7;
    --surface-muted: #f8fafc;
    --text: #18212b;
    --muted: #697789;
    --line: rgba(25, 40, 57, 0.1);
    --line-strong: rgba(25, 40, 57, 0.16);
    --shadow: 0 20px 60px rgba(35, 53, 72, 0.12);
    --shadow-soft: 0 10px 32px rgba(35, 53, 72, 0.08);
    --radius: 16px;
    --radius-small: 10px;
    --topbar: 78px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        color-scheme: dark;
        --bg: #0f141b;
        --surface: rgba(24, 30, 39, 0.9);
        --surface-solid: #161d26;
        --surface-soft: #1f2a35;
        --surface-muted: #111821;
        --text: #edf3f8;
        --muted: #9cabb8;
        --line: rgba(235, 243, 250, 0.1);
        --line-strong: rgba(235, 243, 250, 0.16);
        --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
        --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.18);
    }
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f141b;
    --surface: rgba(24, 30, 39, 0.9);
    --surface-solid: #161d26;
    --surface-soft: #1f2a35;
    --surface-muted: #111821;
    --text: #edf3f8;
    --muted: #9cabb8;
    --line: rgba(235, 243, 250, 0.1);
    --line-strong: rgba(235, 243, 250, 0.16);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.18);
}

html[data-theme="light"] {
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: inherit;
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent), transparent 85%), transparent 34rem),
        var(--bg);
}

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

button {
    cursor: pointer;
}

a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1.04;
}

h2 {
    margin-bottom: 0;
    font-size: 1.25rem;
    line-height: 1.15;
}

h3 {
    margin-bottom: 0.4rem;
    font-size: 1rem;
}

p {
    color: var(--muted);
    line-height: 1.6;
}

.eyebrow,
.auth-kicker {
    display: block;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.74rem;
    font-weight: 800;
}

.muted,
.card-meta {
    color: var(--muted);
    font-size: 0.84rem;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface-solid);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
    border-color: color-mix(in srgb, var(--accent), white 12%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent), transparent 82%);
}

.button,
.small-button,
.icon-button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface-solid);
    color: var(--text);
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 800;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.button:hover,
.small-button:hover,
.icon-button:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent), var(--line) 35%);
}

.button.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.button.ghost {
    background: transparent;
}

.small-button {
    min-height: 34px;
    font-size: 0.82rem;
    padding: 0 11px;
}

.icon-button {
    width: 42px;
    padding: 0;
    border-radius: 999px;
}

.icon-button span {
    width: 16px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    display: block;
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.search-filter-tabs,
.module-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-solid);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.search-filter-tabs button,
.nav-item {
    min-height: 32px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    padding: 0 12px;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.search-filter-tabs button.active,
.nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--accent), transparent 72%);
}

.notice {
    border-radius: var(--radius-small);
    padding: 12px 14px;
    background: var(--surface-soft);
}

.notice.error {
    background: #fff0f0;
    color: #a33a3a;
}

html[data-theme="dark"] .notice.error,
html[data-theme="system"] .notice.error {
    background: rgba(180, 60, 60, 0.14);
    color: #ffb0b0;
}

.login-screen,
.setup-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(100%, 460px);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.setup-card {
    width: min(100%, 560px);
}

.auth-logo {
    width: min(320px, 80vw);
    display: block;
    margin: 0 auto 24px;
}

.app-body {
    overflow: hidden;
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    grid-template-rows: var(--topbar) minmax(0, 1fr);
    height: 100vh;
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid), transparent 10%);
    backdrop-filter: blur(20px);
    z-index: 5;
}

.brand {
    display: flex;
    align-items: center;
    flex: 0 0 188px;
    min-width: 0;
}

.brand img {
    width: 170px;
    max-width: 100%;
    height: auto;
}

.search-trigger {
    margin-left: auto;
}

.mobile-only {
    display: none;
}

.sidebar {
    min-height: 0;
    overflow: auto;
    padding: 20px 16px 26px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid), transparent 16%);
}

.sidebar-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.category-tree,
.folder-tree,
.folder-children,
.task-list-stack {
    display: grid;
    gap: 6px;
}

.category-item,
.task-list-row {
    width: 100%;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 12px;
    text-align: left;
    font-weight: 700;
}

.category-item:hover,
.category-item.active,
.task-list-row:hover,
.task-list-row.active {
    color: var(--text);
    background: var(--surface-soft);
    border-color: var(--line);
}

.wiki-root {
    margin-bottom: 4px;
}

.folder-node {
    display: grid;
    gap: 4px;
}

.folder-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    min-height: 38px;
    padding-left: calc(var(--depth) * 15px);
    border-radius: 10px;
}

.folder-row:hover,
.folder-row.active {
    background: var(--surface-soft);
}

.folder-toggle {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: grid;
    place-items: center;
}

.folder-toggle span {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 6px solid currentColor;
    transition: transform 140ms ease;
}

.folder-toggle.open span {
    transform: rotate(90deg);
}

.folder-button {
    min-width: 0;
    min-height: 36px;
    border: 0;
    background: transparent;
    color: var(--text);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    text-align: left;
    padding: 0 10px 0 0;
}

.folder-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 750;
}

.folder-count {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.compact-muted {
    margin: 8px 0 0;
    padding: 0 10px;
}

.workspace {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 30px clamp(18px, 3vw, 44px) 40px;
}

.workspace-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.workspace-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.save-status,
.dock-count {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.content-area,
.home-shell,
.knowledge-shell,
.tasks-shell,
.settings-stack,
.search-group {
    display: grid;
    gap: 16px;
}

.hero-panel,
.favorites-dock,
.app-section,
.wiki-entry-list,
.wiki-editor-topbar,
.editor-panel,
.tasks-lists-panel,
.tasks-main-panel,
.settings-section,
.empty-panel,
.search-card,
.search-result {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.hero-panel,
.favorites-dock,
.app-section,
.tasks-lists-panel,
.tasks-main-panel,
.settings-section,
.empty-panel {
    padding: 18px;
}

.hero-panel {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.hero-panel.compact {
    align-items: center;
}

.hero-panel h2 {
    margin: 6px 0 8px;
    font-size: 1.7rem;
}

.hero-panel p {
    margin-bottom: 0;
}

.hero-actions,
.empty-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.section-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.section-title-row h2 {
    margin-top: 4px;
}

.dock-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.dock-item {
    min-width: 156px;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-solid), transparent 12%);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    font-weight: 800;
}

.dashboard-sections,
.todo-items {
    display: grid;
    gap: 14px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.app-tile {
    position: relative;
    min-height: 104px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--surface-solid), transparent 6%), color-mix(in srgb, var(--surface-soft), transparent 24%));
    text-decoration: none;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 12px;
    padding: 14px;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.app-tile:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent), var(--line) 34%);
    box-shadow: 0 16px 36px rgba(35, 53, 72, 0.12);
}

.app-tile.dragging {
    opacity: 0.45;
    transform: scale(0.98);
}

.app-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,0.62), transparent 38%),
        color-mix(in srgb, var(--accent), transparent 18%);
    color: white;
    font-size: 1rem;
    font-weight: 950;
}

.app-icon.small {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 0.8rem;
    flex: 0 0 auto;
}

.app-info {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.app-title,
.card-title {
    font-size: 1rem;
    font-weight: 850;
    color: var(--text);
}

.app-title,
.app-description,
.app-host,
.wiki-entry-title,
.wiki-entry-excerpt {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-description,
.app-host {
    color: var(--muted);
    font-size: 0.8rem;
}

.app-host {
    font-size: 0.74rem;
    font-weight: 750;
}

.app-favorite {
    align-self: start;
    justify-self: end;
    color: color-mix(in srgb, var(--muted), transparent 36%);
}

.app-favorite.active,
.wiki-entry-favorite {
    color: var(--accent);
}

.wiki-entry-row {
    position: relative;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    text-align: left;
    padding: 16px 20px;
}

.wiki-entry-row:last-child {
    border-bottom: 0;
}

.wiki-entry-row:hover {
    background: var(--surface-soft);
}

.wiki-entry-main {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.wiki-entry-title {
    font-size: 1rem;
    font-weight: 850;
}

.wiki-entry-excerpt,
.wiki-entry-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

.wiki-entry-meta {
    display: grid;
    gap: 4px;
    justify-items: end;
    text-align: right;
    padding-right: 26px;
}

.wiki-entry-favorite {
    position: absolute;
    top: 16px;
    right: 20px;
}

.wiki-editor-shell {
    display: grid;
    gap: 14px;
}

.wiki-editor-topbar {
    min-height: 56px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.wiki-editor-context {
    display: grid;
    gap: 2px;
    justify-items: end;
    text-align: right;
}

.editor {
    display: grid;
    gap: 14px;
}

.editor-panel {
    padding: 18px;
    min-height: calc(100vh - var(--topbar) - 220px);
}

.editor-title {
    font-size: 1.8rem;
    font-weight: 850;
    min-height: 56px;
}

.editor-meta,
.editor-controls,
.toggle-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.editor-meta {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 750;
}

.editor-controls select {
    width: min(100%, 340px);
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toggle-line {
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 750;
}

.toggle-line input {
    width: 18px;
    min-height: 18px;
    height: 18px;
}

.tasks-shell {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    align-items: start;
}

.task-list-row span:last-child {
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--surface-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 800;
}

.todo-row {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-solid), transparent 14%);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.todo-row.done .card-title {
    text-decoration: line-through;
    color: var(--muted);
}

.priority {
    border-radius: 999px;
    padding: 4px 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
}

.priority.high {
    color: #b94e4e;
}

.empty-state,
.empty-panel {
    text-align: left;
}

.refined-empty {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.empty-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    background: color-mix(in srgb, var(--accent), transparent 14%);
    color: white;
    font-weight: 900;
    margin-bottom: 16px;
}

.settings-stack {
    gap: 18px;
}

.settings-section {
    display: grid;
    gap: 18px;
}

.section-copy h2 {
    margin: 6px 0 8px;
}

.section-copy p {
    margin-bottom: 0;
}

.settings-form {
    display: grid;
    gap: 14px;
}

.settings-form.narrow {
    max-width: 520px;
}

.dialog {
    border: 0;
    padding: 0;
    background: transparent;
}

.dialog::backdrop {
    background: rgba(12, 18, 28, 0.4);
    backdrop-filter: blur(12px);
}

.dialog-card {
    width: min(100vw - 24px, 600px);
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-solid);
    box-shadow: var(--shadow);
}

.dialog-card header,
.dialog-card footer,
.search-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.dialog-card footer {
    margin-top: 16px;
}

.icon-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 1.3rem;
}

.search-dialog .dialog-card {
    width: min(100vw - 24px, 820px);
}

.search-card {
    padding: 20px;
}

.search-card-head h2 {
    margin: 6px 0 0;
}

.search-overlay-input {
    margin: 18px 0 16px;
}

.search-page-input {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-solid), transparent 4%);
}

.search-page-input input {
    min-height: 50px;
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 0;
}

.search-filter-tabs.large {
    justify-self: start;
    margin-bottom: 16px;
}

.palette-results {
    min-height: 160px;
}

.search-group {
    gap: 10px;
}

.search-group-title {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.search-result {
    width: 100%;
    padding: 14px 16px;
    text-align: left;
    display: grid;
    gap: 4px;
    background: color-mix(in srgb, var(--surface-solid), transparent 10%);
}

.search-result:hover {
    border-color: color-mix(in srgb, var(--accent), var(--line) 34%);
    background: var(--surface-soft);
}

@media (max-width: 1280px) {
    :root {
        --topbar: 126px;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 10px 14px;
    }

    .module-nav {
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .module-nav::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 980px) {
    .tasks-shell {
        grid-template-columns: 1fr;
    }

    .wiki-entry-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .wiki-entry-meta {
        justify-items: start;
        text-align: left;
        padding-right: 0;
    }
}

@media (max-width: 820px) {
    :root {
        --topbar: 156px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .topbar {
        gap: 10px;
        padding: 10px;
    }

    .brand {
        flex: 1 1 150px;
    }

    .brand img {
        width: 138px;
    }

    .module-nav {
        order: 3;
        flex-basis: 100%;
    }

    .mobile-only {
        display: inline-flex;
        flex-direction: column;
        gap: 3px;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        z-index: 10;
        transform: translateX(-105%);
        transition: transform 220ms ease;
        box-shadow: var(--shadow);
        background: var(--surface-solid);
        padding-top: 92px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .workspace {
        padding: 18px 14px 32px;
    }

    .workspace-head,
    .hero-panel,
    .wiki-editor-topbar {
        display: grid;
    }

    .workspace-actions,
    .hero-actions,
    .wiki-editor-context {
        justify-content: start;
        justify-items: start;
        text-align: left;
    }
}

@media (max-width: 560px) {
    :root {
        --topbar: 182px;
    }

    .workspace-head {
        margin-bottom: 16px;
    }

    .hero-panel,
    .favorites-dock,
    .app-section,
    .editor-panel,
    .tasks-lists-panel,
    .tasks-main-panel,
    .settings-section,
    .empty-panel,
    .search-card,
    .refined-empty {
        padding: 15px;
    }

    .dialog-card {
        width: min(100vw - 12px, 600px);
        padding: 16px;
    }

    .search-dialog .dialog-card {
        width: min(100vw - 12px, 820px);
    }

    .app-grid {
        grid-template-columns: 1fr;
    }

    .app-tile {
        min-height: 92px;
        grid-template-columns: 48px minmax(0, 1fr) 22px;
    }

    .app-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    .dock-item {
        min-width: 142px;
    }

    .wiki-entry-row {
        padding: 14px 15px;
        gap: 8px;
    }

    .wiki-entry-favorite {
        top: 14px;
        right: 15px;
    }

    .nav-item,
    .search-filter-tabs button {
        min-height: 36px;
        padding: 0 10px;
    }

    .editor-title {
        font-size: 1.55rem;
    }
}
