:root {
    --bg-main: #121212;
    --bg-sidebar: #181818;
    --bg-card: #1E1E1E;
    --bg-card-hover: #262626;
    --bg-card-active: #282415;
    --border-color: #2D2D2D;
    --border-active: #FBC02D;
    --accent-yellow: #FBC02D;
    --accent-yellow-hover: #FDD835;
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --text-muted: #666666;
    --danger: #EF5350;
    --success: #4CAF50;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-stack);
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Left Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-icon {
    width: 28px;
    height: 28px;
    background: var(--accent-yellow);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #000;
    font-size: 16px;
}

.app-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.e2ee-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
    background: #222222;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid #333333;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #757575;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.sidebar-actions {
    padding: 0 16px 12px;
}

.btn-new-note {
    width: 100%;
    background: var(--accent-yellow);
    color: #121212;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-new-note:hover {
    background: var(--accent-yellow-hover);
}

.category-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.nav-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    padding: 8px 10px 4px;
    letter-spacing: 0.5px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
}

.category-item:hover {
    background: #222222;
    color: var(--text-primary);
}

.category-item.active {
    background: #282415;
    color: var(--accent-yellow);
    font-weight: 600;
}

.category-count {
    font-size: 11px;
    color: var(--text-muted);
    background: #242424;
    padding: 2px 6px;
    border-radius: 10px;
}

.btn-add-category {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    border-radius: 6px;
    transition: color 0.15s;
}

.btn-add-category:hover {
    color: var(--accent-yellow);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Middle Column: Note List */
.note-list-panel {
    width: 340px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    flex-shrink: 0;
}

.note-list-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-bar-wrap {
    display: flex;
    align-items: center;
    background: #1F1F1F;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    height: 38px;
}

.search-bar-wrap svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13.5px;
    width: 100%;
    margin-left: 8px;
}

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

.list-subheader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.notes-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-notes-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* Note Card */
.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.note-card:hover {
    background: var(--bg-card-hover);
    border-color: #3C3C3C;
}

.note-card.active {
    background: var(--bg-card-active);
    border-color: var(--border-active);
}

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.note-card-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.pin-icon {
    color: var(--accent-yellow);
    flex-shrink: 0;
}

.note-card-preview {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    user-select: none;
}

.note-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-category-pill {
    background: #2A2A2A;
    color: #BDBDBD;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10.5px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Right Column: Editor Panel */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    overflow: hidden;
}

.editor-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 12px;
}

.editor-empty-state svg {
    color: #333;
}

.editor-empty-state p {
    font-size: 14px;
}

.editor-active-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-top-toolbar {
    height: 56px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.category-select {
    background: #1F1F1F;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    outline: none;
    cursor: pointer;
}

.note-datetime-badge {
    font-size: 12px;
    color: var(--text-muted);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.save-status-text {
    font-size: 11.5px;
    color: var(--text-muted);
    transition: opacity 0.2s;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: #252525;
    color: var(--text-primary);
}

.icon-btn.active {
    color: var(--accent-yellow);
}

.icon-btn.danger:hover {
    color: var(--danger);
    background: rgba(239, 83, 80, 0.15);
}

.editor-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 32px;
    overflow-y: auto;
}

.editor-title-input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    width: 100%;
    margin-bottom: 16px;
    font-family: inherit;
}

.editor-title-input::placeholder {
    color: #444;
}

.editor-body-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    line-height: 1.6;
    color: #D6D6D6;
    font-family: inherit;
    width: 100%;
    height: 100%;
}

.editor-body-textarea::placeholder {
    color: #444;
}

/* Modal Dialog for Pairing / Fallback */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: #1E1E1E;
    border: 1px solid #333333;
    border-radius: 12px;
    padding: 28px;
    width: 420px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.modal-input {
    background: #141414;
    border: 1px solid #333333;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13.5px;
    color: var(--text-primary);
    outline: none;
}

.modal-input:focus {
    border-color: var(--accent-yellow);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.btn-secondary {
    background: #2B2B2B;
    color: var(--text-primary);
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent-yellow);
    color: #121212;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #2C2C2C;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444444;
}
