.notes-view {
    min-width: 0;
    overflow: hidden;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
}

.notes-topbar {
    display: flex;
    min-height: var(--topbar-height);
    flex: 0 0 var(--topbar-height);
    align-items: center;
    gap: 18px;
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.notes-topbar-brand {
    display: flex;
    min-width: 150px;
    align-items: center;
    gap: 12px;
}

.notes-topbar-brand > div {
    min-width: 0;
}

.notes-topbar-brand h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.notes-eyebrow {
    display: block;
    margin: 0 0 2px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 1.3;
}

.notes-global-search {
    display: flex;
    width: min(360px, 40vw);
    min-width: 150px;
    height: 36px;
    align-items: center;
    gap: 9px;
    margin-left: auto;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    transition: border-color var(--ease), box-shadow var(--ease);
}

.notes-global-search:focus-within {
    border-color: var(--border-gold-strong);
    box-shadow: 0 0 0 2px var(--gold-subtle);
}

.notes-global-search > i {
    flex: 0 0 auto;
    font-size: 12px;
}

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

.notes-global-search input::placeholder {
    color: var(--text-muted);
}

.notes-global-search kbd {
    flex: 0 0 auto;
    color: var(--text-muted);
    font: inherit;
    font-size: 9px;
    white-space: nowrap;
}

.notes-create-btn {
    display: inline-flex;
    min-height: 36px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 13px;
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-sm);
    background: var(--gold);
    color: var(--text-inverse);
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}

.notes-create-btn:hover {
    background: var(--gold-light);
    box-shadow: 0 4px 14px rgba(212, 175, 55, .14);
}

.notes-create-btn:active {
    transform: translateY(1px);
}

.notes-create-btn:focus-visible,
.notes-icon-btn:focus-visible,
.notes-format-toolbar button:focus-visible,
.notes-filter:focus-visible,
.notes-row-main:focus-visible,
.notes-mobile-back:focus-visible {
    outline: 2px solid var(--gold-light);
    outline-offset: 2px;
}

.notes-layout {
    display: grid;
    min-height: 0;
    flex: 1;
    grid-template-columns: minmax(230px, 292px) minmax(0, 1fr);
}

.notes-sidebar {
    display: flex;
    min-height: 0;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: #0e0f11;
}

.notes-filter-nav {
    display: grid;
    gap: 2px;
    padding: 14px 12px 12px;
    border-bottom: 1px solid var(--border);
}

