/* ============================================================
   O Bloquinho – design system
   Referências: miaumente.vercel.app (estrutura, vidro, raios) e
   agenciarollin.com (acento ciano/roxo). Tema escuro é o padrão;
   [data-theme="light"] troca os tokens.
   ============================================================ */

@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/Manrope-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/Manrope-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
    --font: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, Consolas, 'Cascadia Mono', monospace;

    --bg: #090a0f;
    --bg-glow: radial-gradient(circle at 20% -10%, rgba(1, 250, 213, 0.08), transparent 40%),
               radial-gradient(circle at 90% 0%, rgba(138, 43, 214, 0.12), transparent 38%);
    --panel: #121521;
    --panel-2: #171b28;
    --panel-hover: #1b2030;
    --sidebar: #0f1118;

    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);

    --text: #f4f7fb;
    --text-2: #a4aaba;
    --text-3: #7f8799;

    --accent: #01fad5;
    --accent-ink: #062621;
    --accent-soft: rgba(1, 250, 213, 0.14);
    --accent-2: #8a2bd6;
    --accent-2-soft: rgba(138, 43, 214, 0.18);
    --danger: #ff5c7a;
    --danger-soft: rgba(255, 92, 122, 0.14);
    --warn: #ffd60a;
    --ok: #34c759;

    --btn-primary-bg: linear-gradient(135deg, #f3f6fb, #d8e1f4);
    --btn-primary-text: #090a0f;
    --btn-primary-glow: 0 12px 26px rgba(0, 0, 0, 0.28), 0 6px 18px rgba(1, 250, 213, 0.16);

    --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 18px 40px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 30px 60px rgba(0, 0, 0, 0.38);
    --inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.04);

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 999px;

    --sidebar-w: 264px;
    --sidebar-w-min: 76px;
    --content-max: 1120px;

    --t-fast: 0.14s ease;
    --t: 0.22s cubic-bezier(0.4, 0, 0.2, 1);

    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f4f3f8;
    --bg-glow: radial-gradient(circle at 20% -10%, rgba(11, 184, 159, 0.12), transparent 40%),
               radial-gradient(circle at 90% 0%, rgba(106, 26, 176, 0.10), transparent 38%);
    --panel: #ffffff;
    --panel-2: #f1f0f6;
    --panel-hover: #e9e7f1;
    --sidebar: #fbfbfd;

    --border: rgba(11, 9, 19, 0.08);
    --border-strong: rgba(11, 9, 19, 0.16);

    --text: #0b0913;
    --text-2: #5b5870;
    --text-3: #8a879c;

    --accent: #0bb89f;
    --accent-ink: #ffffff;
    --accent-soft: rgba(11, 184, 159, 0.14);
    --accent-2: #6a1ab0;
    --accent-2-soft: rgba(106, 26, 176, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --warn: #b45309;
    --ok: #17794f;

    --btn-primary-bg: linear-gradient(135deg, #1a1626, #0b0913);
    --btn-primary-text: #ffffff;
    --btn-primary-glow: 0 10px 22px rgba(11, 9, 19, 0.22);

    --shadow-sm: 0 4px 12px rgba(11, 9, 19, 0.06);
    --shadow-md: 0 14px 32px rgba(11, 9, 19, 0.10);
    --shadow-lg: 0 24px 48px rgba(11, 9, 19, 0.14);
    --inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.6);

    color-scheme: light;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    background-color: var(--bg);
    background-image: var(--bg-glow);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

svg { display: block; }
[data-icon] > svg, .nav-icon > svg { width: 1.15em; height: 1.15em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); background-clip: padding-box; }

/* ---------- Layout ---------- */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page {
    flex: 1;
    overflow-y: auto;
    padding: 0 32px 48px;
}

.page > .view {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 22px;
    animation: fadeUp 0.28s ease-out;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 14px 12px;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--t);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 14px;
    position: relative;
}

