/* =========================================================
   Catatan — editor dokumen
   ========================================================= */

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-doc: "Lora", Georgia, "Times New Roman", serif;

  --ink: #1b1a1f;
  --ink-soft: #3b3944;
  --muted: #7b7785;
  --line: #e7e2d8;
  --line-strong: #d8d1c4;

  --bg: #f4f0e8;
  --bg-2: #eae4d9;
  --panel: #ffffff;
  --panel-2: #faf8f3;
  --paper: #fffefb;

  --accent: #6a5ae0;
  --accent-2: #b6583f;
  --accent-soft: #efeefc;
  --accent-ink: #4b3fc4;

  --ok: #2f7d5f;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(30, 26, 20, .06), 0 1px 1px rgba(30, 26, 20, .04);
  --shadow-md: 0 10px 30px -12px rgba(32, 27, 20, .28), 0 2px 8px rgba(32, 27, 20, .06);
  --shadow-lg: 0 30px 70px -30px rgba(28, 23, 16, .45), 0 8px 24px -12px rgba(28, 23, 16, .18);
  --page-shadow: 0 1px 2px rgba(40, 34, 25, .10), 0 18px 40px -18px rgba(40, 34, 25, .32), 0 50px 80px -50px rgba(40, 34, 25, .30);

  --page-w: 210mm;
  --page-min-h: 297mm;
  --page-pad: 22mm;
  --doc-font-size: 16px;
  --doc-line: 1.75;
}

body[data-theme="senja"] {
  --ink: #2a211b;
  --ink-soft: #4a3c31;
  --muted: #8a7763;
  --line: #e3d6c3;
  --line-strong: #d2c0a8;
  --bg: #f0e6d6;
  --bg-2: #e6d9c4;
  --panel: #fffaf1;
  --panel-2: #f9f1e4;
  --paper: #fffdf6;
  --accent: #a9552f;
  --accent-2: #7d6242;
  --accent-soft: #f7e9dc;
  --accent-ink: #8c4526;
}

body[data-theme="malam"] {
  --ink: #e9e7f1;
  --ink-soft: #c9c5d6;
  --muted: #9a95ac;
  --line: #322f3f;
  --line-strong: #403c50;
  --bg: #14131a;
  --bg-2: #0f0e14;
  --panel: #1e1c27;
  --panel-2: #25222f;
  --paper: #f6f3ec;
  --accent: #8b7bf5;
  --accent-2: #dd8a6c;
  --accent-soft: #2b2740;
  --accent-ink: #b5a9ff;
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, .8);
  --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; }
button, select, input { font-size: 13px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 112, 96, .28); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 112, 96, .45); background-clip: content-box; }

.lucide { width: 17px; height: 17px; stroke-width: 1.9; flex: none; }

/* ---------------- layout ---------------- */

.app {
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------------- titlebar ---------------- */

.titlebar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  height: 58px;
  flex: none;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2)));
  color: #fff;
  font-family: var(--font-doc);
  font-weight: 600;
  font-size: 17px;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--accent) 70%, transparent);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 20% 0%, rgba(255,255,255,.45), transparent 60%);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 14.5px; letter-spacing: -.2px; }
