:root {
    --bg: #090b12;
    --sidebar: #0d111c;
    --panel: #101522;
    --panel-strong: #151b2b;
    --panel-raised: #1a2235;
    --text: #f3f6ff;
    --muted: #97a3ba;
    --line: #293145;
    --accent: #ffb000;
    --accent-strong: #ffc400;
    --accent-soft: rgba(255, 176, 0, 0.14);
    --teal: #37d2bd;
    --teal-soft: rgba(55, 210, 189, 0.15);
    --coral: #ff7a5f;
    --coral-soft: rgba(255, 122, 95, 0.15);
    --mustard: #ffb000;
    --mustard-soft: rgba(255, 176, 0, 0.15);
    --blue: #72a7ff;
    --blue-soft: rgba(114, 167, 255, 0.15);
    --green: #8fda75;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
    --radius: 8px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

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

button {
    cursor: pointer;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    padding: 18px 18px 12px;
}

.brand-mark,
.avatar,
.mini-avatar,
.context-badge {
    align-items: center;
    background: var(--teal);
    color: white;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    letter-spacing: 0;
    overflow: hidden;
    text-transform: uppercase;
}

.brand-mark {
    background: var(--accent);
    border-radius: 8px;
    color: #121212;
    height: 40px;
    width: 40px;
}

.brand-title {
    color: var(--accent-strong);
    font-size: 19px;
    font-weight: 750;
}

.brand-subtitle,
.brand-version,
.eyebrow,
.meta,
.hint {
    color: var(--muted);
    font-size: 12px;
}

.brand-version {
    margin-top: 1px;
}

.main-nav {
    display: grid;
    gap: 6px;
    padding: 8px 12px 12px;
}

.nav-item {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    display: flex;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    text-align: left;
}

.nav-item:hover,
.nav-item.active {
    background: var(--panel-strong);
    border-color: var(--line);
}

.nav-icon {
    align-items: center;
    background: #0a0d15;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    height: 24px;
    justify-content: center;
    width: 24px;
}

.sidebar-tools {
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    padding: 14px 14px 16px;
}

.filter-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-top: 4px;
}

.subsection-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin: 14px 0 6px;
    text-transform: uppercase;
}

.sidebar-tools label,
.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
textarea,
select {
    background: #0a0d15;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    min-height: 38px;
    outline: none;
    padding: 8px 10px;
    width: 100%;
}

textarea {
    min-height: 112px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(18, 108, 100, 0.13);
}

.segmented {
    background: #0a0d15;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 3px;
}

.segmented button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    min-height: 32px;
}

.segmented button.active {
    background: var(--accent);
    color: #111111;
    font-weight: 750;
}

.context-list {
    display: grid;
    gap: 14px;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 14px;
}

.sidebar-footer {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 6px;
    padding: 12px;
}

.footer-item {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    display: flex;
    gap: 10px;
    min-height: 38px;
    padding: 8px 10px;
    text-align: left;
    width: 100%;
}

a.footer-item {
    text-decoration: none;
}

.footer-item:hover,
.footer-item.active {
    background: var(--panel-strong);
    border-color: var(--line);
}

.context-group {
    display: grid;
    gap: 8px;
}

.group-heading {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 12px;
    font-weight: 750;
    gap: 8px;
    justify-content: space-between;
    text-transform: uppercase;
}

.contact-row {
    align-items: center;
    background: rgba(21, 27, 43, 0.78);
    border: 1px solid transparent;
    border-radius: var(--radius);
    display: grid;
    gap: 10px;
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: 62px;
    padding: 9px;
    position: relative;
    text-align: left;
    width: 100%;
}

.contact-row:hover,
.contact-row.active {
    background: var(--panel-raised);
    border-color: var(--accent);
}

.avatar {
    border-radius: 50%;
    height: 44px;
    position: relative;
    width: 44px;
}

.avatar.large {
    font-size: 26px;
    height: 76px;
    width: 76px;
}

.mini-avatar {
    background: var(--accent);
    border: 2px solid var(--sidebar);
    color: #111111;
    border-radius: 50%;
    bottom: 7px;
    font-size: 9px;
    height: 20px;
    position: absolute;
    right: 7px;
    width: 20px;
}

.contact-name,
.card-title,
.note-title {
    font-weight: 750;
}

.contact-role {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    align-items: center;
    background: rgba(9, 11, 18, 0.92);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 18px 24px 16px;
    position: sticky;
    top: 0;
    z-index: 4;
}

h1 {
    font-size: 26px;
    line-height: 1.15;
    margin: 2px 0 0;
}

h2 {
    font-size: 18px;
    margin: 0;
}

h3 {
    font-size: 15px;
    margin: 0;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
    align-items: center;
    border-radius: 7px;
    display: inline-flex;
    gap: 8px;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
}

.primary-button {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #111111;
    font-weight: 750;
}

.secondary-button {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    color: var(--text);
}

.danger-button {
    background: rgba(239, 68, 68, 0.09);
    border: 1px solid rgba(239, 68, 68, 0.42);
    color: #fecaca;
}

.ghost-button {
    background: transparent;
    border: 1px solid transparent;
    color: var(--accent-strong);
}

.icon-button {
    aspect-ratio: 1;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    padding: 0;
    width: 38px;
}

.view {
    display: none;
    padding: 22px 24px 32px;
}