.brand-mark {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 18px;
    color: var(--accent-ink);
    background: linear-gradient(135deg, var(--accent), #6ee7d8);
    box-shadow: 0 8px 18px rgba(1, 250, 213, 0.22);
}
:root[data-theme="light"] .brand-mark { box-shadow: 0 8px 18px rgba(11, 184, 159, 0.28); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.brand-text span { font-size: 11px; color: var(--text-3); }

.sidebar-toggle {
    margin-left: auto;
    color: var(--text-3);
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    color: var(--text-2);
    font-weight: 600;
    font-size: 14px;
    text-align: left;
    white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}

.nav-btn:hover { background: var(--panel-hover); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--text); }
.nav-btn.active .nav-icon { color: var(--accent); }
.nav-icon { flex-shrink: 0; width: 22px; display: grid; place-items: center; color: var(--text-3); }
.nav-text { overflow: hidden; text-overflow: ellipsis; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-3); background: var(--panel-2); padding: 2px 8px; border-radius: var(--r-pill); }
.nav-btn.active .nav-count { background: rgba(0, 0, 0, 0.2); color: var(--text); }
:root[data-theme="light"] .nav-btn.active .nav-count { background: rgba(255, 255, 255, 0.7); }

.side-section { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.side-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    white-space: nowrap;
}
.side-empty { padding: 4px 10px; font-size: 12px; color: var(--text-3); }

.side-footer {
    margin-top: auto;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: -14px;
    padding-bottom: 14px;
    background: var(--sidebar);
    z-index: 1;
}

.theme-switch {
    display: flex;
    background: var(--panel-2);
    border-radius: var(--r-pill);
    padding: 3px;
    gap: 2px;
}
.theme-btn {
    flex: 1;
    min-height: 30px;
    display: grid;
    place-items: center;
    border-radius: var(--r-pill);
    color: var(--text-3);
    transition: background var(--t-fast), color var(--t-fast);
}
.theme-btn:hover { color: var(--text); }
.theme-btn.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }

.api-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
}
.api-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.api-pill.on .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.18); }
.api-pill.err .dot { background: var(--danger); }
.api-pill.net .dot { background: var(--warn); }

/* Sidebar recolhida */
.sidebar.collapsed { width: var(--sidebar-w-min); padding-left: 10px; padding-right: 10px; }
.sidebar.collapsed .brand { justify-content: center; padding-bottom: 10px; flex-wrap: wrap; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-count,
.sidebar.collapsed .side-heading span,
.sidebar.collapsed .side-heading .icon-btn { display: none; }
.sidebar.collapsed .sidebar-toggle { margin: 0; }
.sidebar.collapsed .nav-btn { justify-content: center; padding: 8px; }
.sidebar.collapsed .side-heading { justify-content: center; padding: 6px 0 4px; }
.sidebar.collapsed .side-heading::before { content: ''; width: 24px; height: 1px; background: var(--border-strong); }
.sidebar.collapsed .theme-switch { flex-direction: column; border-radius: var(--r-md); }
.sidebar.collapsed .api-pill { justify-content: center; padding: 6px 0; }
.sidebar.collapsed .side-empty { display: none; }

/* Tooltip quando recolhida */
.sidebar.collapsed .nav-btn[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: 12px;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    z-index: 60;
    pointer-events: none;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 32px 18px;
    flex-wrap: wrap;
}

.header-title h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.header-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; min-height: 1.2em; }

.header-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search-bar input {
    width: 240px;
    min-height: 40px;
    padding: 8px 38px 8px 38px;
    border-radius: var(--r-pill);
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), width var(--t);
}
.search-bar input::placeholder { color: var(--text-3); }
.search-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); width: 300px; }
.search-bar input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 6px; }

.segmented {
    display: flex;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 3px;
}
.seg-btn {
    min-width: 34px;
    min-height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--r-pill);
    color: var(--text-3);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); }
.seg-btn.text { padding: 0 14px; font-weight: 700; font-size: 13px; }
.remote-ok { color: var(--ok); font-weight: 700; }
.remote-err { color: var(--danger); font-weight: 700; }

