:root {
  --kertas: #F4FBF7;
  --kertas-raised: #FFFFFF;
  --tinta: #0B1F17;
  --tinta-soft: #374151;
  --muted: #6B7280;
  --heading: #064E3B;
  --line: #DCE6E4;
  --accent: #04805A;
  --accent-hover: #036B4B;
  --accent-tint: #D1FAE5;
  --danger: #B42318;
  --danger-tint: #FEECEB;
  --shadow: 0 1px 2px rgba(11,31,23,0.04), 0 8px 24px rgba(11,31,23,0.06);
  --shadow-lg: 0 16px 48px rgba(11,31,23,0.12), 0 4px 12px rgba(11,31,23,0.06);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --gradient-mesh: radial-gradient(ellipse 70% 50% at 15% -10%, rgba(52,211,153,0.22), transparent),
    radial-gradient(ellipse 60% 50% at 90% 0%, rgba(16,185,129,0.14), transparent);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--kertas);
  color: var(--tinta);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--kertas-raised); border-color: var(--line); color: var(--heading); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
:focus-visible { outline: 3px solid rgba(4,128,90,.35); outline-offset: 2px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 20px;
  color: var(--heading); text-decoration: none; line-height: 1;
}
.brand b { color: var(--accent); }

/* ---------- Auth pages ---------- */
body.auth { background: var(--gradient-mesh), var(--kertas); }
.auth-wrap {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 16px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--kertas-raised); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 32px 28px;
}
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-family: 'Baloo 2', system-ui, sans-serif; color: var(--heading); font-size: 28px; line-height: 1.2; margin-top: 24px; }
.auth-card .lead { color: var(--tinta-soft); margin: 4px 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; color: var(--tinta-soft); }
.auth-form input {
  min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--kertas); font-weight: 400; font-size: 16px; color: var(--tinta);
}
.auth-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(4,128,90,.15); background: #fff; }
.auth-form .btn { margin-top: 6px; }
.switch { margin-top: 18px; text-align: center; color: var(--tinta-soft); font-size: 14px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: 13px; }
.alert { background: var(--danger-tint); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.alert.ok { background: var(--accent-tint); color: var(--heading); }
.muted { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.acct-sec { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 20px; }
.acct-sec h2 { font-size: 16px; color: var(--heading); margin-bottom: 12px; }
.acct-sec.danger h2 { color: var(--danger); }

/* ---------- App shell ---------- */
body.app { overflow: hidden; }
.shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side {
  display: flex; flex-direction: column; gap: 12px; min-height: 0;
  background: var(--kertas); border-right: 1px solid var(--line); padding: 16px;
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px; }
.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-tint); color: var(--heading); font-weight: 700;
}
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: 44px; z-index: 10; min-width: 220px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 8px;
}
.menu-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-who span { color: var(--muted); font-size: 13px; word-break: break-all; }
.menu-pop a, .menu-pop button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
  background: none; border: 0; cursor: pointer; color: var(--tinta); text-decoration: none; font-size: 14px;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--kertas); }
