:root {
  --paper: #fbf7ef;
  --ink: #2f271d;
  --muted: #756b5d;
  --line: #e4dccd;
  --coklat: #b57810;
  --ungu: #e1bee7;
  --abu: #9e9e9e;
  --putih: #ffffff;
  --hitam: #000000;
  --hijau: #03ff13;
  --merah: #ff0606;
  --kuning: #ffe600;
  --pill-kuning: #fff450;
  --pill-hijau: #4fff59;
  --pill-merah: #ff5252;
  --pill-coklat: #b57810;
  --akcent: #8c4a12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 14px;
}

button, select { font: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #fffdf8;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--coklat);
  color: white;
  font-size: 26px;
  font-family: "Noto Naskh Arabic", "Amiri", "Times New Roman", serif;
}

.topbar h1 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.topbar h1 span { font-weight: 400; color: var(--akcent); }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.brand-note { color: var(--muted); font-size: 12px; white-space: nowrap; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: #fffdf8;
}

.toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.toolbar select, .toolbar button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.toolbar button:hover, .toolbar select:hover { border-color: var(--coklat); }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; padding: 7px 14px; }
.segmented button.active { background: var(--coklat); color: white; }

.badge { color: var(--muted); font-size: 12px; }
.badge.ok { color: #1f7a2e; font-weight: 600; }
.badge.warn { color: #a85600; font-weight: 600; }
.badge.bad { color: #b31212; font-weight: 600; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  padding: 20px 24px 40px;
  align-items: start;
}

.canvas-wrap {
  min-width: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(70, 45, 15, .05);
}

.canvas-head {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.canvas-head strong { display: block; font-size: 15px; }
.canvas-head span { color: var(--muted); font-size: 12px; }
.legend-mini { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 11px; }
.legend-mini span { display: inline-flex; align-items: center; gap: 4px; }

.canvas { padding: 22px 18px 28px; display: flex; flex-direction: column; gap: 24px; }

.ayat {
  direction: rtl;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdfaf3;
  overflow-x: auto;
  min-height: 122px;
}
.ayat:hover { background: #fbf5e8; }

/* ---------- Kartu ---------- */
.card {
  flex: 0 0 auto;
  position: relative;
  height: 100px;
  min-width: 70px;
  padding: 0 7px;
  background: var(--card-bg, var(--coklat));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(60, 40, 10, .22);
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(60, 40, 10, .28); }
.card.shape-oval { border-radius: 50px; min-width: 84px; padding: 0 12px; }
.card.shape-daun { border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-left-radius: 28px; border-bottom-right-radius: 28px; }
.card.shape-lingkaran {
  width: 50px; min-width: 50px; border-radius: 50%; padding: 0;
  outline: 1px solid white; outline-offset: -1px;
}
.card.bg-putih { border: 1px solid var(--line); }

.card.is-selected { outline: 3px solid #2d6cdf; outline-offset: 3px; z-index: 5; }
.card.is-amil { outline: 3px solid #12a019; outline-offset: 3px; z-index: 4; }
.card.is-dependent { outline: 3px solid #e0b500; outline-offset: 3px; z-index: 4; }

.row-ind, .row-eng {
  height: 25px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1.05; color: #1b140c;
  text-align: center; white-space: nowrap;
}
.row-eng { font-size: 11px; }

.row-ar {
  height: 50px;
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 4px;
  direction: rtl;
  white-space: nowrap;
}

.token {
  direction: rtl;
  font-family: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", "Times New Roman", serif;
  font-size: 27px;
  line-height: 1;
  color: var(--token-color, #000);
}
.token.type-pill {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px; border-radius: 28px; padding: 0 7px;
  background: var(--pill-bg, #fff450);
  font-size: 24px;
}
.token.type-pill { color: var(--token-color, #000000); }
.token.has-border { border: 1px solid white; box-shadow: 0 0 0 .5px white; }

.circle {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: .5px solid white;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  z-index: 3;
}
.circle.kuning { left: -5px; bottom: 10px; background: var(--pill-kuning); }
.circle.hijau { right: -5px; top: 8px; background: var(--pill-hijau); }
.circle.merah { right: -5px; top: 8px; background: var(--pill-merah); }

/* ---------- Panel samping ---------- */
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(70, 45, 15, .05);
}
.panel h2 { margin: 0 0 12px; font-size: 15px; }
.panel h3 { margin: 14px 0 6px; font-size: 12px; color: var(--akcent); text-transform: uppercase; letter-spacing: .4px; }
.panel h3 em { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.legend-row { display: flex; align-items: center; gap: 9px; margin: 6px 0; font-size: 12px; }
.legend-row b { font-weight: 600; }
.swatch {
  flex: 0 0 auto; width: 22px; height: 18px;
  display: inline-grid; place-items: center;
  border: 1px solid rgba(0,0,0,.15);
  font-size: 12px; font-weight: 700;
}
.shape-kotak { border-radius: 0; background: var(--coklat); }
.shape-oval { border-radius: 50%; background: var(--coklat); width: 26px; }
.shape-daun { background: var(--coklat); border-radius: 0 0 9px 9px; }
.shape-lingkaran { background: var(--coklat); border-radius: 50%; width: 18px; height: 18px; outline: 1px solid #999; }
.bg-coklat { background: var(--coklat); } .bg-ungu { background: var(--ungu); }
.bg-abu { background: var(--abu); } .bg-putih { background: white; }
.font-hitam { color: #000; } .font-hijau { color: #00c40b; }
.font-kuning { color: #c9a900; } .font-merah { color: #e00000; }
.pill-kuning { background: var(--pill-kuning); border-radius: 20px; }
.pill-putih { background: white; border-radius: 20px; }
.pill-coklat { background: var(--coklat); border-radius: 20px; outline: 1px solid white; box-shadow: 0 0 0 1px #bbb; }
.dot { flex: 0 0 auto; display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: .5px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.dot-kuning { background: var(--pill-kuning); } .dot-hijau { background: var(--pill-hijau); } .dot-merah { background: var(--pill-merah); }

.detail .empty { color: var(--muted); font-size: 13px; line-height: 1.5; }
.detail-word {
  font-family: "Noto Naskh Arabic", "Amiri", "Times New Roman", serif;
  font-size: 34px; line-height: 1.5; direction: rtl; text-align: right;
}
.detail-trans { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.detail-row {
  display: grid; grid-template-columns: 118px 1fr;
  gap: 8px; padding: 7px 0; border-top: 1px solid var(--line);
  font-size: 12px; line-height: 1.45;
}
.detail-row .key { color: var(--muted); }
.detail-row .val b { font-weight: 600; }
.chip {
  display: inline-block; padding: 2px 7px; border-radius: 12px;
  background: #f3ecdf; margin: 2px 3px 2px 0; font-size: 11px;
}
.chip.hijau { background: #d8ffdc; } .chip.kuning { background: #fff6b8; }
.chip.merah { background: #ffd9d9; } .chip.hitam { background: #eeeae2; }
.link-btn {
  border: 0; background: none; padding: 0;
  color: #8c4a12; text-decoration: underline; cursor: pointer; font-size: 12px;
}
.catatan { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: #fff3d6; color: #7a4b00; font-size: 12px; }
.issue-list { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.6; }

@media (max-width: 1050px) {
  main { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .side .panel { flex: 1 1 300px; }
}

@media print {
  body { background: white; }
  .topbar, .toolbar, .canvas-head, .side { display: none !important; }
  main { display: block; padding: 0; }
  .canvas-wrap { border: 0; box-shadow: none; }
  .canvas { padding: 0; gap: 10px; }
  .ayat { flex-wrap: wrap; background: white; overflow: visible; gap: 4px; margin-bottom: 12px; border-bottom: 1px dashed #bbb; }
  .card { outline: 1px dashed #bbb !important; box-shadow: none; break-inside: avoid; }
}
