/* =============================================================================
   Catatku — gaya antarmuka (light & dark)
   ========================================================================== */
:root {
  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #e9e5ff 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, #dff6fb 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e8ebf2;
  --text: #141824;
  --text-2: #3b4254;
  --muted: #6b7386;
  --border: #e3e6ee;
  --border-strong: #d2d6e1;
  --primary: #6c5cf6;
  --primary-2: #8b7bff;
  --primary-ink: #ffffff;
  --primary-soft: #efedff;
  --accent: #14b8d4;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #18a058;
  --warn: #d48a00;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px -4px rgba(16, 24, 40, .10), 0 2px 4px -2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .22);
  --radius: 16px;
  --radius-sm: 10px;
  --ring: 0 0 0 3px rgba(108, 92, 246, .28);
  --topbar-h: 64px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* warna kartu */
  --c-default: var(--surface);
  --c-red: #ffe9e7; --c-orange: #ffefdc; --c-yellow: #fff7cf; --c-green: #e3f7e6;
  --c-teal: #dcf5f3; --c-blue: #e1edff; --c-purple: #efe8ff; --c-pink: #ffe6f2;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c0e13;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(108, 92, 246, .16) 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(20, 184, 212, .10) 0%, transparent 55%);
  --surface: #151820;
  --surface-2: #1b1f29;
  --surface-3: #242936;
  --text: #e8eaf0;
  --text-2: #c3c8d4;
  --muted: #8d95a8;
  --border: #252a36;
  --border-strong: #323849;
  --primary: #8b7bff;
  --primary-2: #a597ff;
  --primary-ink: #0c0e13;
  --primary-soft: rgba(139, 123, 255, .14);
  --danger: #ff6b6f;
  --danger-soft: rgba(255, 107, 111, .12);
  --ok: #3ddc84;
  --warn: #f3b33d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 20px -6px rgba(0, 0, 0, .55);
  --shadow-lg: 0 28px 60px -12px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(139, 123, 255, .35);

  --c-red: #2b1a1d; --c-orange: #2c2117; --c-yellow: #2a2615; --c-green: #172619;
  --c-teal: #14272a; --c-blue: #17202f; --c-purple: #211b33; --c-pink: #2c1826;
  color-scheme: dark;
}

