:root {
    --bg: #0b1020;
    --panel: #11182d;
    --panel-2: #16213d;
    --paper: #f8fafc;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #38bdf8;
    --accent-2: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at top left, #1e3a8a 0, #0b1020 32%, #050816 100%);
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
}

.app-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
}

.sidebar {
    background: rgba(17, 24, 45, 0.94);
    border-right: 1px solid var(--border);
    padding: 18px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 25px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.25);
}

.brand h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1;
    letter-spacing: -1px;
}

.brand span {
    color: var(--muted);
    font-size: 13px;
}

.search-box {
    margin-bottom: 14px;
}

.search-box input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: #0f172a;
    color: var(--text);
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
}

.btn {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #1e293b;
    color: var(--text);
    cursor: pointer;
    transition: 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    font-weight: 700;
}

.btn-success {
    background: rgba(34, 197, 94, 0.85);
    border: none;
    font-weight: 700;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.85);
    border: none;
    font-weight: 700;
}

.full {
    width: 100%;
}

.notes-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.note-card {
    display: block;
    text-decoration: none;
    color: var(--text);
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    transition: 0.15s ease;
}

.note-card:hover {
    background: rgba(30, 41, 59, 0.95);
    transform: translateY(-1px);
}

.note-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3);
}

.note-card strong {
    display: block;
    margin-bottom: 8px;
}

.note-card small {
    color: var(--muted);
    font-size: 11px;
}

.empty-sidebar {
    color: var(--muted);
    padding: 12px;
}

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

.topbar {
    background: rgba(15, 23, 42, 0.72);
    border-bottom: 1px solid var(--border);
    padding: 16px;
}

.title-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 14px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.topbar-actions form {
    margin: 0;
}

.paper {
    flex: 1;
    overflow: auto;
    padding: 32px;
}

.editor {
    max-width: 1050px;
    min-height: calc(100vh - 210px);
    margin: 0 auto;
    padding: 42px;
    background: var(--paper);
    color: #111827;
    border-radius: 24px;
    box-shadow: var(--shadow);
    outline: none;
    font-size: 18px;
    line-height: 1.7;
}

.editor h1,
.editor h2,
.editor h3 {
    line-height: 1.2;
}

.editor a {
    color: #2563eb;
}

.statusbar {
    padding: 10px 18px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.72);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.empty-editor {
    margin: auto;
    text-align: center;
    color: var(--muted);
}

.empty-editor h2 {
    color: var(--text);
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        max-height: 42vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .paper {
        padding: 16px;
    }

    .editor {
        padding: 24px;
        min-height: 60vh;
        border-radius: 18px;
    }

    .title-input {
        font-size: 22px;
    }

    .statusbar {
        flex-direction: column;
    }
}

/* ==================================================
   Menu próprio das notas
   ================================================== */

.context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 180px;
    padding: 8px;
    display: none;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
}

.context-menu.open {
    display: block;
}

.context-menu button {
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    background: transparent;
    color: #e5e7eb;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.context-menu button:hover {
    background: rgba(56, 189, 248, 0.14);
}

.context-menu .danger-item {
    color: #fecaca;
}

.context-menu .danger-item:hover {
    background: rgba(239, 68, 68, 0.18);
}

.context-divider {
    height: 1px;
    margin: 6px 4px;
    background: rgba(148, 163, 184, 0.18);
}

.context-label {
    padding: 6px 10px 8px;
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding: 0 6px 6px;
}

.context-menu .color-dot {
    width: 22px;
    height: 22px;
    min-width: 22px;
    padding: 0;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.28);
}

.context-menu .color-dot:hover {
    transform: scale(1.08);
    background: inherit;
}

.color-default {
    background: #1e293b !important;
}

.color-blue {
    background: #2563eb !important;
}

.color-green {
    background: #16a34a !important;
}

.color-yellow {
    background: #ca8a04 !important;
}

.color-red {
    background: #dc2626 !important;
}

.color-purple {
    background: #9333ea !important;
}

.color-gray {
    background: #64748b !important;
}

/* ==================================================
   Cores visuais dos cards de notas
   ================================================== */

.note-card {
    position: relative;
    overflow: hidden;
}

.note-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: rgba(56, 189, 248, 0.55);
}

.note-color-default::before {
    background: rgba(56, 189, 248, 0.55);
}

.note-color-blue::before {
    background: #2563eb;
}

.note-color-green::before {
    background: #16a34a;
}

.note-color-yellow::before {
    background: #ca8a04;
}

.note-color-red::before {
    background: #dc2626;
}

.note-color-purple::before {
    background: #9333ea;
}

.note-color-gray::before {
    background: #64748b;
}

.note-color-blue {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.22), rgba(15, 23, 42, 0.72));
}

.note-color-green {
    background: linear-gradient(90deg, rgba(22, 163, 74, 0.22), rgba(15, 23, 42, 0.72));
}

.note-color-yellow {
    background: linear-gradient(90deg, rgba(202, 138, 4, 0.22), rgba(15, 23, 42, 0.72));
}

.note-color-red {
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.22), rgba(15, 23, 42, 0.72));
}

.note-color-purple {
    background: linear-gradient(90deg, rgba(147, 51, 234, 0.22), rgba(15, 23, 42, 0.72));
}

.note-color-gray {
    background: linear-gradient(90deg, rgba(100, 116, 139, 0.25), rgba(15, 23, 42, 0.72));
}

/* ==================================================
   Título automático da nota
   ================================================== */

.note-title-preview {
    width: 100%;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-title-preview span {
    color: #94a3b8;
    font-size: 13px;
}

.note-title-preview strong {
    color: #f8fafc;
    font-size: 18px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
