:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e4e8ef;
  --text: #172033;
  --muted: #6d7788;
  --navy: #0b1220;
  --blue: #3366ff;
  --blue-dark: #2854dc;
  --violet: #7157e8;
  --green: #1e9b6c;
  --amber: #d38b19;
  --danger: #cc4554;
  --shadow: 0 20px 50px rgba(25, 37, 58, .10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c111b;
  --surface: #131a27;
  --surface-2: #192231;
  --line: #253044;
  --text: #edf2f8;
  --muted: #9ba7b9;
  --navy: #070b12;
  --shadow: 0 22px 55px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.brand { display: flex; align-items: center; gap: 11px; font-size: 17px; }
.brand > span:last-child { display: flex; line-height: 1; }
.brand small { margin-left: 4px; color: #8d98aa; font-weight: 500; }
.brand-mark, .unlock-mark {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 11px;
  background: linear-gradient(145deg, #4476ff, #244dd5);
  color: #fff;
  font-weight: 850;
  box-shadow: 0 9px 22px rgba(51, 102, 255, .28);
}
.brand-mark.large { width: 50px; height: 50px; border-radius: 15px; font-size: 22px; }

.primary-action, .secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.primary-action { background: var(--blue); color: #fff; box-shadow: 0 9px 18px rgba(51, 102, 255, .20); }
.primary-action:hover { background: var(--blue-dark); transform: translateY(-1px); }
.primary-action:disabled { opacity: .64; cursor: wait; transform: none; }
.secondary-action { border: 1px solid var(--line); background: var(--surface-2); }
.wide { width: 100%; }
.centered { text-align: center; }

/* Authentication */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr);
  background: var(--surface);
}
.auth-visual {
  position: relative;
  display: grid;
  align-items: center;
  overflow: hidden;
  padding: 8vw;
  background:
    radial-gradient(circle at 12% 15%, rgba(73, 118, 255, .35), transparent 27%),
    radial-gradient(circle at 88% 82%, rgba(111, 74, 232, .24), transparent 33%),
    linear-gradient(145deg, #080d18, #111c31 70%, #0b1323);
  color: white;
}
.auth-visual::before, .auth-visual::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
}
.auth-visual::before { width: 520px; height: 520px; right: -250px; top: -120px; }
.auth-visual::after { width: 720px; height: 720px; left: -420px; bottom: -520px; }
.visual-copy { position: relative; z-index: 1; max-width: 560px; }
.visual-copy .eyebrow { margin-top: 32px; color: #88a7ff; }
.visual-copy h1 { margin: 0; font-size: clamp(42px, 5vw, 72px); line-height: 1.02; letter-spacing: -.045em; }
.visual-copy h1 em { color: #7394ff; font-style: normal; }
.visual-copy > p:not(.eyebrow) { max-width: 480px; color: #b8c2d5; font-size: 17px; line-height: 1.7; }
.visual-security { display: flex; gap: 14px; align-items: center; margin-top: 45px; padding: 16px 18px; border: 1px solid rgba(255, 255, 255, .11); border-radius: 15px; background: rgba(255, 255, 255, .045); }
.visual-security > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: rgba(92, 128, 255, .18); color: #8ca7ff; }
.visual-security div { display: flex; flex-direction: column; gap: 5px; }
.visual-security small { color: #9eabbe; }

.auth-form-wrap { display: flex; flex-direction: column; justify-content: center; padding: 9vw; background: var(--surface); }
.auth-form { width: min(100%, 410px); margin: auto; }
.auth-form h2 { margin: 0 0 8px; font-size: 33px; letter-spacing: -.035em; }
.auth-form > p:not(.eyebrow) { margin: 0 0 32px; color: var(--muted); line-height: 1.65; }
.auth-form-wrap footer { margin: 40px auto 0; color: var(--muted); font-size: 12px; }
.auth-card { align-self: center; grid-column: 1 / -1; width: min(92vw, 520px); margin: auto; padding: 45px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 12px; }
.auth-card p { color: var(--muted); line-height: 1.7; }
.auth-card code { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--blue); }
.auth-card .primary-action { margin-top: 24px; }

label { display: flex; flex-direction: column; gap: 8px; margin: 0 0 19px; color: var(--text); font-size: 13px; font-weight: 650; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border .16s ease, box-shadow .16s ease;
}
input, select { height: 46px; padding: 0 14px; }
textarea { min-height: 140px; padding: 13px 14px; resize: vertical; line-height: 1.65; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51, 102, 255, .11); }
.otp-input { height: 58px; text-align: center; font-size: 25px; font-weight: 760; letter-spacing: .22em; }
.back-link { margin: 0 0 30px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.form-error { margin: -4px 0 16px; padding: 11px 13px; border: 1px solid rgba(204, 69, 84, .25); border-radius: 9px; background: rgba(204, 69, 84, .08); color: var(--danger); font-size: 13px; }
.trust-device { flex-direction: row; align-items: center; gap: 10px; margin-top: -2px; color: var(--muted); font-size: 12px; font-weight: 550; }
.trust-device input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }

/* Setup */
.setup-page { min-height: 100vh; display: grid; place-items: center; padding: 42px 20px; background: radial-gradient(circle at 50% -20%, rgba(51,102,255,.12), transparent 40%), var(--bg); }
.setup-card { width: min(100%, 720px); padding: 42px 50px 50px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.setup-card h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: -.035em; }
.setup-card form > p:not(.eyebrow), .recovery-panel > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.setup-progress { display: flex; align-items: center; justify-content: center; margin-bottom: 38px; }
.setup-progress span { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 750; }
.setup-progress span.active { border-color: var(--blue); background: var(--blue); color: #fff; }
.setup-progress i { width: 70px; height: 1px; background: var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid label:first-child { grid-column: 1 / -1; }
.security-callout { display: flex; gap: 12px; margin: 2px 0 20px; padding: 14px; border-radius: 11px; background: rgba(211,139,25,.10); color: #92600d; }
.security-callout span { flex: 0 0 auto; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #d99a35; color: #fff; font-weight: 850; }
.security-callout p { margin: 1px 0 0; line-height: 1.5; font-size: 12px; }
.secret-box { margin: 25px 0; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.secret-box label { margin: 0 0 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.secret-box code { display: block; margin: 0 0 15px; overflow-wrap: anywhere; font-size: 16px; font-weight: 750; letter-spacing: .05em; }
.secret-box button { padding: 0; border: 0; background: transparent; color: var(--blue); font-weight: 700; cursor: pointer; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 22px 0; }
.recovery-grid code { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); text-align: center; font-size: 14px; }
.recovery-panel .secondary-action { margin-bottom: 10px; }

/* Application */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 245px; display: flex; flex-direction: column; padding: 25px 17px 17px; border-right: 1px solid #1b2638; background: var(--navy); color: #dfe6f0; }
.sidebar .brand { padding: 0 9px 24px; color: white; }
.sidebar .brand small { color: #738096; }
.sidebar .primary-action, .vault-action { width: 100%; margin-bottom: 9px; }
.vault-action { min-height: 40px; border: 1px solid #2c3950; border-radius: 11px; background: #151f30; color: #c9d3e1; font-weight: 700; cursor: pointer; }
.vault-action:hover { background: #1b2940; }
.nav-list { display: flex; flex-direction: column; gap: 3px; margin-top: 17px; }
.nav-item { display: grid; grid-template-columns: 23px 1fr auto; align-items: center; width: 100%; min-height: 41px; padding: 0 11px; border: 0; border-radius: 10px; background: transparent; color: #8f9bad; text-align: left; cursor: pointer; }
.nav-item:hover { color: #e3e9f2; background: #121c2b; }
.nav-item.active { color: white; background: #18243a; }
.nav-item > span { color: #7d8ba1; font-size: 17px; }
.nav-item.active > span { color: #7ea0ff; }
.nav-item b { min-width: 20px; padding: 2px 6px; border-radius: 10px; background: #202d43; color: #8895a8; font-size: 10px; text-align: center; }
.sidebar-foot { margin-top: auto; }
.security-pill { display: flex; align-items: center; gap: 10px; margin: 10px 7px 12px; padding: 11px; border: 1px solid rgba(57, 192, 138, .15); border-radius: 11px; background: rgba(31, 155, 108, .08); }
.security-pill i, .sync-state i { width: 7px; height: 7px; border-radius: 50%; background: #37c28a; box-shadow: 0 0 0 4px rgba(55, 194, 138, .10); }
.security-pill span { display: flex; flex-direction: column; gap: 3px; color: #b9c8d5; font-size: 11px; font-weight: 700; }
.security-pill small { color: #6f7f93; font-size: 9px; font-weight: 500; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-top: 9px; padding: 13px 9px 4px; border-top: 1px solid #1c283b; }
.user-chip > span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: #28498d; color: white; font-size: 12px; font-weight: 800; }
.user-chip div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.user-chip strong { color: #dde4ee; font-size: 11px; }
.user-chip small { overflow: hidden; color: #69788d; font-size: 9px; text-overflow: ellipsis; }

.workspace { position: relative; grid-column: 2; min-width: 0; min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; height: 70px; display: flex; align-items: center; gap: 16px; padding: 0 34px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); }
.search-box { flex: 1; max-width: 620px; position: relative; margin: 0; }
.search-box span { position: absolute; left: 15px; top: 50%; color: var(--muted); font-size: 20px; transform: translateY(-53%); }
.search-box input { height: 42px; padding-left: 42px; border-color: transparent; background: var(--surface-2); }
.top-actions { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.sync-state { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; font-weight: 650; }
.sync-state.working i { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.icon-button:hover { background: var(--surface-2); }

.note-tabs {
  position: sticky;
  z-index: 19;
  top: 70px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-height: 48px;
  padding: 7px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  scrollbar-width: thin;
  backdrop-filter: blur(14px);
}
.note-tab { flex: 0 0 auto; display: flex; align-items: center; max-width: 230px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.note-tab.active { border-color: color-mix(in srgb, var(--blue) 44%, var(--line)); background: rgba(51,102,255,.08); color: var(--text); box-shadow: 0 4px 12px rgba(51,102,255,.08); }
.note-tab-open, .note-tab-close { height: 32px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.note-tab-open { max-width: 185px; overflow: hidden; padding: 0 8px 0 11px; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.note-tab-close { width: 30px; padding: 0; border-left: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: 0 9px 9px 0; font-size: 17px; }
.note-tab-close:hover { background: rgba(204,69,84,.09); color: var(--danger); }

.dashboard { max-width: 1440px; margin: 0 auto; padding: 42px 44px 70px; }
.dashboard-head { display: flex; justify-content: space-between; gap: 25px; align-items: flex-start; }
.dashboard-head h1 { margin: 0 0 8px; font-size: 31px; letter-spacing: -.035em; }
.dashboard-head p:last-child { margin: 0; color: var(--muted); }
.date-chip { padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 11px; text-transform: capitalize; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 185px)); gap: 12px; margin: 28px 0 38px; }
.stat-card { display: flex; align-items: center; gap: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.stat-card div { display: flex; flex-direction: column; }
.stat-card strong { font-size: 18px; }
.stat-card small { color: var(--muted); font-size: 10px; }
.stat-icon { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; }
.stat-icon.blue { background: rgba(51,102,255,.10); color: var(--blue); }
.stat-icon.violet { background: rgba(113,87,232,.10); color: var(--violet); }
.stat-icon.amber { background: rgba(211,139,25,.10); color: var(--amber); }
.content-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.content-head > div:first-child { display: flex; align-items: baseline; gap: 10px; }
.content-head h2 { margin: 0; font-size: 17px; }
.content-head span { color: var(--muted); font-size: 10px; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.view-switch button { width: 31px; height: 27px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.view-switch button.active { background: var(--surface-2); color: var(--blue); }

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 14px; }
.note-card { position: relative; min-height: 206px; display: flex; flex-direction: column; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 1px 1px rgba(0,0,0,.015); cursor: pointer; transition: transform .16s ease, border .16s ease, box-shadow .16s ease; }
.note-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: #9ba4b2; opacity: .75; }
.note-card.color-blue::before { background: var(--blue); }
.note-card.color-green::before { background: var(--green); }
.note-card.color-amber::before { background: var(--amber); }
.note-card.color-violet::before { background: var(--violet); }
.note-card:hover, .note-card:focus { outline: none; border-color: color-mix(in srgb, var(--blue) 38%, var(--line)); box-shadow: 0 11px 28px rgba(32, 52, 90, .09); transform: translateY(-2px); }
.note-card-top { display: flex; justify-content: space-between; align-items: center; }
.type-badge { padding: 4px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 8px; font-weight: 850; letter-spacing: .1em; }
.type-badge.vault { background: rgba(113,87,232,.09); color: var(--violet); }
.favorite-mark { color: var(--amber); }
.note-card h3 { margin: 18px 0 8px; overflow: hidden; font-size: 15px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.note-card > p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.6; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.note-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 18px; color: var(--muted); font-size: 9px; }
.note-card footer span { color: var(--amber); }
.notes-grid.list-view { grid-template-columns: 1fr; }
.notes-grid.list-view .note-card { min-height: 110px; }
.notes-grid.list-view .note-card > p { -webkit-line-clamp: 1; }
.notes-grid.list-view .note-card footer { padding-top: 10px; }
.empty-state { display: grid; place-items: center; padding: 80px 20px; border: 1px dashed var(--line); border-radius: 17px; text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: rgba(51,102,255,.09); color: var(--blue); font-size: 22px; }
.empty-state h3 { margin: 16px 0 5px; }
.empty-state p { margin: 0 0 19px; color: var(--muted); }

/* Editor */
.editor-panel { min-height: calc(100vh - 70px); background: var(--surface); }
.editor-head { position: sticky; z-index: 10; top: 118px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 62px; padding: 0 34px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(16px); }
.editor-status { color: var(--muted); font-size: 10px; font-weight: 600; }
.editor-actions { display: flex; align-items: center; gap: 8px; }
.edit-button, .done-button { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 11px; font-weight: 750; cursor: pointer; }
.edit-button:hover { border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); background: rgba(51,102,255,.07); color: var(--blue); }
.done-button { border-color: var(--blue); background: var(--blue); color: #fff; }
.done-button:hover { background: var(--blue-dark); }
.danger-button { min-height: 36px; padding: 0 13px; border: 1px solid rgba(204,69,84,.22); border-radius: 9px; background: transparent; color: var(--danger); font-size: 11px; cursor: pointer; }
.editor-body { width: min(100% - 48px, 900px); margin: 0 auto; padding: 52px 0 90px; }
.note-view { min-height: 560px; }
.viewer-kicker { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 27px; }
.viewer-kicker > span { padding: 5px 8px; border-radius: 6px; background: rgba(51,102,255,.08); color: var(--blue); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.viewer-kicker > span.vault { background: rgba(113,87,232,.09); color: var(--violet); }
.viewer-kicker time { color: var(--muted); font-size: 10px; }
.note-view > h1 { max-width: 780px; margin: 0 0 38px; font-size: clamp(35px, 4vw, 48px); line-height: 1.08; letter-spacing: -.042em; }
.note-rendered { min-height: 360px; max-width: 820px; color: var(--text); font-size: 16px; line-height: 1.82; overflow-wrap: anywhere; }
.note-rendered.plain-text { white-space: pre-wrap; }
.note-rendered.is-empty::before { content: "Esta nota está vacía."; color: var(--muted); font-style: italic; }
.note-rendered > :first-child { margin-top: 0; }
.note-rendered > :last-child { margin-bottom: 0; }
.note-rendered h1, .rich-editor h1 { margin: 1.1em 0 .5em; font-size: 2em; line-height: 1.18; }
.note-rendered h2, .rich-editor h2 { margin: 1.05em 0 .5em; font-size: 1.55em; line-height: 1.24; }
.note-rendered h3, .rich-editor h3 { margin: 1em 0 .45em; font-size: 1.25em; line-height: 1.3; }
.note-rendered blockquote, .rich-editor blockquote { margin: 20px 0; padding: 9px 18px; border-left: 3px solid var(--blue); background: var(--surface-2); color: var(--muted); }
.note-rendered pre, .rich-editor pre { overflow-x: auto; padding: 17px; border-radius: 12px; background: #0b1220; color: #e8eef8; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.6; }
.note-rendered a, .rich-editor a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.viewer-vault { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.viewer-vault section { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.viewer-vault section.wide { grid-column: 1 / -1; }
.viewer-vault section > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.viewer-vault section > div { display: flex; align-items: center; gap: 7px; min-width: 0; }
.viewer-vault code, .viewer-vault a, .viewer-vault p { min-width: 0; margin: 0; overflow-wrap: anywhere; font-family: inherit; font-size: 13px; line-height: 1.6; }
.viewer-vault a { color: var(--blue); }
.viewer-vault button { flex: 0 0 auto; min-height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--blue); font-size: 9px; font-weight: 750; cursor: pointer; }
.viewer-vault button:disabled { color: var(--muted); cursor: default; }
.viewer-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 58px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.viewer-meta > div { display: flex; flex-wrap: wrap; gap: 7px; }
.viewer-meta > div span { padding: 6px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.note-editor { min-height: 560px; }
.editor-type { display: flex; justify-content: space-between; align-items: center; }
.editor-type > span { padding: 5px 8px; border-radius: 6px; background: var(--surface-2); color: var(--blue); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.editor-type > span.vault { color: var(--violet); }
.editor-type label { flex-direction: row; align-items: center; margin: 0; color: var(--muted); font-size: 10px; }
.editor-type select { width: 92px; height: 31px; padding: 0 8px; font-size: 10px; }
.title-input { height: auto; margin: 27px 0 18px; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: clamp(30px, 4vw, 46px); font-weight: 780; letter-spacing: -.04em; }
.title-input:focus { box-shadow: none; }
.rich-toolbar { position: sticky; z-index: 9; top: 190px; display: flex; align-items: center; gap: 3px; overflow: visible; margin: 0 0 28px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: 0 10px 28px rgba(24,37,60,.08); backdrop-filter: blur(14px); }
.rich-toolbar > button, .rich-toolbar > select, .toolbar-color { flex: 0 0 auto; min-width: 36px; height: 36px; display: grid; place-items: center; margin: 0; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }
.rich-toolbar > button:hover, .rich-toolbar > select:hover, .toolbar-color:hover { border-color: var(--line); background: var(--surface-2); }
.rich-toolbar > select { width: 142px; padding: 0 10px; }
.toolbar-divider { flex: 0 0 1px; width: 1px; height: 23px; margin: 0 4px; background: var(--line); }
.toolbar-color { position: relative; width: 36px; padding: 0; font-weight: 850; text-decoration: underline; text-decoration-color: #3366ff; text-decoration-thickness: 3px; text-underline-offset: 3px; }
.toolbar-color.highlight { border-radius: 6px; background: #fff0a8; color: #172033; text-decoration: none; }
.toolbar-color input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.emoji-picker { position: absolute; z-index: 15; top: 50px; right: 0; display: grid; grid-template-columns: repeat(5, 38px); gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.emoji-picker button { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-size: 20px; cursor: pointer; }
.emoji-picker button:hover { background: var(--surface-2); }
.content-input { min-height: 420px; padding: 0; border: 0; border-radius: 0; background: transparent; font-family: inherit; font-size: 16px; line-height: 1.82; }
.content-input:focus { box-shadow: none; }
.rich-editor { outline: none; overflow-wrap: anywhere; }
.rich-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.vault-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; margin-top: 10px; }
.vault-fields label:first-child, .vault-fields label:last-child { grid-column: 1 / -1; }
.copy-field { display: flex; }
.copy-field input { border-radius: 10px 0 0 10px; }
.copy-field button { flex: 0 0 auto; padding: 0 12px; border: 1px solid var(--line); border-left: 0; background: var(--surface-2); color: var(--blue); font-size: 10px; font-weight: 700; cursor: pointer; }
.copy-field button:last-child { border-radius: 0 10px 10px 0; }
.copy-field button + button { border-radius: 0; }
.editor-meta { display: grid; grid-template-columns: 1fr 250px; gap: 18px; margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--line); }
.encryption-note { margin-top: 18px; color: var(--muted); font-size: 10px; }

/* Unlock */
.unlock-overlay { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(7, 12, 22, .82); backdrop-filter: blur(13px); }
.unlock-card { width: min(100%, 420px); padding: 38px; border: 1px solid rgba(255,255,255,.10); border-radius: 22px; background: #101827; color: #eef3fa; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.unlock-card .unlock-mark { margin-bottom: 28px; }
.unlock-card h1 { margin: 0 0 9px; font-size: 29px; letter-spacing: -.035em; }
.unlock-card > p:not(.eyebrow) { margin: 0 0 26px; color: #8f9cb1; line-height: 1.6; }
.unlock-card label { color: #d9e0ea; }
.unlock-card input { border-color: #29364b; background: #0b1220; color: white; }
.unlock-card > small { display: block; margin-top: 15px; color: #6e7c90; line-height: 1.5; text-align: center; }
.biometric-action { width: 100%; min-height: 44px; margin-top: 10px; border: 1px solid #2d3d56; border-radius: 12px; background: #172237; color: #dbe6f7; font-weight: 700; cursor: pointer; }
.biometric-action:hover { background: #1c2a42; }
.toast { position: fixed; z-index: 150; left: 50%; bottom: 24px; padding: 11px 16px; border-radius: 10px; background: #101827; color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9d2d3a; }
.sidebar-backdrop { display: none; }
.mobile-tabbar { display: none; }

@media (max-width: 980px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { min-height: 340px; padding: 50px 8vw; }
  .visual-copy h1 { font-size: 48px; }
  .visual-security { display: none; }
  .auth-form-wrap { min-height: 570px; padding: 55px 8vw; }
  .app-shell { grid-template-columns: 220px minmax(0,1fr); }
  .sidebar { width: 220px; }
  .dashboard { padding-inline: 28px; }
  .editor-body { width: min(100% - 50px, 760px); }
}

@media (max-width: 760px) {
  body { overscroll-behavior-y: none; }
  .mobile-only { display: grid !important; }
  .app-shell { display: block; }
  .sidebar { width: min(84vw, 285px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 22px 0 55px rgba(0,0,0,.26); }
  .sidebar.open { transform: translateX(0); }
  .workspace { min-height: 100vh; }
  .sidebar-backdrop { position: fixed; z-index: 25; inset: 0; display: block; background: rgba(3,7,14,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .topbar { height: 62px; padding: 0 15px; }
  .note-tabs { top: 62px; min-height: 46px; padding: 6px 12px; }
  .topbar .sync-state { display: none; }
  .search-box input { height: 39px; }
  .dashboard { padding: 29px 17px calc(105px + env(safe-area-inset-bottom)); }
  .dashboard-head { display: block; }
  .dashboard-head h1 { font-size: 27px; }
  .date-chip { display: none; }
  .stat-row { grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 22px 0 31px; }
  .stat-card { display: block; padding: 10px; }
  .stat-icon { width: 31px; height: 31px; margin-bottom: 8px; }
  .stat-card strong { font-size: 15px; }
  .notes-grid { grid-template-columns: 1fr; }
  .note-card { min-height: 168px; }
  .editor-panel { min-height: calc(100vh - 62px); padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .editor-head { top: 108px; grid-template-columns: auto 1fr auto; padding: 0 14px; }
  .editor-status { display: none; }
  .editor-actions { gap: 5px; }
  .edit-button, .done-button { min-height: 37px; padding: 0 11px; }
  .editor-actions .danger-button { width: 37px; overflow: hidden; padding: 0; color: transparent; }
  .editor-actions .danger-button::before { content: "♲"; color: var(--danger); font-size: 16px; }
  .editor-body { width: calc(100% - 34px); padding-top: 30px; }
  .note-view { min-height: 460px; }
  .viewer-kicker { margin-bottom: 22px; }
  .note-view > h1 { margin-bottom: 29px; font-size: 34px; }
  .note-rendered { min-height: 300px; font-size: 16px; line-height: 1.75; }
  .viewer-vault { grid-template-columns: 1fr; }
  .viewer-vault section.wide { grid-column: 1; }
  .viewer-meta { align-items: flex-start; flex-direction: column; margin-top: 40px; }
  .title-input { font-size: 31px; }
  .content-input { min-height: 330px; }
  .rich-toolbar { position: static; overflow-x: auto; overflow-y: hidden; margin-inline: -4px; padding: 7px; box-shadow: none; scrollbar-width: none; }
  .rich-toolbar > select { width: 128px; }
  .rich-toolbar::-webkit-scrollbar { display: none; }
  .emoji-picker { position: fixed; top: auto; right: 17px; bottom: 24px; }
  .vault-fields { grid-template-columns: 1fr; }
  .vault-fields label { grid-column: 1 !important; }
  .editor-meta { grid-template-columns: 1fr; gap: 0; }
  .setup-card { padding: 30px 22px; }
  .form-grid, .recovery-grid { grid-template-columns: 1fr; }
  .form-grid label:first-child { grid-column: 1; }
  .setup-progress i { width: 42px; }
  .auth-visual { min-height: 290px; }
  .visual-copy h1 { font-size: 39px; }
  .auth-form-wrap { min-height: 530px; padding: 42px 24px; }
  .auth-form h2 { font-size: 29px; }
  .unlock-card { padding: 31px 24px; }
  .mobile-tabbar {
    position: fixed;
    z-index: 80;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    min-height: calc(72px + env(safe-area-inset-bottom));
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 -12px 30px rgba(16, 26, 43, .08);
    backdrop-filter: blur(18px);
  }
  .mobile-tab {
    display: grid;
    place-items: center;
    gap: 3px;
    min-height: 54px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
  }
  .mobile-tab span { font-size: 19px; line-height: 1; }
  .mobile-tab small { font-size: 9px; font-weight: 700; }
  .mobile-tab.active { color: var(--blue); background: rgba(51, 102, 255, .09); }
  .mobile-create {
    align-self: start;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: -25px auto 0;
    border: 5px solid var(--bg);
    border-radius: 18px;
    background: linear-gradient(145deg, #4a7bff, #2854dc);
    color: #fff;
    box-shadow: 0 12px 26px rgba(51, 102, 255, .32);
    cursor: pointer;
  }
  .mobile-create span { font-size: 27px; font-weight: 400; line-height: 1; }
  .mobile-create:active, .mobile-tab:active { transform: scale(.96); }
  .app-shell.is-editing .mobile-tabbar { display: none; }
  .app-shell.is-editing .editor-panel { padding-bottom: 0; }
}

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