.brand-text small { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.title-block {
  display: flex; align-items: center; gap: 8px;
  margin: 0 auto;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
}
.doc-name {
  color: var(--ink-soft);
  font-weight: 600;
  max-width: 34vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dot { opacity: .5; }
.save-state { font-size: 12px; }
.save-state.dirty { color: var(--accent-2); }

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

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink-soft);
  font-weight: 500;
  cursor: pointer;
  transition: .15s ease;
}
.pill:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.pill.primary {
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #000));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 90%, transparent);
}
.pill.primary:hover { filter: brightness(1.06); color: #fff; }
.pill .lucide { width: 15px; height: 15px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------------- menubar ---------------- */

.menubar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  height: 38px;
  flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 25;
}
.menubar::-webkit-scrollbar { display: none; }

.menu-tab {
  border: 0;
  background: transparent;
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.menu-tab:hover { background: var(--accent-soft); color: var(--accent-ink); }
.menu-tab.open { background: var(--accent); color: #fff; }

/* ---------------- ribbon ---------------- */

.ribbon-wrap {
  flex: none;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.ribbon-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 0;
}

.rtab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px 8px 0 0;
  padding: 5px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: .15s;
}
.rtab .lucide { width: 14px; height: 14px; }
.rtab:hover { color: var(--accent-ink); background: var(--accent-soft); }
.rtab.active {
  color: var(--accent-ink);
  background: var(--panel-2);
  border-color: var(--line);
  border-bottom-color: transparent;
  box-shadow: inset 0 2px 0 var(--accent);
}

.ribbon-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ribbon-scroll::-webkit-scrollbar { height: 0; display: none; }

.ribbon {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 4px 8px 5px;
  min-height: 62px;
  width: max-content;
  min-width: 100%;
}

.rb-group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 8px;
  border-right: 1px solid var(--line);
}
.rb-group:last-child { border-right: 0; }

.rb-row { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; }

.rb-label {
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding-top: 3px;
  white-space: nowrap;
}

.tb {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: .13s;
}
.tb:hover { background: var(--accent-soft); color: var(--accent-ink); }
.tb:active { transform: translateY(1px); }
.tb.on { background: var(--accent); color: #fff; border-color: transparent; }
.tb .lucide { width: 16px; height: 16px; }
.tb.wide { width: auto; padding: 0 9px; gap: 6px; font-size: 12px; }
.tb.wide .lucide { width: 15px; height: 15px; }

.tb[disabled] { opacity: .35; pointer-events: none; }

.color-tb {
  position: relative;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-soft);
  border: 1px solid transparent;
  transition: .13s;
}
.color-tb:hover { background: var(--accent-soft); }
.color-tb input[type="color"] {
  position: absolute; inset: auto 0 0 0;
  width: 100%; height: 5px;
  border: 0; padding: 0; margin: 0;
  background: transparent;
  cursor: pointer;
  opacity: .95;
}
.color-tb input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-tb input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.color-tb input[type="color"]::-moz-color-swatch { border: 0; border-radius: 3px; }
.color-tb .lucide { margin-bottom: 4px; }

.mini-select {
  height: 28px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink-soft);
  border-radius: 7px;
  padding: 0 6px;
  cursor: pointer;
  max-width: 126px;
  transition: .15s;
}
.mini-select:hover { border-color: var(--accent); }
.mini-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mini-select.small { max-width: 66px; }

.rb-divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------------- workspace ---------------- */

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0;
  overflow: auto;
  background:
    radial-gradient(120% 90% at 12% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    radial-gradient(100% 80% at 100% 0%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  position: relative;
  padding: 22px 16px 40px;
  scroll-behavior: smooth;
}

.page-wrap {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  flex: none;
}

.ruler {
  width: var(--page-w);
  max-width: 100%;
  height: 20px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  color: var(--muted);
  font-size: 9px;
  user-select: none;
  box-shadow: var(--shadow-sm);
}
.ruler-ticks {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 100%);
  background-size: calc(var(--page-pad) / 2.2) 6px;
  background-position: 0 100%;
  background-repeat: repeat-x;
  opacity: .45;
  padding-left: var(--page-pad);
}
.ruler[hidden] { display: none !important; }
.ruler-unit {
  position: absolute; left: 8px; top: 3px;
  font-size: 9px; letter-spacing: .06em; text-transform: uppercase;
  opacity: .8;
}

.paper {
  width: var(--page-w);
  min-height: var(--page-min-h);
  padding: var(--page-pad);
  background: var(--paper);
  border-radius: 3px;
  box-shadow: var(--page-shadow);
  font-family: var(--font-doc);
  font-size: var(--doc-font-size);
  line-height: var(--doc-line);
  color: #1a1815;
  outline: none;
  position: relative;
  word-wrap: break-word;
  transition: background .25s ease;
  align-self: center;
}
.paper:focus { outline: none; }