.select, .input {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--r-md);
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.select:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { padding-right: 32px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--panel); color: var(--text); }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: var(--r-md);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.01em;
    border: 1px solid transparent;
    transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
    white-space: nowrap;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); box-shadow: var(--btn-primary-glow); }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.04); }

.btn-ghost { background: var(--panel); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-hover); border-color: var(--border-strong); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-lg { min-height: 50px; padding: 10px 22px; font-size: 15px; border-radius: 16px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    min-width: 36px;
    min-height: 36px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); }
.icon-btn.small { min-width: 30px; min-height: 30px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.accent:hover, .icon-btn.is-on { color: var(--accent); }
.icon-btn.accent:hover { background: var(--accent-soft); }

/* ---------- Dashboard ---------- */
.hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 32px;
    border-radius: var(--r-xl);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
        var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md), var(--inset-hi);
    position: relative;
    overflow: hidden;
}
.hero-card::before {
    content: '';
    position: absolute;
    inset: -40% auto auto -10%;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-2-soft), transparent 70%);
    pointer-events: none;
}
.hero-title { font-size: 34px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.hero-sub { color: var(--text-2); margin-top: 6px; font-size: 15px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; position: relative; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat {
    padding: 16px 18px;
    border-radius: var(--r-lg);
    background: var(--panel);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat.accent .stat-value { color: var(--accent); }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.panel {
    padding: 20px;
    border-radius: var(--r-lg);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--inset-hi);
}
.panel-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; color: var(--text-2); margin-bottom: 12px; }
.panel-title [data-icon] { color: var(--accent); }

.quick-list { display: flex; flex-direction: column; gap: 6px; }
.quick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: var(--panel-2);
    border: 1px solid transparent;
    color: var(--text);
    text-align: left;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.quick-item:hover { border-color: var(--border-strong); background: var(--panel-hover); }
.quick-item .q-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.quick-item .q-meta { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.quick-item [data-icon] { color: var(--text-3); flex-shrink: 0; }

/* ---------- Editor ---------- */
.editor-card {
    border-radius: var(--r-xl);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md), var(--inset-hi);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color var(--t), box-shadow var(--t);
}
.editor-card:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow-lg), 0 0 0 3px var(--accent-soft); }
.editor-card.editing { border-color: var(--accent-2); }

.editor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-label { font-size: 13px; color: var(--text-3); font-weight: 600; }
.chip-select { min-height: 32px; padding: 4px 30px 4px 12px; border-radius: var(--r-pill); font-weight: 700; font-size: 13px; background-color: var(--panel-2); }
.editor-status { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 600; }
.editor-status.saving { color: var(--warn); }
.editor-status.ok { color: var(--ok); }
.editor-status.err { color: var(--danger); }
.editor-status.dirty { color: var(--accent-2); }

.editor-title {
    background: transparent;
    border: none;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.03em;
    width: 100%;
    padding: 4px 0;
}
.editor-title:focus { outline: none; }
.editor-title::placeholder, .editor-body::placeholder { color: var(--text-3); font-weight: 500; }

.editor-body {
    background: transparent;
    border: none;
    font-size: 15.5px;
    line-height: 1.65;
    width: 100%;
    resize: vertical;
    min-height: 130px;
    padding: 0;
}
.editor-body:focus { outline: none; }
.editor-meta { font-size: 11.5px; color: var(--text-3); text-align: right; }

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-group label.btn { cursor: pointer; }

.recording-status { display: none; align-items: center; gap: 6px; color: var(--danger); font-size: 13px; font-weight: 700; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.recording .recording-status { display: inline-flex; }
.recording #btn-record { background: var(--danger); color: #fff; border-color: transparent; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.media-preview { display: flex; flex-wrap: wrap; gap: 12px; }
.media-preview:empty { display: none; }
.media-preview img { max-width: 100%; max-height: 260px; border-radius: var(--r-md); border: 1px solid var(--border); object-fit: cover; }
.media-preview audio { width: 320px; max-width: 100%; height: 40px; }
.media-thumb { position: relative; }

/* ---------- Lista de notas ---------- */
.list-head { display: flex; align-items: baseline; gap: 10px; }
.list-head h3 { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.list-count { font-size: 13px; color: var(--text-3); font-weight: 600; }

.entries-list { display: grid; grid-template-columns: 1fr; gap: 14px; }
.entries-list.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .entries-list.grid { grid-template-columns: 1fr; } }

.entry-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--inset-hi);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    animation: fadeUp 0.25s ease-out;
    min-width: 0;
}
.entry-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm), var(--inset-hi); }
.entry-card.pinned { border-color: var(--accent-2); }
.entry-card.pinned::before { content: ''; }