.notes-filter {
    display: flex;
    min-height: 35px;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.notes-filter > i {
    width: 14px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.notes-filter > span {
    flex: 1;
}

.notes-filter > small {
    color: var(--text-muted);
    font-size: 10px;
}

.notes-filter:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.notes-filter.is-active {
    border-color: rgba(212, 175, 55, .12);
    background: var(--gold-subtle);
    color: var(--text);
}

.notes-filter.is-active > i {
    color: var(--gold);
}

.notes-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px 8px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
}

.notes-list-heading > span:last-child {
    font-size: 10px;
    font-weight: 500;
}

.notes-list {
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding: 0 9px 14px;
}

.notes-group-label {
    padding: 10px 9px 5px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
}

.notes-row {
    position: relative;
    display: flex;
    align-items: stretch;
    margin-bottom: 3px;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: border-color var(--ease), background var(--ease);
}

.notes-row:hover,
.notes-row.is-active {
    border-color: var(--border);
    background: var(--surface-raised);
}

.notes-row.is-active {
    border-color: var(--border-gold);
}

.notes-row-main {
    display: flex;
    min-width: 0;
    min-height: 67px;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 9px 5px 9px 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.notes-row-title-line {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.notes-row-title {
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-row-title-line > i {
    flex: 0 0 auto;
    color: var(--gold);
    font-size: 9px;
}

.notes-row-preview {
    overflow: hidden;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-row-meta {
    color: var(--text-muted);
    font-size: 9px;
}

.notes-row-menu-wrap,
.notes-popover-wrap {
    position: relative;
    flex: 0 0 auto;
}

.notes-row-menu-wrap {
    display: flex;
    align-items: flex-start;
    padding: 6px 5px 0 0;
}

.notes-icon-btn {
    display: inline-grid;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.notes-icon-btn:hover,
.notes-icon-btn[aria-expanded="true"] {
    border-color: var(--border);
    background: var(--surface-hover);
    color: var(--text);
}

.notes-popover {
    position: absolute;
    z-index: 20;
    top: calc(100% + 5px);
    right: 0;
    display: grid;
    width: 205px;
    gap: 2px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #17181b;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .38);
}

.notes-popover[hidden] {
    display: none;
}

.notes-popover button {
    display: flex;
    min-height: 31px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 9px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.notes-popover button:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
}

.notes-popover button:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.notes-popover button small {
    color: var(--text-muted);
    font-size: 9px;
}

.notes-popover-divider {
    height: 1px;
    margin: 3px 5px;
    background: var(--border);
}

.notes-list-empty {
    padding: 16px 12px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.55;
}

.notes-editor-panel {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    background: var(--bg);
}

.notes-editor-empty {
    display: flex;
    min-height: 100%;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.notes-empty-icon {
    display: grid;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    place-items: center;
    border: 1px solid var(--border-gold);
    border-radius: 14px;
    background: var(--gold-subtle);
    color: var(--gold);
    font-size: 20px;
}

.notes-editor-empty h2 {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
}

.notes-editor-empty p {
    margin: 0 0 18px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.65;
}

.notes-editor-content {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.notes-editor-content[hidden],
.notes-editor-empty[hidden] {
    display: none;
}

.notes-editor-header {
    display: flex;
    min-height: 66px;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    padding: 12px clamp(18px, 4vw, 48px);
    border-bottom: 1px solid var(--border);
}

.notes-title-input {
    width: 100%;
    min-width: 0;
    flex: 1;
    padding: 4px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 20px;
    font-weight: 650;
}

.notes-title-input:focus-visible {
    box-shadow: 0 1px 0 var(--gold);
}

.notes-save-state {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
}

.notes-save-state[data-state="saving"]::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    content: "";
    animation: notes-save-pulse 1s ease-in-out infinite;
}

.notes-save-state[data-state="saved"]::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #67b987;
    content: "";
}

.notes-save-state button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--gold-light);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

@keyframes notes-save-pulse {
    50% { opacity: .35; }
}

.notes-editor-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.notes-ask-btn {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    gap: 7px;
    padding: 0 9px;
    border: 1px solid var(--border-gold);
    border-radius: 6px;
    background: rgba(212, 175, 55, .08);
    color: var(--gold-light);
    font: inherit;
    font-size: 10px;
    cursor: pointer;
}

.notes-ask-btn > i:first-child {
    color: var(--gold);
}

.notes-ask-btn > i:last-child {
    font-size: 8px;
}

.notes-ask-btn:hover,
.notes-ask-btn[aria-expanded="true"] {
    background: rgba(212, 175, 55, .15);
}

.notes-format-toolbar {
    display: flex;
    min-height: 42px;
    flex: 0 0 auto;
    align-items: center;
    gap: 3px;
    overflow-x: auto;
    padding: 5px clamp(18px, 4vw, 48px);
    border-bottom: 1px solid var(--border);
    background: rgba(17, 18, 21, .7);
    scrollbar-width: thin;
}

.notes-format-toolbar select {
    max-width: 104px;
    height: 29px;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 10px;
}

.notes-format-toolbar select:focus-visible {
    outline: 1px solid var(--gold);
}

.notes-format-toolbar select option {
    background: var(--surface-raised);
}

.notes-format-toolbar > button {
    display: grid;
    width: 29px;
    height: 29px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--ease), color var(--ease);
}

.notes-format-toolbar > button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.notes-format-toolbar > button i {
    font-size: 11px;
}

.notes-toolbar-separator {
    width: 1px;
    height: 18px;
    flex: 0 0 auto;
    margin: 0 4px;
    background: var(--border);
}

.notes-convert-btn {
    display: inline-flex;
    min-height: 29px;
    align-items: center;
    gap: 7px;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 10px;
    white-space: nowrap;
    cursor: pointer;
}

.notes-convert-btn:hover,
.notes-convert-btn[aria-expanded="true"] {
    border-color: var(--border);
    background: var(--surface-hover);
    color: var(--text);
}

.notes-convert-btn:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.notes-convert-btn i {
    font-size: 8px;
}

.notes-convert-wrap .notes-popover {
    top: calc(100% + 8px);
    right: 0;
}

.notes-editor {
    width: min(100%, 900px);
    min-height: 0;
    flex: 1;
    overflow: auto;
    align-self: center;
    padding: 32px clamp(22px, 6vw, 76px) 80px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.8;
    overflow-wrap: anywhere;
    outline: none;
}

.notes-editor:focus-visible {
    outline: none;
}

.notes-editor:empty::before {
    color: var(--text-muted);
    content: attr(data-placeholder);
    pointer-events: none;
}

.notes-editor h1,
.notes-editor h2,
.notes-editor h3 {
    margin: 1.25em 0 .45em;
    color: var(--text);
    line-height: 1.35;
}

.notes-editor h1 { font-size: 25px; }
.notes-editor h2 { font-size: 20px; }
.notes-editor h3 { font-size: 16px; }
.notes-editor p { margin: .45em 0; }
.notes-editor ul,
.notes-editor ol { padding-left: 1.5em; }
.notes-editor blockquote {
    margin: 1em 0;
    padding: 3px 0 3px 14px;
    border-left: 2px solid var(--gold);
    color: var(--text-secondary);
}
.notes-editor pre {
    overflow: auto;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-raised);
    color: var(--gold-light);
    font: 12px/1.65 "JetBrains Mono", monospace;
    white-space: pre-wrap;
}
.notes-editor code {
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--surface-raised);
    color: var(--gold-light);
    font: .9em "JetBrains Mono", monospace;
}
.notes-editor a { color: var(--gold-light); text-decoration: underline; }
.notes-editor hr { border: 0; border-top: 1px solid var(--border); }
.notes-editor input[type="checkbox"] { accent-color: var(--gold); }
.notes-editor ul[data-notes-checklist="true"] { padding-left: 0; list-style: none; }
.notes-editor ul[data-notes-checklist="true"] li { display: flex; align-items: baseline; gap: 8px; }

.notes-mobile-back {
    display: none;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-raised);
    color: var(--text-secondary);
    cursor: pointer;
}

.notes-link-dialog {
    width: min(420px, calc(100vw - 28px));
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #151619;
    color: var(--text);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.notes-link-dialog::backdrop {
    background: rgba(0, 0, 0, .66);
    backdrop-filter: blur(3px);
}

.notes-link-dialog form { display: grid; gap: 12px; }
.notes-link-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.notes-link-dialog-heading h2 { margin: 0; font-size: 16px; }
.notes-link-dialog label { color: var(--text-secondary); font-size: 11px; }
.notes-link-dialog input {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 12px;
}
.notes-link-dialog input:focus { border-color: var(--border-gold-strong); outline: none; }
.notes-link-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.notes-cancel-btn {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

@media (max-width: 720px) {
    .notes-topbar { gap: 9px; padding: 0 12px; }
    .notes-view.is-editing .notes-topbar { display: none; }
    .notes-topbar-brand { min-width: 78px; gap: 7px; }
    .notes-topbar-brand .topbar-btn { width: 30px; height: 30px; }
    .notes-global-search { width: auto; min-width: 0; flex: 1; }
    .notes-global-search kbd { display: none; }
    .notes-create-btn { width: 36px; min-width: 36px; padding: 0; }
    .notes-create-btn span { display: none; }
    .notes-layout { display: block; }
    .notes-sidebar { height: 100%; border-right: 0; }
    .notes-filter-nav { display: flex; overflow-x: auto; gap: 4px; padding: 10px 12px; }
    .notes-filter { min-height: 32px; flex: 0 0 auto; gap: 7px; padding: 0 9px; white-space: nowrap; }
    .notes-filter > small { display: none; }
    .notes-list-heading { padding: 12px 15px 6px; }
    .notes-list { padding: 0 10px 16px; }
    .notes-row-main { min-height: 76px; }
    .notes-editor-panel { display: none; height: 100%; }
    .notes-view.is-editing .notes-sidebar { display: none; }
    .notes-view.is-editing .notes-editor-panel { display: flex; }
    .notes-view.is-editing .notes-editor-empty { display: none; }
    .notes-mobile-back { display: inline-grid; }
    .notes-editor-header { min-height: 58px; gap: 7px; padding: 8px 12px; }
    .notes-title-input { font-size: 16px; }
    .notes-save-state { max-width: 75px; overflow: hidden; font-size: 9px; text-overflow: ellipsis; }
    .notes-editor-actions { gap: 2px; }
    .notes-ask-btn { width: 32px; justify-content: center; padding: 0; }
    .notes-ask-btn span,
    .notes-ask-btn > i:last-child { display: none; }
    .notes-format-toolbar { padding: 5px 10px; }
    .notes-editor { padding: 24px 18px 60px; font-size: 14px; }
    .notes-popover { position: fixed; top: auto; right: 12px; bottom: 12px; }
}

@media (max-width: 380px) {
    .notes-topbar-brand { min-width: 64px; }
    .notes-topbar-brand .notes-eyebrow { display: none; }
    .notes-title-input { font-size: 14px; }
    .notes-save-state { max-width: 50px; }
}

@media (prefers-reduced-motion: reduce) {
    .notes-view *,
    .notes-view *::before,
    .notes-view *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