.new-note { width: 100%; }
.search {
  min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; font-size: 15px;
}
.search:focus { outline: none; border-color: var(--accent); }
.note-list { list-style: none; overflow-y: auto; flex: 1; min-height: 0; margin: 0 -6px; padding: 0 6px; }
.note-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%;
  text-align: left; padding: 10px 12px; margin-bottom: 4px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: none; cursor: pointer;
}
.note-item:hover { background: #fff; border-color: var(--line); }
.note-item.active { background: #fff; border-color: var(--accent); box-shadow: var(--shadow); }
.ni-title { font-weight: 600; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ni-date { grid-row: 1; grid-column: 2; color: var(--muted); font-size: 12px; align-self: center; }
.ni-excerpt { grid-column: 1 / -1; color: var(--tinta-soft); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-list { color: var(--muted); text-align: center; padding: 24px 0; font-size: 14px; }

/* ---------- Editor ---------- */
.editor { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #fff; position: relative; }
.editor-bar {
  display: flex; align-items: center; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.status { flex: 1; color: var(--muted); font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: none; cursor: pointer; font-size: 17px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--kertas); border-color: var(--line); }
#pin[aria-pressed="false"] { filter: grayscale(1); opacity: .55; }
.back { display: none; }
.ribbon {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0;
  padding: 6px 12px; background: var(--kertas); border-bottom: 1px solid var(--line);
}
.rb-group { display: flex; align-items: center; gap: 2px; padding: 0 8px; border-right: 1px solid var(--line); }
.rb-group:last-child { border-right: 0; }
.rb-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  min-width: 32px; height: 32px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px;
  background: none; cursor: pointer; color: var(--tinta); font-size: 15px; line-height: 1;
}
.rb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rb-btn svg circle { fill: currentColor; stroke: none; }
.rb-btn:hover { background: #fff; border-color: var(--line); }
.rb-btn[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--heading); }
.rb-b { font-weight: 800; font-family: Georgia, serif; }
.rb-i { font-style: italic; font-family: Georgia, serif; }
.rb-u { text-decoration: underline; font-family: Georgia, serif; }
.rb-s { text-decoration: line-through; font-family: Georgia, serif; }
.rb-text { font-size: 12px; font-weight: 700; color: var(--heading); }
.rb-color { flex-direction: column; gap: 1px; padding-top: 3px; }
.rb-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.rb-a { font-weight: 700; font-family: Georgia, serif; font-size: 14px; }
.rb-hl { font-weight: 700; font-size: 12px; }
.rb-swatch { width: 18px; height: 4px; border-radius: 2px; }
.rb-select {
  height: 32px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 13px; color: var(--tinta); cursor: pointer;
}
.rb-block { width: 104px; }
.rb-font { width: 136px; }
.rb-size { width: 76px; }
.conflict {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: #FFF7E6; border-bottom: 1px solid #F5D99A; padding: 10px 16px; font-size: 14px;
}
.conflict p { flex: 1 1 200px; color: #7E5F28; font-weight: 600; }
.conflict .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.doc { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.title {
  width: 100%; margin: 0; border: 0; outline: none; background: none; padding: 28px 28px 4px;
  font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 28px; color: var(--heading);
}
.title::placeholder { color: #A3AFAB; }
.page { position: relative; flex: 1; padding: 8px 28px 60px; min-height: 300px; }
.rich {
  outline: none; font-size: 15px; line-height: 1.65; color: var(--tinta);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.rich.is-empty::before { content: attr(data-placeholder); color: #A3AFAB; pointer-events: none; position: absolute; }
.rich h1 { font-size: 1.8em; line-height: 1.25; margin: .3em 0 .2em; color: var(--heading); }
.rich h2 { font-size: 1.45em; line-height: 1.3; margin: .3em 0 .2em; color: var(--heading); }
.rich h3 { font-size: 1.2em; line-height: 1.35; margin: .3em 0 .2em; color: var(--heading); }
.rich p { margin: 0 0 .6em; }
.rich ul, .rich ol { padding-left: 1.6em; margin: .2em 0; white-space: normal; }
.rich li { white-space: pre-wrap; }
.rich blockquote { border-left: 4px solid var(--accent-tint); margin: .4em 0; padding: .2em 0 .2em 14px; color: var(--tinta-soft); }
.rich pre, .rich code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .92em; background: var(--kertas); border-radius: 4px; }
.rich pre { padding: 10px 12px; }
.rich a { color: var(--accent); }
.rich hr { border: 0; border-top: 2px dashed var(--line); margin: 18px 0; }
.mode-btn {
  min-height: 36px; padding: 0 12px; margin-right: 4px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  color: var(--heading); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.mode-btn:hover { border-color: var(--accent); }
.mode-btn[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); }
.cards {
  width: 100%; margin: 0; padding: 12px 28px 40px;
  display: flex; flex-direction: column; gap: 12px;
}
.card {
  border: 1.5px solid var(--line); border-radius: var(--radius-md); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(4,128,90,.12); }
.card-input { position: relative; min-height: 64px; padding: 14px 16px 10px; }
.card-foot {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px 16px;
  border-top: 1px dashed var(--line);
}
.card-num { flex: 1; color: var(--muted); font-size: 12px; font-weight: 700; }
.card-del {
  min-height: 34px; padding: 0 10px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 600; border-radius: 8px;
}
.card-del:hover { color: var(--danger); background: var(--danger-tint); }
.copy-btn, .copy-wa { min-height: 34px; padding: 0 12px; font-size: 13px; min-width: 88px; }
.copy-wa.done { background: var(--accent-tint); }
.copy-btn.done { background: var(--heading); }
.add-block {
  min-height: 48px; border: 1.5px dashed var(--line); border-radius: var(--radius-md);
  background: none; cursor: pointer; color: var(--accent); font-weight: 600;
}
.add-block:hover { border-color: var(--accent); background: var(--kertas); }
.placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; background: #fff;
  color: var(--muted); text-align: center; padding: 24px;
}
.shell:not(.has-note) .ribbon, .shell:not(.has-note) .editor-bar, .shell:not(.has-note) .doc { visibility: hidden; }

@media (max-width: 759px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; }
  .editor { display: none; }
  .shell.has-note .side { display: none; }
  .shell.has-note .editor { display: flex; }
  .back { display: grid; }
  .title { font-size: 24px; padding: 20px 16px 4px; }
  .page { padding: 8px 16px 40px; }
  .cards { padding: 8px 12px 32px; }
  .ribbon { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 6px 4px; }
  .ribbon::-webkit-scrollbar { display: none; }
  .card-foot { flex-wrap: wrap; padding-left: 12px; }
  .copy-btn, .copy-wa { min-width: 0; }
  .auth-card { padding: 28px 20px; }
}