.entry-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.entry-heading { min-width: 0; }
.entry-title { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.entry-title .pin-mark { color: var(--accent-2); flex-shrink: 0; }
.entry-meta { font-size: 12px; color: var(--text-3); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.entry-meta .cat-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--panel-2); color: var(--text-2); font-weight: 700; }
.entry-meta .api-chip { color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.entry-meta svg { display: inline-block; }

.entry-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0.55; transition: opacity var(--t-fast); }
.entry-card:hover .entry-actions, .entry-card:focus-within .entry-actions { opacity: 1; }

.entry-body { font-size: 15px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.entry-body p { min-height: 0.5em; }
.entry-body p + p { margin-top: 2px; }
.entry-body ul { padding-left: 22px; margin: 4px 0; }
.entry-body li { margin: 2px 0; }
.entry-body .check { list-style: none; margin-left: -22px; display: flex; gap: 8px; align-items: baseline; }
.entry-body .check.done { color: var(--text-2); }
.entry-body .check .box { color: var(--ok); flex-shrink: 0; }
.entry-body .check:not(.done) .box { color: var(--text-3); }
.entry-body code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }
.entry-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.entry-body a:hover { border-bottom-color: var(--accent); }
.entry-body.clamped { max-height: 9.6em; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent); mask-image: linear-gradient(180deg, #000 70%, transparent); }
.expand-btn { align-self: flex-start; font-size: 13px; font-weight: 700; color: var(--accent); padding: 2px 0; }
mark { background: var(--warn); color: #0b0913; border-radius: 3px; padding: 0 2px; }

.entry-media { display: flex; flex-direction: column; gap: 10px; }
.entry-media img { max-width: 100%; max-height: 360px; border-radius: var(--r-md); object-fit: contain; background: var(--panel-2); border: 1px solid var(--border); }
.entry-media audio { width: 100%; height: 40px; }
.entry-files { display: flex; flex-wrap: wrap; gap: 8px; }

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: var(--r-md);
    position: relative;
    max-width: 280px;
    min-width: 0;
}
.file-preview-icon { font-size: 22px; line-height: 1; }
.file-preview-info { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); text-decoration: none; }
.file-size { font-size: 11px; color: var(--text-3); }

.remove-file-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--danger);
    color: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-fast);
}
.remove-file-btn:hover { transform: scale(1.08); }
.remove-file-btn.inline { position: static; margin-left: 8px; }