.doc-body { min-height: 40vh; }
.doc-body > *:first-child { margin-top: 0; }

.doc-body h1 { font-size: 2em; line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.015em; }
.doc-body h2 { font-size: 1.42em; line-height: 1.3; margin: 1.5em 0 .45em; letter-spacing: -.01em; }
.doc-body h3 { font-size: 1.15em; margin: 1.3em 0 .4em; }
.doc-body p { margin: 0 0 .95em; }
.doc-body .lead { font-size: 1.06em; color: #4a453d; }
.doc-body ul, .doc-body ol { padding-left: 1.4em; margin: 0 0 1em; }
.doc-body li { margin: .25em 0; }
.doc-body blockquote {
  margin: 1.3em 0;
  padding: .2em 0 .2em 1.1em;
  border-left: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  color: #4d4740;
  font-style: italic;
}
.doc-body a { color: #3b4fb5; }
.doc-body img { max-width: 100%; height: auto; border-radius: 4px; }
.doc-body hr { border: 0; border-top: 1px solid #dcd6ca; margin: 1.6em 0; }
.doc-body kbd {
  font-family: var(--font-ui);
  font-size: .78em;
  background: #f1ede4;
  border: 1px solid #ded7c9;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  color: #4a453d;
}
.doc-body .muted-note { color: #7a736a; font-size: .9em; }

.doc-table { width: 100%; border-collapse: collapse; margin: 1em 0 1.3em; font-size: .95em; }
.doc-table th, .doc-table td {
  border: 1px solid #cfc8ba;
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.doc-table th { background: #f5f1e8; font-weight: 600; }
.doc-table.grid-hidden th, .doc-table.grid-hidden td { border-color: transparent; }
.paper[data-grid="off"] .doc-table th, .paper[data-grid="off"] .doc-table td { border-color: transparent; }

.doc-header, .doc-footer {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #857d72;
  letter-spacing: .02em;
  padding: 0 0 10px;
  margin-bottom: 14px;
  border-bottom: 1px dashed #ddd6c8;
  outline: none;
}
.doc-footer {
  padding: 10px 0 0;
  margin: 18px 0 0;
  border-bottom: 0;
  border-top: 1px dashed #ddd6c8;
  text-align: center;
}

.page-break {
  margin: 26px calc(var(--page-pad) * -1);
  border-top: 1px dashed color-mix(in srgb, var(--accent) 35%, #c9c2b4);
  position: relative;
  height: 22px;
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(120,110,95,.06) 6px 12px);
}
.page-break::after {
  content: attr(data-label);
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9c9384;
  background: var(--paper);
  padding: 0 8px;
}

.textbox {
  border: 1px solid #cfc8ba;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 1em 0;
  min-height: 44px;
  background: #fffdf8;
}

.dropcap::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: .86;
  padding: .04em .1em 0 0;
  font-weight: 600;
  color: color-mix(in srgb, var(--accent) 80%, #000);
}

.footnote-ref { font-size: .72em; vertical-align: super; color: var(--accent-ink); }
.footnotes {
  margin-top: 2em;
  padding-top: .7em;
  border-top: 1px solid #ddd6c8;
  font-size: .84em;
  color: #57514a;
}
.footnotes p { margin: .2em 0; }

mark.hit { background: #ffe08a; color: inherit; padding: 0 1px; border-radius: 2px; }
mark.hit.current { background: #ffb347; }

[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: #a9a294;
}

.paper ::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* ---------------- sidebar / split ---------------- */

.sidebar {
  width: 268px;
  flex: none;
  margin-left: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 14px;
  align-self: flex-start;
  position: sticky;
  top: 0;
  max-height: calc(100dvh - 260px);
  overflow: auto;
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } }

.sidebar h4 {
  margin: 0 0 3px;
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar .sb-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.sidebar .style-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  margin-bottom: 6px;
  cursor: pointer;
  transition: .14s;
}
.sidebar .style-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.sidebar .style-item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.sidebar .sb-actions { display: grid; gap: 6px; margin-top: 14px; }
.sidebar .sb-actions button { justify-content: flex-start; }

.split-preview {
  flex: 1;
  min-width: 300px;
  margin-left: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: auto;
  padding: 22px;
}
.split-preview .sp-head {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
}
.split-preview .sp-doc {
  font-family: var(--font-doc);
  line-height: 1.7;
  color: #24211d;
  background: var(--paper);
  padding: 30px;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* ---------------- statusbar ---------------- */

.statusbar {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
  gap: 12px;
}
.status-left, .status-right { display: flex; align-items: center; gap: 10px; }
.sep { width: 1px; height: 12px; background: var(--line-strong); }

.mini {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  height: 22px;
  padding: 0 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 11.5px;
  transition: .13s;
}
.mini:hover { background: var(--accent-soft); color: var(--accent-ink); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 3px;
  background: var(--line-strong);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border: 2px solid var(--panel);
  border-radius: 50%; background: var(--accent);
}
.zoom-label { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- menu popover ---------------- */

.menu-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

.menu-panel {
  position: fixed;
  pointer-events: auto;
  min-width: 286px;
  max-width: 340px;
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn .14s ease-out;
  transform-origin: top left;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.985); } }

.mp-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.mp-title { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.mp-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }

.mp-list { overflow-y: auto; padding: 6px; flex: 1; }

.mi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 13px;
  color: var(--ink-soft);
  transition: background .1s, color .1s;
}
.mi:hover, .mi:focus-visible { background: var(--accent-soft); color: var(--accent-ink); outline: none; }
.mi .lucide { width: 16px; height: 16px; opacity: .85; }
.mi-label { flex: 1; min-width: 0; }
.mi.has-sub .chev { width: 14px; height: 14px; opacity: .55; }
.mi-sub { display: none; padding: 2px 0 4px 26px; }
.mi-sub.open { display: block; animation: popIn .12s ease; }
.mi-sub .mi { font-size: 12.5px; padding: 6px 9px; }
.mi-sep { height: 1px; background: var(--line); margin: 6px 8px; }

.mp-hint {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  min-height: 30px;
  line-height: 1.4;
}

/* ---------------- modal ---------------- */

.modal-layer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.modal-layer.active { pointer-events: auto; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, #16131c 42%, transparent);
  backdrop-filter: blur(3px);
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  max-height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s cubic-bezier(.2,.8,.3,1);
  overflow: hidden;
}
.modal.wide { width: min(760px, calc(100vw - 32px)); }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.98); } }

.modal-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); position: relative; }
.modal-head h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.modal-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.modal-x { position: absolute; top: 12px; right: 12px; }

.modal-body { padding: 16px 20px; overflow: auto; font-size: 13px; line-height: 1.55; }
.modal-foot {
  padding: 12px 20px 16px;
  display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.btn {
  height: 34px; padding: 0 15px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink-soft);
  font-weight: 500;
  cursor: pointer;
  transition: .14s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); color: #fff; }
.btn.danger { border-color: #e2b7ad; color: #a63f28; }
.btn.danger:hover { background: #fbeae5; }
.btn .lucide { width: 15px; height: 15px; }

.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }
.field input[type="text"], .field input[type="number"], .field input[type="url"], .field select, .field textarea {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: .14s;
}
.field textarea { height: auto; min-height: 90px; padding: 9px 10px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice {
  flex: 1;
  min-width: 100px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  color: var(--ink-soft);
  transition: .14s;
}
.choice:hover { border-color: var(--accent); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.choice small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: 2px; }

.doc-list { display: grid; gap: 8px; }
.doc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: .14s;
}
.doc-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.doc-item .di-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--accent-ink); flex: none;
}
.doc-item .di-text { flex: 1; min-width: 0; }
.doc-item strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item small { color: var(--muted); font-size: 11px; }