/* ---------- dasar ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 15px/1.55 var(--font); color: var(--text);
  background: var(--bg-grad), var(--bg); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.theme-anim, .theme-anim * { transition: background-color .3s ease, color .3s ease, border-color .3s ease !important; }
a { color: var(--primary); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
::selection { background: rgba(108, 92, 246, .25); }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
code, pre, kbd { font-family: var(--mono); }
kbd { font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.i { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { display: flex; justify-content: center; margin-top: 24px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }
.grad { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.only-mobile { display: none !important; }
@media (max-width: 760px) { .only-mobile { display: inline-flex !important; } .only-desktop { display: none !important; } }

/* ---------- boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap; position: relative;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease, opacity .2s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px -6px rgba(108, 92, 246, .6); }
:root[data-theme="dark"] .btn-primary { color: #fff; }
.btn-primary:hover { box-shadow: 0 10px 22px -8px rgba(108, 92, 246, .75); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 48px; font-size: 15px; }
.btn-block { width: 100%; }
.danger-text { color: var(--danger) !important; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-ghost.loading::after { border-color: var(--border); border-top-color: var(--primary); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background .15s, color .15s, transform .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.93); }
.icon-btn.on { color: var(--primary); background: var(--primary-soft); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm .i { width: 18px; height: 18px; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; font-size: 14px; }
.link:hover { text-decoration: underline; }
.link.right { align-self: flex-end; margin-top: -4px; }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .pw-wrap input, .select {
  height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 15px; font-weight: 400; color: var(--text);
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
.field input:focus, .pw-wrap input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 46px; }
.pw-wrap .icon-btn { position: absolute; right: 7px; top: 7px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; font-weight: 500; }
.select { height: 38px; width: auto; font-size: 13px; padding: 0 10px; border-radius: 10px; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: -6px; }
.strength i { height: 4px; border-radius: 4px; background: var(--surface-3); transition: background .25s; }
.strength i.on.s1 { background: var(--danger); } .strength i.on.s2 { background: var(--warn); }
.strength i.on.s3 { background: #7cc644; } .strength i.on.s4 { background: var(--ok); }

/* ---------- halaman auth ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 40px; max-width: 1100px; margin: 0 auto; padding: 32px 24px; position: relative; }
.auth-corner { position: absolute; top: 18px; right: 18px; }
.auth-hero h1 { font-size: clamp(34px, 5vw, 54px); font-weight: 800; margin: 28px 0 24px; letter-spacing: -.03em; }
.hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.hero-points li { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-weight: 500; }
.hero-points .i { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--primary); border: 1px solid var(--border); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 36px; box-shadow: var(--shadow-lg); animation: rise .45s cubic-bezier(.2, .8, .2, 1); }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card > .muted { margin: 0 0 24px; }
.auth-switch { text-align: center; margin: 22px 0 0; color: var(--muted); font-size: 14px; }
.auth-switch a { font-weight: 600; }
.auth-card.setup { grid-column: 1 / -1; max-width: 620px; margin: 0 auto; }
.auth-card.setup ol { padding-left: 20px; line-height: 1.9; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -.02em; }
.brand .i { width: 34px; height: 34px; padding: 6px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 6px 14px -6px rgba(108, 92, 246, .7); }
.brand.big { font-size: 22px; }
.brand.big .i { width: 40px; height: 40px; }
.auth-card .brand.only-mobile { margin-bottom: 20px; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; padding: 72px 16px 24px; align-items: start; }
  .auth-hero { display: none; }
  .auth-card { padding: 28px 22px; border-radius: 20px; }
  .auth-card .brand.only-mobile { display: inline-flex !important; }
}
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar-h); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); background: color-mix(in srgb, var(--bg) 78%, transparent); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1240px; margin: 0 auto; height: 100%; padding: 0 20px; display: flex; align-items: center; gap: 18px; }
.nav-desktop { display: flex; gap: 4px; }
.nav-desktop a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px; transition: background .15s, color .15s; }
.nav-desktop a .i { width: 18px; height: 18px; }
.nav-desktop a:hover { color: var(--text); background: var(--surface-2); }
.nav-desktop a.active { color: var(--primary); background: var(--primary-soft); }
.search-trigger { flex: 1; max-width: 420px; margin-left: auto; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.search-trigger:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger .i { width: 18px; height: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }

/* ---------- menu dropdown ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .16s ease; }
.menu > button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: 9px; text-align: left; font-size: 14px; font-weight: 500; color: var(--text); }
.menu > button .i { width: 18px; height: 18px; color: var(--muted); }
.menu > button:hover { background: var(--surface-2); }
.menu > button.danger, .menu > button.danger .i { color: var(--danger); }
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-head span { font-size: 13px; color: var(--muted); word-break: break-all; }
.menu-note { display: flex; gap: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; border-bottom: 1px solid var(--border); margin-bottom: 6px; max-width: 280px; }
.menu-note .i { width: 16px; height: 16px; color: var(--primary); margin-top: 1px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

.banner { max-width: 1240px; margin: 12px auto 0; padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-radius: 12px; background: var(--primary-soft); color: var(--text-2); font-size: 13.5px; width: calc(100% - 40px); }
.banner > span { flex: 1; }
.banner .i { color: var(--primary); }

/* ---------- layout ---------- */
.view { max-width: 1240px; margin: 0 auto; padding: 28px 20px 120px; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
.page-title { font-size: clamp(24px, 3.2vw, 32px); font-weight: 800; letter-spacing: -.025em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.hero-row p { margin: 6px 0 0; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-card { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-card .i { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.quick-card span { display: flex; flex-direction: column; line-height: 1.25; }
.quick-card b { font-size: 14px; } .quick-card small { color: var(--muted); font-size: 12px; }
.section { margin-bottom: 36px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.section-head .section-title { margin-bottom: 0; }
.section-title .i { width: 16px; height: 16px; }
.section-title.sm { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }

/* ---------- kartu catatan ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.note-card {
  --card: var(--c-default);
  display: flex; flex-direction: column; gap: 10px; min-height: 160px; padding: 18px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s, border-color .18s;
  position: relative; overflow: hidden; contain: content;
}
.grid.anim > .note-card { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }
.grid.anim > .note-card:nth-child(2) { animation-delay: .02s; } .grid.anim > .note-card:nth-child(3) { animation-delay: .04s; }
.grid.anim > .note-card:nth-child(4) { animation-delay: .06s; } .grid.anim > .note-card:nth-child(n+5) { animation-delay: .08s; }
.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.note-card:active { transform: translateY(-1px) scale(.995); }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-top h3 { flex: 1; font-size: 16px; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.pin-badge { color: var(--primary); } .pin-badge .i { width: 16px; height: 16px; }
.snippet { margin: 0; flex: 1; font-size: 14px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.snippet.locked { display: flex; align-items: center; gap: 8px; color: var(--muted); font-style: italic; }
.snippet.locked .i { width: 16px; height: 16px; }
mark { background: rgba(255, 200, 0, .38); color: inherit; border-radius: 3px; padding: 0 1px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 10px; align-items: center; }
.badges span { display: inline-flex; align-items: center; gap: 3px; }
.badges .i { width: 14px; height: 14px; }
.c-default { --card: var(--c-default); } .c-red { --card: var(--c-red); } .c-orange { --card: var(--c-orange); }
.c-yellow { --card: var(--c-yellow); } .c-green { --card: var(--c-green); } .c-teal { --card: var(--c-teal); }
.c-blue { --card: var(--c-blue); } .c-purple { --card: var(--c-purple); } .c-pink { --card: var(--c-pink); }

.note-card.skeleton { pointer-events: none; gap: 12px; }
.note-card.skeleton i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.note-card.skeleton i:first-child { height: 18px; width: 60%; }
.note-card.skeleton i:nth-child(3) { width: 85%; } .note-card.skeleton i:last-child { width: 40%; margin-top: auto; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon .i { width: 60px; height: 60px; padding: 15px; border-radius: 18px; background: var(--primary-soft); color: var(--primary); }
.empty h3 { font-size: 19px; margin-top: 6px; }
.empty p { max-width: 380px; margin: 0 0 10px; }

/* ---------- pencarian ---------- */
.search-head { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 10; display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.search-box { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.search-box:focus-within { border-color: var(--primary); box-shadow: var(--ring), var(--shadow); }
.search-box input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; min-width: 0; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-box > .i { color: var(--muted); }
.filters { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .15s; }
.chip .i { width: 15px; height: 15px; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.chip small { opacity: .7; font-weight: 500; }
.tag-chips:empty { display: none; }
.result-count { margin: 0 0 14px; font-size: 13px; }

/* ---------- editor catatan ---------- */
.view-note { max-width: 920px; padding-top: 16px; }
.note-page { --card: var(--c-default); position: relative; }
.note-toolbar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20; display: flex; align-items: center; gap: 4px; padding: 6px; margin-bottom: 14px; border-radius: 14px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.save-status { font-size: 12.5px; color: var(--muted); padding: 0 8px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.save-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.save-status.ok::before { background: var(--ok); }
.save-status.busy::before { background: var(--primary); animation: pulse 1s infinite; }
.save-status.warn::before { background: var(--warn); }
.save-status.err { color: var(--danger); } .save-status.err::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); margin-right: 4px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: none; font-size: 13px; font-weight: 600; color: var(--muted); transition: all .15s; }
.seg button .i { width: 16px; height: 16px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.palette { display: grid; grid-template-columns: repeat(5, 32px); gap: 8px; padding: 12px; min-width: 0; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--card); transition: transform .12s; }
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: var(--primary); box-shadow: var(--ring); }

.note-sheet { background: var(--card); border: 1px solid var(--border); border-radius: 22px; padding: 28px 32px 24px; box-shadow: var(--shadow); transition: background .25s ease; min-height: 60vh; display: flex; flex-direction: column; }
.note-title { width: 100%; border: 0; background: none; outline: none; font-size: clamp(24px, 3.4vw, 32px); font-weight: 800; letter-spacing: -.02em; padding: 0; margin-bottom: 10px; }
.note-title::placeholder, .note-content::placeholder { color: var(--muted); opacity: .7; }
.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
#n-tag-list { display: contents; }
.tag-edit { padding-right: 3px; }
.tag-edit button { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: none; color: inherit; padding: 0; }
.tag-edit button:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.tag-edit .i { width: 12px; height: 12px; }
.tag-input-wrap { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.tag-input-wrap .i { width: 14px; height: 14px; }
.tag-input-wrap input { border: 0; background: none; outline: none; font-size: 13px; width: 110px; padding: 4px 0; }
.md-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px; margin: 0 -8px 10px; border-radius: 12px; border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 60%, transparent); overflow-x: auto; scrollbar-width: none; transition: opacity .2s; }
.md-toolbar::-webkit-scrollbar { display: none; }
.md-toolbar.dim { opacity: .55; }
.md-toolbar button { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--text-2); }
.md-toolbar button:hover { background: var(--surface-2); color: var(--text); }
.md-toolbar .i { width: 18px; height: 18px; }
.note-content { width: 100%; min-height: 40vh; border: 0; background: none; outline: none; resize: none; font-size: 16px; line-height: 1.75; padding: 0; overflow: hidden; tab-size: 4; }
.note-meta { margin: 18px 0 0; padding-top: 14px; border-top: 1px dashed var(--border); }

/* markdown preview */
.md { min-height: 40vh; font-size: 16px; line-height: 1.75; word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.3em 0 .5em; font-weight: 750; }
.md h1 { font-size: 1.7em; } .md h2 { font-size: 1.4em; } .md h3 { font-size: 1.2em; }
.md p { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.5em; margin: .5em 0; }
.md li.indent-1 { margin-left: 1.2em; } .md li.indent-2 { margin-left: 2.4em; } .md li.indent-3 { margin-left: 3.6em; } .md li.indent-4 { margin-left: 4.8em; }
.md ul.task-list { list-style: none; padding-left: .2em; }
.md li[data-task] label { display: inline-flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.md li[data-task] input { width: 18px; height: 18px; margin-top: .35em; accent-color: var(--primary); cursor: pointer; }
.md .done { text-decoration: line-through; color: var(--muted); }
.md code { font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); padding: .1em .4em; border-radius: 6px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); padding: 14px 16px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; font-size: .86em; }
.md blockquote { margin: .8em 0; padding: .4em 1em; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 10px 10px 0; color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md a { text-decoration: underline; text-underline-offset: 2px; }

/* lampiran */
.attachments { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.attachments .section-head { margin-bottom: 12px; }
.attachments.empty-files .files-grid { display: none; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 10px; }
.file-tile { display: flex; flex-direction: column; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); overflow: hidden; animation: rise .3s ease both; transition: box-shadow .15s, transform .15s; }
.file-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.file-tile .thumb { position: relative; height: 110px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); overflow: hidden; }
.file-tile .thumb .i { width: 34px; height: 34px; }
.file-tile .thumb.is-img { cursor: zoom-in; }
.file-tile .thumb img { width: 100%; height: 100%; object-fit: cover; animation: fadein .3s ease; }
.file-tile .thumb .ext { position: absolute; bottom: 8px; right: 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 6px; background: var(--primary); color: #fff; }
.loading-thumb { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)) !important; background-size: 200% 100% !important; animation: shimmer 1.2s infinite; }
.file-info { padding: 10px 12px 4px; display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info small { font-size: 11.5px; color: var(--muted); }
.file-actions { display: flex; justify-content: flex-end; gap: 2px; padding: 2px 6px 6px; min-height: 8px; }
.file-tile.failed { border-color: var(--danger); } .file-tile.failed .thumb { color: var(--danger); }
.progress { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .25s ease; }
.file-tile.uploading { padding-bottom: 10px; }
.drop-overlay { position: absolute; inset: -6px; z-index: 30; display: grid; place-items: center; border-radius: 24px; border: 2px dashed var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); backdrop-filter: blur(3px); pointer-events: none; animation: fadein .15s; }
.drop-overlay div { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--primary); font-size: 16px; }
.drop-overlay .i { width: 40px; height: 40px; }
.note-loading { display: grid; place-items: center; min-height: 50vh; }

/* layar terkunci */
.lock-screen { display: grid; place-items: center; min-height: 62vh; }
.lock-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 36px 28px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: rise .35s ease; }
.lock-card h2 { font-size: 21px; word-break: break-word; }
.lock-card p { margin: 0; font-size: 14px; }
.lock-card .pw-wrap { width: 100%; }
.lock-icon .i { width: 64px; height: 64px; padding: 16px; border-radius: 20px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 12px 28px -10px rgba(108, 92, 246, .7); }

/* lightbox */
.lightbox { display: flex; flex-direction: column; gap: 12px; }
.lightbox-img { display: grid; place-items: center; min-height: 200px; max-height: 75vh; overflow: auto; border-radius: 12px; background: var(--surface-2); }
.lightbox-img img { max-width: 100%; max-height: 75vh; object-fit: contain; }
.lightbox-bar { display: flex; align-items: center; gap: 10px; }
.lightbox-bar .file-name { flex: 1; }

/* ---------- live pad ---------- */
.view-live { max-width: 980px; }
.live-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.live-head p { margin: 6px 0 0; max-width: 560px; }
.live-head .page-title .i { width: 30px; height: 30px; color: var(--primary); }
.live-pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.live-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.live-pill.ok { color: var(--ok); } .live-pill.ok i { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); animation: pulse 2s infinite; }
.live-pill.busy i { background: var(--primary); animation: pulse .8s infinite; }
.live-pill.warn { color: var(--warn); } .live-pill.warn i { background: var(--warn); }
.live-pill.err { color: var(--danger); } .live-pill.err i { background: var(--danger); }
.live-card { border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.live-text { display: block; width: 100%; min-height: 52vh; padding: 22px 24px; border: 0; outline: none; resize: vertical; background: none; font-family: var(--mono); font-size: 15px; line-height: 1.65; transition: background .6s ease; }
.live-text.flash { animation: flash 1s ease; }
@keyframes flash { 0% { background: var(--primary-soft); } 100% { background: transparent; } }
.live-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.live-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px) scale(.97); transition: opacity .22s ease, transform .22s cubic-bezier(.2, .8, .2, 1); cursor: pointer; max-width: 100%; }
.toast.show { opacity: 1; transform: none; }
.toast .i { width: 18px; height: 18px; }
.toast-success .i { color: var(--ok); } .toast-error .i { color: var(--danger); }
:root[data-theme="dark"] .toast { background: #f0f1f5; color: #11131a; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 18, .45); backdrop-filter: blur(4px); opacity: 0; transition: opacity .18s ease; }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-width: 420px; max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.modal-wide { max-width: 900px; }
.modal-backdrop.show .modal { transform: none; }
.modal-title { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.modal-title .i { color: var(--primary); }
.modal-text { color: var(--text-2); margin: 8px 0 0; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* bottom sheet (menu akun di ponsel) */
.modal-backdrop.is-sheet { align-items: end; padding: 0; }
.modal.sheet { max-width: 520px; border-radius: 22px 22px 0 0; padding: 10px 14px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.modal.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto 14px; }
.modal-backdrop.show .modal.sheet { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 4px 6px 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.sheet-head > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.sheet-head span { font-size: 13px; word-break: break-all; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; display: grid; place-items: center; flex: none; }
.sheet-list { display: flex; flex-direction: column; }
.sheet-list button { display: flex; align-items: center; gap: 12px; padding: 14px 10px; border: 0; background: none; border-radius: 12px; font-size: 15px; font-weight: 500; text-align: left; color: var(--text); }
.sheet-list button:active, .sheet-list button:hover { background: var(--surface-2); }
.sheet-list button .i { color: var(--muted); }
.sheet-list button.danger, .sheet-list button.danger .i { color: var(--danger); }

/* ---------- navigasi mobile ---------- */
.nav-mobile { display: none; }
@media (max-width: 760px) {
  :root { --topbar-h: 56px; }
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .nav-desktop, .search-trigger { display: none; }
  .topbar-actions { margin-left: auto; gap: 2px; }
  .topbar-actions .avatar { display: none; }
  .view { padding: 18px 14px calc(110px + env(safe-area-inset-bottom)); }
  .nav-mobile {
    display: flex; position: fixed; z-index: 45; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: 64px; padding: 0 6px; align-items: center; justify-content: space-around; border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  }
  .nav-mobile a, .nav-mobile > button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 6px 0; -webkit-tap-highlight-color: transparent; }
  .nav-mobile a.active { color: var(--primary); }
  .nav-mobile .fab { flex: none; width: 52px; height: 52px; margin-top: -26px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 10px 24px -8px rgba(108, 92, 246, .8); border: 3px solid var(--bg); }
  .nav-mobile .fab .i { width: 24px; height: 24px; }
  #user-menu { position: fixed; top: auto; bottom: calc(84px + env(safe-area-inset-bottom)); right: 12px; left: 12px; }
  .banner { width: calc(100% - 28px); }
  .hero-row { margin-bottom: 20px; }
  .quick { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .quick-card { flex-direction: column; align-items: flex-start; padding: 12px; gap: 8px; }
  .quick-card small { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .note-card { padding: 14px; min-height: 140px; border-radius: 14px; }
  .card-top h3 { font-size: 15px; }
  .snippet { font-size: 13px; -webkit-line-clamp: 4; }
  .search-head { top: calc(var(--topbar-h) + 4px); }
  .search-box { height: 50px; }
  .note-toolbar { top: calc(var(--topbar-h) + 4px); }
  .note-toolbar { gap: 2px; padding: 4px; }
  .note-toolbar .icon-btn { width: 36px; height: 36px; }
  .seg button span { display: none; }
  .seg button { padding: 0 9px; }
  .note-sheet { padding: 20px 16px 18px; border-radius: 18px; }
  .md-toolbar { margin: 0 -4px 10px; }
  .files-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-text { min-height: 45vh; padding: 16px; font-size: 14px; }
  .live-actions .btn { flex: 1 1 calc(50% - 8px); }
  .toasts { bottom: calc(90px + env(safe-area-inset-bottom)); }
  .menu.menu-right { right: -40px; }
}
@media (max-width: 430px) { .save-status { font-size: 0; gap: 0; padding: 0 8px; } }
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