/* Estado vazio */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    border-radius: var(--r-xl);
    border: 1px dashed var(--border-strong);
    color: var(--text-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.empty-state .empty-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.empty-state .empty-icon svg { width: 26px; height: 26px; }
.empty-state h4 { font-size: 17px; font-weight: 800; color: var(--text); }
.empty-state p { font-size: 14px; max-width: 380px; }
.empty-state kbd { font-family: var(--mono); background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; font-size: 12px; }

/* ---------- Menu ⋯ ---------- */
.menu {
    position: fixed;
    z-index: 90;
    min-width: 200px;
    background: var(--panel-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: flex;
    flex-direction: column;
    animation: fadeUp 0.14s ease-out;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    width: 100%;
}
.menu-item:hover { background: var(--panel-hover); }
.menu-item [data-icon] { color: var(--text-3); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger [data-icon] { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ---------- Modais ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(5, 6, 10, 0.62);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.16s ease-out;
}
:root[data-theme="light"] .modal { background: rgba(11, 9, 19, 0.35); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    padding: 24px 26px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeUp 0.2s ease-out;
}
.modal-sm { max-width: 440px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.dialog-title { font-size: 18px; font-weight: 800; }
.help { color: var(--text-2); font-size: 14px; }
.sep { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: 40px; }
.row .label { min-width: 150px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.row .value { flex: 1; font-size: 14px; min-width: 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.mono { font-family: var(--mono); font-size: 13px; }
code.mono, .token-row code {
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: var(--r-sm);
    word-break: break-all;
}
.token-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-block {
    font-family: var(--mono);
    font-size: 12.5px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-2);
    display: block;
}
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .actions-grid { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: var(--r-md); }
.tab { flex: 1; min-height: 34px; border-radius: var(--r-sm); font-weight: 700; color: var(--text-3); font-size: 14px; }
.tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: flex; flex-direction: column; gap: 10px; }

.switch { position: relative; width: 44px; height: 26px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--panel-hover); border: 1px solid var(--border-strong); transition: background var(--t-fast); cursor: pointer; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-3); transition: transform var(--t-fast), background var(--t-fast); }
.switch input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Categorias */
.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); background: var(--panel-2); }
.cat-row .cat-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--panel); color: var(--accent); flex-shrink: 0; }
.cat-row .cat-name { flex: 1; min-width: 0; font-weight: 700; }
.cat-row .cat-name input { width: 100%; }
.cat-row .cat-count { font-size: 12px; color: var(--text-3); }
.cat-add { display: flex; flex-direction: column; gap: 10px; }
.cat-add-row { display: flex; gap: 8px; }
.cat-add-row .input { flex: 1; }
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-opt { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); color: var(--text-2); border: 1px solid transparent; }
.icon-opt:hover { color: var(--text); border-color: var(--border-strong); }
.icon-opt.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--panel-2);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 600;
    animation: slideIn 0.22s ease-out;
}
.toast.leaving { animation: slideOut 0.2s ease-in forwards; }
.toast [data-icon] { flex-shrink: 0; color: var(--accent); }
.toast.error [data-icon] { color: var(--danger); }
.toast.warn [data-icon] { color: var(--warn); }
.toast .toast-text { flex: 1; min-width: 0; }
.toast .toast-action { color: var(--accent); font-weight: 800; padding: 4px 8px; border-radius: 8px; }
.toast .toast-action:hover { background: var(--accent-soft); }
@keyframes slideIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
    .page { padding: 0 18px 32px; }
    .app-header { padding: 18px 18px 12px; }
    .search-bar input, .search-bar input:focus { width: 200px; }
    .hero-title { font-size: 28px; }
}

/* ---------- Telas estreitas (versão web no celular): barra lateral vira gaveta ---------- */
.mobile-menu, .sidebar-backdrop { display: none; }
@media (max-width: 720px) {
    .mobile-menu { display: inline-grid; }
    .header-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .header-title h1 { font-size: 20px; }
    .header-sub { display: none; }
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
        width: min(84vw, 300px); padding: 14px 12px;
        transform: translateX(-100%);
        transition: transform var(--t);
        border-right: 1px solid var(--border-strong);
    }
    .sidebar.mobile-open { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-toggle { display: none; }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
    .sidebar-backdrop[hidden] { display: none !important; }
    .app-header { padding: 12px 14px 10px; gap: 10px; }
    .header-tools { width: 100%; }
    .search-bar { flex: 1 1 100%; }
    .search-bar input, .search-bar input:focus { width: 100%; }
    .header-tools .select { flex: 1; min-width: 0; }
    #btn-new-note { flex: 1; justify-content: center; }
    .page { padding: 0 12px 28px; }
    .hero-card { padding: 22px 18px; }
    .hero-title { font-size: 24px; }
    .hero-actions { width: 100%; }
    .hero-actions .btn { flex: 1; justify-content: center; }
    .editor-card { padding: 14px; border-radius: var(--r-lg); }
    .editor-title { font-size: 20px; }
    .editor-toolbar .btn-text { display: none; }
    .modal { padding: 10px; align-items: flex-end; }
    .modal-card { padding: 18px 16px; border-radius: var(--r-lg); max-height: 92vh; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