.view.active {
    display: block;
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric,
.panel,
.context-card,
.note-card,
.tag-pill,
.drop-zone {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.metric {
    display: grid;
    gap: 8px;
    min-height: 112px;
    padding: 16px;
}

.metric-value {
    font-size: 30px;
    font-weight: 800;
}

.metric:nth-child(1) {
    border-top: 4px solid var(--accent);
}

.metric:nth-child(2) {
    border-top: 4px solid var(--coral);
}

.metric:nth-child(3) {
    border-top: 4px solid var(--mustard);
}

.metric:nth-child(4) {
    border-top: 4px solid var(--blue);
}

.content-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    margin-top: 16px;
}

.panel {
    padding: 16px;
}

.panel-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.list-stack,
.note-stream,
.tag-list,
.settings-stack {
    display: grid;
    gap: 10px;
}

.reminder-item,
.activity-item,
.debug-row {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 46px;
    padding: 8px 0;
}

.reminder-item:last-child,
.activity-item:last-child,
.debug-row:last-child {
    border-bottom: 0;
}

.detail-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.context-card {
    align-items: start;
    display: grid;
    gap: 14px;
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 144px;
    padding: 16px;
    position: relative;
    text-align: left;
}

.context-card.clickable:hover,
.context-card.clickable.active {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.context-badge {
    border-radius: 8px;
    height: 64px;
    width: 64px;
}

.context-badge.org {
    background: var(--blue);
}

.context-badge.project {
    background: var(--mustard);
}

.detail-lines {
    display: grid;
    gap: 5px;
    margin-top: 8px;
}

.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip,
.category,
.tag-inline,
.small-count {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    gap: 6px;
    min-height: 26px;
    padding: 4px 9px;
}

.chip {
    background: var(--teal-soft);
    color: #80eee1;
}

.chip.project {
    background: var(--mustard-soft);
    color: #65480e;
}

.chip.former {
    background: #232a3c;
    color: var(--muted);
}

.category.personal {
    background: var(--coral-soft);
    color: var(--coral);
}

.category.professional {
    background: var(--blue-soft);
    color: var(--blue);
}

.category.instruction {
    background: var(--mustard-soft);
    color: #6a4a0c;
}

.composer {
    margin-top: 16px;
}

.form-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field.wide {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 5px;
}

.drop-zone {
    align-items: center;
    border-style: dashed;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px;
}

.drop-zone.dragging {
    background: var(--teal-soft);
    border-color: var(--teal);
    color: var(--teal);
}

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

.attachment-pill {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    gap: 6px;
    padding: 5px 9px;
}

.suggestions {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: var(--shadow);
    display: none;
    margin-top: -4px;
    overflow: hidden;
}

.suggestions.active {
    display: block;
}

.suggestions button {
    background: transparent;
    border: 0;
    display: block;
    padding: 8px 10px;
    text-align: left;
    width: 100%;
}

.suggestions button:hover {
    background: var(--accent-soft);
}

.note-stream {
    margin-top: 16px;
}

.note-card {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.note-topline {
    align-items: start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.note-body {
    white-space: pre-wrap;
}

.context-line {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    gap: 7px;
}

.note-actions,
.note-tags,
.row-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.row-actions {
    justify-content: flex-end;
}

.form-actions {
    justify-content: flex-start;
    margin-top: 10px;
}

.tag-inline,
.tag-pill {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    color: var(--accent-strong);
}

.tag-pill {
    align-items: center;
    display: flex;
    justify-content: space-between;
    min-height: 46px;
    padding: 10px 12px;
    width: 100%;
}

.tag-toolbar {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) minmax(0, 1fr);
    margin-bottom: 14px;
}

.settings-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.code-box {
    background: #06080d;
    border-radius: 7px;
    color: #f7f1e5;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    max-height: 220px;
    overflow: auto;
    padding: 12px;
    white-space: pre-wrap;
}

.toast {
    background: #20283a;
    border-radius: 8px;
    bottom: 18px;
    box-shadow: var(--shadow);
    color: white;
    left: 50%;
    max-width: min(460px, calc(100vw - 32px));
    padding: 10px 13px;
    position: fixed;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: opacity 160ms ease, transform 160ms ease;
    z-index: 30;
}

.toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
    align-items: center;
    background: rgba(0, 0, 0, 0.68);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 40;
}

.modal-panel {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 48px);
    max-width: 940px;
    overflow: auto;
    padding: 16px;
    width: min(940px, 100%);
}

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

.modal-panel .composer {
    margin-top: 0;
}

.auth-page {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card,
.setup-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 16px;
    max-width: 440px;
    padding: 22px;
    width: min(100%, 440px);
}

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

.auth-brand {
    padding: 0;
}

.form-error,
.form-success {
    border-radius: var(--radius);
    padding: 10px 12px;
}

.form-error {
    background: var(--coral-soft);
    color: #ffb4a4;
}

.form-success {
    background: var(--teal-soft);
    color: #89f3e8;
}

.setup-section {
    box-shadow: none;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    padding: 20px;
    text-align: center;
}

@media (max-width: 1060px) {
    .app-shell {
        grid-template-columns: 280px minmax(0, 1fr);
    }

    .dashboard-grid,
    .detail-grid,
    .settings-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        border-bottom: 1px solid var(--line);
        border-right: 0;
        max-height: 54vh;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
        padding: 14px;
    }

    .view {
        padding: 14px;
    }

    .dashboard-grid,
    .form-grid,
    .tag-toolbar {
        grid-template-columns: 1fr;
    }

    .context-card {
        grid-template-columns: 1fr;
    }
}