.symbol-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.symbol-grid button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 7px;
  font-size: 16px;
  cursor: pointer;
  transition: .12s;
}
.symbol-grid button:hover { background: var(--accent-soft); border-color: var(--accent); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  transition: .14s;
}
.swatch:hover { transform: translateY(-1px); }
.swatch.on { border-color: var(--ink); }

.help-section { margin-bottom: 20px; }
.help-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent-ink);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.help-item { display: flex; gap: 9px; padding: 5px 0; font-size: 12.5px; align-items: flex-start; }
.help-item .lucide { width: 15px; height: 15px; margin-top: 2px; color: var(--muted); }
.help-item b { font-weight: 600; }
.help-item span { color: var(--muted); }

.preview-frame {
  width: 100%;
  height: min(60vh, 560px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.letter-preview {
  background: var(--paper);
  color: #1a1815;
  font-family: var(--font-doc);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ---------------- toast ---------------- */

.toast-layer {
  position: fixed;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: #fff;
  font-size: 12.5px;
  padding: 9px 15px;
  border-radius: 99px;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease;
  display: flex; align-items: center; gap: 8px;
  max-width: 90vw;
}
.toast .lucide { width: 15px; height: 15px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.noscript {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: #fff; color: #222; z-index: 999;
  font-family: sans-serif;
}

/* ---------------- context menu ---------------- */

.ctx-menu {
  position: fixed;
  z-index: 90;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
  animation: popIn .12s ease;
}
.ctx-menu .mi { font-size: 12.5px; padding: 6px 9px; }

/* ---------------- views ---------------- */

body[data-view="normal"] .ruler { display: none; }
body[data-view="normal"] .paper { box-shadow: var(--shadow-sm); }

body[data-view="reading"] .ribbon-wrap,
body[data-view="reading"] .menubar { display: none; }
body[data-view="reading"] .paper {
  --page-w: 760px;
  box-shadow: none;
  background: transparent;
  font-size: 18px;
  line-height: 1.85;
}
body[data-view="reading"] .workspace { padding-top: 34px; }
body[data-view="reading"] .ruler { display: none; }

body[data-fullscreen] .titlebar,
body[data-fullscreen] .statusbar { display: none; }

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  .title-block { display: none; }
  .sidebar { position: fixed; right: 10px; top: 150px; width: min(300px, 86vw); z-index: 45; max-height: 62vh; }
  .split-preview { display: none !important; }
}

@media (max-width: 720px) {
  .titlebar { height: 52px; gap: 10px; padding: 0 10px; }
  .brand-text small { display: none; }
  .pill span { display: none; }
  .pill { width: 34px; padding: 0; justify-content: center; border-radius: 10px; }
  .hide-sm { display: none !important; }
  .menubar { height: 34px; padding: 0 6px; }
  .menu-tab { padding: 5px 9px; font-size: 12.5px; }
  .ribbon-tabs { padding: 4px 8px 0; }
  .rtab { padding: 4px 9px 5px; font-size: 11.5px; }
  .ribbon { min-height: 56px; }
  .rb-label { display: none; }
  .tb { width: 32px; height: 32px; }
  .workspace { display: block; overflow-x: hidden; padding: 12px 8px 30px; }
  .page-wrap { width: 100%; max-width: 100%; }
  .paper {
    --page-w: 100%;
    --page-min-h: auto;
    --page-pad: 18px;
    --doc-font-size: 15.5px;
    --doc-line: 1.7;
    width: 100% !important;
    max-width: 100%;
    min-height: calc(100dvh - 240px);
    border-radius: 6px;
  }
  .page-break { margin-left: -18px; margin-right: -18px; }
  .ruler { display: none; }
  .statusbar { height: 30px; font-size: 10.5px; padding: 0 10px; }
  input[type="range"] { width: 64px; }
  .menu-layer .menu-panel {
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: 8px;
    width: auto;
    max-width: none;
    min-width: 0;
    max-height: 68vh;
    border-radius: 18px;
    animation: sheetIn .2s cubic-bezier(.2,.8,.3,1);
  }
  @keyframes sheetIn { from { opacity: 0; transform: translateY(18px); } }
  .modal { width: calc(100vw - 20px); border-radius: 16px; max-height: 88vh; }
  .modal-body { padding: 14px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .symbol-grid { grid-template-columns: repeat(8, 1fr); }
  .toast-layer { bottom: 38px; }
}

@media (max-width: 420px) {
  .brand-mark { width: 28px; height: 28px; font-size: 15px; }
  .brand-text strong { font-size: 13px; }
  .title-actions { gap: 4px; }
}

/* ---------------- print ---------------- */

@media print {
  @page { margin: 0; }

  html, body { overflow: visible !important; height: auto !important; background: #fff !important; }
  .titlebar, .menubar, .ribbon-wrap, .statusbar,
  .sidebar, .split-preview, .menu-layer, .modal-layer, .toast-layer { display: none !important; }
  .app { display: block; height: auto; }
  .workspace { display: block; overflow: visible; padding: 0; background: #fff; }
  .page-wrap { display: block; }
  .ruler { display: none !important; }
  .paper {
    width: auto; min-height: 0;
    padding: 0;
    box-shadow: none;
    background: #fff;
    zoom: 1 !important;
  }
  .page-break {
    break-before: page;
    page-break-before: always;
    height: 0; margin: 0; border: 0; background: none;
  }
  .page-break::after { display: none; }
  .doc-body { min-height: 0; }
  mark.hit { background: none !important; }
}

/* ---------------- bentuk gambar ---------------- */

.shape-wrap {
  display: inline-block;
  margin: 6px 8px 6px 0;
  padding: 4px;
  border-radius: 6px;
  vertical-align: middle;
  cursor: pointer;
  line-height: 0;
  transition: box-shadow .15s;
}
.shape-wrap svg { display: block; max-width: 100%; height: auto; }
.shape-wrap:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.shape-wrap.shape-selected { box-shadow: 0 0 0 2px var(--accent); }

/* tombol hapus untuk objek yang dipilih */
.objek-tools {
  position: fixed;
  z-index: 70;
  display: flex;
  gap: 4px;
}
.objek-tools[hidden] { display: none; }
.objek-tools .objek-ubah {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 99px;
  background: #4b3fc4;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(30, 20, 15, .6);
}
.objek-tools .objek-ubah[hidden] { display: none; }
.objek-tools .objek-ubah .lucide { width: 16px; height: 16px; stroke-width: 2.2; }
.objek-tools .objek-hapus {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 99px;
  background: #b3402b;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(30, 20, 15, .6);
}
.objek-tools .objek-hapus:active { transform: translateY(1px); }
.objek-tools .objek-hapus .lucide { width: 16px; height: 16px; stroke-width: 2.2; }

/* bilah cepat tabel */
.tabel-tools {
  position: fixed;
  z-index: 72;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: 0 10px 24px -12px rgba(30, 20, 15, .5);
}
.tabel-tools[hidden] { display: none; }
.tabel-tools .tt-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.tabel-tools .tt-btn:active { background: var(--accent-soft); color: var(--accent-ink); }
.tabel-tools .tt-btn .lucide { width: 17px; height: 17px; stroke-width: 2; }

/* pegangan sudut untuk ukuran dan pegangan geser */
.objek-handles {
  position: fixed;
  z-index: 71;
  pointer-events: none;
}
.objek-handles[hidden] { display: none; }
.objek-handles .oh-resize {
  position: absolute;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(20, 16, 30, .35);
  pointer-events: auto;
  touch-action: none;
  cursor: nwse-resize;
}
.objek-handles .oh-nw { left: -10px; top: -10px; cursor: nwse-resize; }
.objek-handles .oh-ne { right: -10px; top: -10px; cursor: nesw-resize; }
.objek-handles .oh-sw { left: -10px; bottom: -10px; cursor: nesw-resize; }
.objek-handles .oh-se { right: -10px; bottom: -10px; cursor: nwse-resize; }
.objek-handles .oh-move {
  position: absolute;
  bottom: -17px;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  box-shadow: 0 4px 12px -2px rgba(30, 20, 15, .45);
}
.objek-handles .oh-move .lucide { width: 15px; height: 15px; stroke-width: 2.4; }
.objek-handles.sedang-geser .oh-move { cursor: grabbing; }

body.objek-ukur-aktif, body.objek-ukur-aktif * { cursor: nwse-resize !important; user-select: none !important; }
body.objek-geser-aktif, body.objek-geser-aktif * { cursor: grabbing !important; user-select: none !important; }

.objek-drop-line {
  position: fixed;
  height: 3px;
  margin-top: -1.5px;
  background: var(--accent);
  border-radius: 99px;
  z-index: 75;
  pointer-events: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.objek-drop-line[hidden] { display: none; }

/* bilah pilih baris/kolom di tepi tabel */
.tabel-pilih {
  position: fixed;
  z-index: 72;
  pointer-events: none;
}
.tabel-pilih[hidden] { display: none; }
.tabel-pilih .tp-row,
.tabel-pilih .tp-col {
  position: absolute;
  padding: 0;
  border: 0;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 4px;
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
}
.tabel-pilih .tp-row { left: -20px; width: 14px; }
.tabel-pilih .tp-col { top: -18px; height: 12px; }
.tabel-pilih .tp-row:hover,
.tabel-pilih .tp-col:hover,
.tabel-pilih .tp-row:active,
.tabel-pilih .tp-col:active { background: var(--accent); }
.doc-table td.tbl-blok,
.doc-table th.tbl-blok {
  background: color-mix(in srgb, var(--accent) 22%, #fff) !important;
}

.shape-wrap.objek-terpilih,
figure.objek-terpilih,
.page-break.objek-terpilih,
img.objek-terpilih {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
img.objek-terpilih { outline-offset: 0; }
figure.objek-terpilih { cursor: pointer; }
figure { max-width: 100%; }
figure svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.doc-table { max-width: 100%; }
table.doc-table.objek-terpilih { outline: 2px solid var(--accent); outline-offset: 3px; }

.markup-note { border-radius: 2px; }

/* empty state / drag */
.paper.drag-over { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* ---------------- bilah objek kontekstual ---------------- */

/* tombol aksi yang isinya berubah mengikuti jenis objek terpilih */
.objek-tools .objek-aksi {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(30, 20, 15, .5);
}
.objek-tools .objek-aksi:active { transform: translateY(1px); }
.objek-tools .objek-aksi .lucide { width: 15px; height: 15px; stroke-width: 2.1; }
.objek-tools .objek-aksi.objek-hapus { border: 0; background: #b3402b; color: #fff; }

/* tombol riwayat yang tidak bisa dipakai */
.tb.nonaktif,
.tb:disabled { opacity: .4; cursor: default; }

/* ---------------- layar keluar ---------------- */

.exit-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f0e8;
  color: #2b2930;
  text-align: center;
  font-family: Inter, system-ui, sans-serif;
}
.exit-overlay .exit-card { max-width: 320px; }
.exit-overlay .exit-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #6a5ae0;
  color: #fff;
  font-family: Georgia, serif;
  font-size: 24px;
}
.exit-overlay h1 { font-size: 20px; margin: 0 0 8px; }
.exit-overlay p { font-size: 13.5px; color: #7b7785; margin: 0 0 20px; }
