:root {
      --bg: #111009;
      --panel: #1c1609;
      --panel2: #251d0c;
      --border: rgba(210, 165, 80, 0.18);
      --accent: #d4a44c;
      --accent2: #f0c97a;
      --muted: #7a6340;
      --text: #e8d5b0;
      --hijau: #4cde4c;
      --biru: #50b4ff;
    }

    /* DEKLARASI FONT LOKAL */
    @font-face {
      font-family: 'Gloria Hallelujah';
      src: url('fonts/GloriaHallelujah-Regular.ttf');
    }

    @font-face {
      font-family: 'HandwritingCR 2';
      src: url('fonts/HandwritingCR-2.ttf');
    }

    @font-face {
      font-family: 'My Handwriting';
      src: url('fonts/My_handwriting.ttf');
    }

    @font-face {
      font-family: 'My Hands';
      src: url('fonts/MyHandsareHoldingYou.ttf');
    }

    @font-face {
      font-family: 'Shadows Into Light';
      src: url('fonts/ShadowsIntoLight-Regular.ttf');
    }

    *,
    *::before,
    *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: 'Patrick Hand', sans-serif;
      font-size: 15px;
      height: 100vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    header {
      background: var(--panel);
      border-bottom: 1px solid var(--border);
      height: 50px;
      display: flex;
      align-items: center;
      padding: 0 20px;
      gap: 16px;
      flex-shrink: 0;
      box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
      z-index: 20;
    }

    .logo {
      font-family: 'Dancing Script', cursive;
      font-size: 22px;
      font-weight: 700;
      color: var(--accent2);
    }

    .logo em {
      color: var(--accent);
      font-style: normal;
    }

    .live-pill {
      display: flex;
      align-items: center;
      gap: 5px;
      background: rgba(80, 180, 80, 0.12);
      border: 1px solid rgba(80, 200, 80, 0.25);
      border-radius: 20px;
      padding: 2px 10px;
      font-size: 11px;
      color: #7ee87e;
    }

    .live-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #4cde4c;
      animation: blink 1.4s ease-in-out infinite;
    }

    @keyframes blink {

      0%,
      100% {
        opacity: 1
      }

      50% {
        opacity: 0.3
      }
    }

    .hdr-right {
      margin-left: auto;
      font-size: 11px;
      color: var(--muted);
    }

    .app {
      flex: 1;
      display: flex;
      overflow: hidden;
    }

    .sidebar {
      width: 320px;
      flex-shrink: 0;
      background: var(--panel);
      border-right: 1px solid var(--border);
      overflow-y: auto;
      display: flex;
      flex-direction: column;
    }

    .sidebar::-webkit-scrollbar {
      width: 4px;
    }

    .sidebar::-webkit-scrollbar-thumb {
      background: var(--panel2);
      border-radius: 2px;
    }

    .sec {
      border-bottom: 1px solid var(--border);
      padding: 13px 15px;
    }

    .sec-title {
      font-size: 9.5px;
      font-weight: 700;
      letter-spacing: 1.2px;
      text-transform: uppercase;
      color: var(--muted);
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .sec-title::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }

    .field {
      margin-bottom: 12px;
    }

    .field label {
      display: block;
      font-size: 11px;
      color: var(--muted);
      margin-bottom: 4px;
    }

    input[type=text],
    input[type=number],
    textarea,
    select {
      width: 100%;
      background: var(--panel2);
      border: 1px solid var(--border);
      color: var(--text);
      font-family: 'Patrick Hand', sans-serif;
      font-size: 14px;
      border-radius: 7px;
      padding: 7px 10px;
      outline: none;
      transition: border-color .2s;
      resize: vertical;
    }

    input[type=text]:focus,
    input[type=number]:focus,
    textarea:focus,
    select:focus {
      border-color: var(--accent);
    }

    textarea {
      min-height: 80px;
      line-height: 1.55;
    }

    input[type=number]::-webkit-inner-spin-button,
    input[type=number]::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    input[type=number] {
      -moz-appearance: textfield;
      width: 45px;
      text-align: center;
      font-family: sans-serif;
      font-size: 11px;
      padding: 4px;
      margin-left: 5px;
    }

    .font-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 5px;
      margin-bottom: 10px;
    }

    .fc {
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 7px 6px;
      cursor: pointer;
      background: var(--panel2);
      transition: all .15s;
      text-align: center;
      user-select: none;
    }

    .fc:hover {
      border-color: var(--accent);
    }

    .fc.active {
      border-color: var(--accent);
      background: rgba(212, 164, 76, 0.13);
    }

    .fc .prev {
      font-size: 19px;
      line-height: 1.3;
      color: var(--text);
    }

    .fc .fn {
      font-size: 9px;
      color: var(--muted);
      margin-top: 2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .upload-zone {
      border: 1.5px dashed var(--border);
      border-radius: 9px;
      padding: 11px;
      text-align: center;
      cursor: pointer;
      position: relative;
      color: var(--muted);
      font-size: 12px;
      transition: all .2s;
      margin-bottom: 10px;
    }

    .upload-zone:hover {
      border-color: var(--accent);
      color: var(--accent2);
    }

    .upload-zone input {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
      width: 100%;
      height: 100%;
    }

    .upload-zone .ic {
      font-size: 18px;
      margin-bottom: 3px;
    }

    .color-row {
      display: flex;
      gap: 7px;
      align-items: center;
      flex-wrap: wrap;
      margin-bottom: 10px;
    }

    .cdot {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      border: 2px solid transparent;
      cursor: pointer;
      transition: all .15s;
      position: relative;
      flex-shrink: 0;
    }

    .cdot:hover {
      transform: scale(1.15);
    }

    .cdot.active {
      border-color: var(--accent2);
      box-shadow: 0 0 0 2px rgba(240, 201, 122, .4);
    }

    /* --- CUSTOM COLOR PICKER (WHEEL) --- */
    .cpicker {
      /* width: 26px; */
      /* height: 26px; */
      padding: 0;
      border: 0px solid transparent;
      /* Mengikuti gaya .cdot */
      border-radius: 100%;
      cursor: pointer;
      /* Ini adalah warna pelanginya */
      background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
      overflow: hidden;
    }

    .cpicker::-webkit-color-swatch-wrapper {
      padding: 0;
    }

    /* Trik utamanya ada di sini: Menyembunyikan blok warna bawaan browser */
    .cpicker::-webkit-color-swatch {
      border: none;
      opacity: 0;
      /* Membuat lapisan hitam menjadi tembus pandang */
    }

    /* Dukungan untuk browser Firefox */
    .cpicker::-moz-color-swatch {
      border: none;
      opacity: 0;
    }

    .sl-row {
      display: flex;
      align-items: center;
      gap: 7px;
    }

    input[type=range] {
      flex: 1;
      accent-color: var(--accent);
      background: transparent;
      border: none;
      padding: 0;
    }

    .dl-btn {
      width: 100%;
      padding: 11px;
      background: linear-gradient(135deg, var(--accent), var(--accent2));
      color: #1a0f00;
      border: none;
      border-radius: 9px;
      font-size: 14px;
      font-weight: 700;
      font-family: inherit;
      cursor: pointer;
      transition: all .2s;
      box-shadow: 0 3px 14px rgba(212, 164, 76, .3);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
    }

    .dl-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 5px 22px rgba(212, 164, 76, .5);
    }

    .btn-kalibrasi {
      background: #4cde4c;
      color: #000;
      box-shadow: 0 3px 14px rgba(76, 222, 76, 0.2);
    }

    .btn-kalibrasi:disabled {
      background: #333;
      color: #666;
      cursor: not-allowed;
      box-shadow: none;
    }

    .btn-kalibrasi-tabel {
      background: linear-gradient(135deg, #ff8c00, #e066ff) !important;
      color: #fff !important;
      box-shadow: 0 3px 14px rgba(255, 140, 0, 0.25);
    }

    .btn-kalibrasi-tabel:hover {
      box-shadow: 0 5px 22px rgba(255, 140, 0, 0.5);
    }

    .btn-kalibrasi-tabel:disabled {
      background: #333 !important;
      color: #666 !important;
      cursor: not-allowed;
      box-shadow: none;
    }

    .btn-kalibrasi-tabel.btn-aktif-tabel {
      background: linear-gradient(135deg, #4cde4c, #2ecc71) !important;
      color: #000 !important;
      box-shadow: 0 3px 14px rgba(76, 222, 76, 0.3);
      animation: pulse-glow 2s ease-in-out infinite;
    }

    @keyframes pulse-glow {
      0%, 100% { box-shadow: 0 3px 14px rgba(76, 222, 76, 0.3); }
      50% { box-shadow: 0 3px 22px rgba(76, 222, 76, 0.6); }
    }

    #panelNavKalibrasi {
      display: none;
      background: rgba(0, 0, 0, 0.3);
      border: 1px dashed var(--biru);
      padding: 10px;
      border-radius: 7px;
      margin-top: 10px;
    }

    .nav-grup {
      display: flex;
      gap: 5px;
      margin-top: 10px;
    }

    .btn-nav {
      flex: 1;
      padding: 8px;
      background: #333;
      color: #fff;
      border: 1px solid #555;
      border-radius: 6px;
      cursor: pointer;
      font-size: 11px;
      transition: 0.2s;
    }

    .btn-nav:hover {
      background: #444;
    }

    .btn-nav.aktif {
      background: var(--biru);
      color: #000;
      border-color: var(--biru);
      font-weight: bold;
    }

    .btn-nav:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .btn-selesai {
      background: var(--hijau);
      color: #000;
      font-weight: bold;
    }

    #teksPetunjuk {
      font-size: 12px;
      font-weight: bold;
      color: var(--biru);
      text-align: center;
      margin-bottom: 5px;
      line-height: 1.4;
    }

    .panel-presisi {
      background: var(--panel2);
      padding: 12px;
      border-radius: 7px;
      border: 1px solid var(--border);
      margin-bottom: 10px;
    }

    .canvas-wrap {
      flex: 1;
      overflow: auto;
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 30px 20px 60px;
      background: radial-gradient(ellipse at 50% 20%, #1f1508 0%, #070501 100%);
    }

    .canvas-wrap::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    .canvas-wrap::-webkit-scrollbar-thumb {
      background: #251a08;
      border-radius: 3px;
    }

    #myCanvas {
      display: block;
      border-radius: 2px;
      box-shadow: 0 30px 80px rgba(0, 0, 0, .75), 0 0 0 1px rgba(255, 255, 255, .04);
      transition: cursor 0.2s;

      max-width: 100%;
      max-height: 85vh;
      object-fit: contain;
    }

    #myCanvas.mode-ukur {
      cursor: crosshair;
    }

    /* --- DESAIN KHUSUS TOMBOL ZOOM --- */
    .zoom-grup {
      display: flex;
      gap: 5px;
      margin-top: 5px;
    }

    .zoom-btn {
      flex: 1;
      padding: 7px;
      background: var(--panel2);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: 6px;
      cursor: pointer;
      font-size: 11px;
      font-weight: bold;
      font-family: inherit;
      transition: all 0.2s;
    }

    .zoom-btn:hover {
      border-color: var(--accent);
      color: var(--accent2);
    }

    .zoom-label {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(212, 164, 76, 0.1);
      border: 1px solid var(--accent);
      color: var(--accent);
      border-radius: 6px;
      font-size: 12px;
      font-weight: bold;
    }

    #myCanvas {
      transition: width 0.2s ease-out;
    }

    #myCanvas.mode-ukur {
      cursor: crosshair;
      /* Pointer default saat kalibrasi */
    }

    #myCanvas.mode-ukur.can-drag {
      cursor: ns-resize;
      /* Pointer panah atas-bawah saat di atas garis horizontal */
    }

    #myCanvas.mode-ukur.can-drag-v {
      cursor: ew-resize;
      /* Pointer panah kiri-kanan saat di atas garis vertikal */
    }

    /* --- TOMBOL BANTUAN MENGAPUNG --- */
    .btn-bantuan {
      position: fixed;
      right: 30px;
      bottom: 30px;
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: var(--accent);
      color: #000;
      font-size: 24px;
      font-weight: bold;
      border: none;
      font-family: inherit;
      cursor: pointer;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
      z-index: 99;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.2s, box-shadow 0.2s;
    }

    .btn-bantuan:hover {
      transform: scale(1.1);
      box-shadow: 0 6px 20px rgba(212, 164, 76, 0.6);
    }

    /* --- MODAL DIALOG --- */
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.8);
      z-index: 1000;
      display: none;
      /* Disembunyikan secara default */
      align-items: center;
      justify-content: center;
      backdrop-filter: blur(3px);
    }

    .modal-konten {
      background: var(--panel);
      border: 1px solid var(--border);
      width: 90%;
      max-width: 600px;
      max-height: 80vh;
      border-radius: 10px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
      font-family: sans-serif;
      /* Menggunakan font standar agar mudah dibaca */
    }

    .modal-header {
      padding: 15px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .modal-header h2 {
      color: var(--accent2);
      font-size: 18px;
      margin: 0;
      font-family: 'Patrick Hand', cursive;
      letter-spacing: 1px;
    }

    .btn-tutup {
      background: transparent;
      color: var(--text);
      border: none;
      font-size: 20px;
      cursor: pointer;
      transition: 0.2s;
    }

    .btn-tutup:hover {
      color: #ff4c4c;
      transform: scale(1.2);
    }

    .modal-body {
      padding: 20px;
      overflow-y: auto;
      color: #ddd;
      font-size: 14px;
      line-height: 1.6;
    }

    .modal-body::-webkit-scrollbar {
      width: 6px;
    }

    .modal-body::-webkit-scrollbar-thumb {
      background: var(--panel2);
      border-radius: 3px;
    }

    .modal-body h3 {
      color: var(--accent);
      margin-top: 20px;
      margin-bottom: 8px;
      font-size: 15px;
      border-bottom: 1px dashed var(--border);
      padding-bottom: 5px;
    }

    .modal-body h3:first-child {
      margin-top: 0;
    }

    .modal-body ol,
    .modal-body ul {
      padding-left: 20px;
      margin-bottom: 15px;
    }

    .modal-body li {
      margin-bottom: 8px;
    }

    .modal-body code {
      background: rgba(212, 164, 76, 0.2);
      color: var(--accent2);
      padding: 2px 6px;
      border-radius: 4px;
      font-family: monospace;
      font-size: 13px;
    }

    .toast-notif {
      position: fixed;
      top: 20px;
      /* Muncul dari atas */
      left: 50%;
      transform: translate(-50%, -100px);
      /* Tersembunyi di atas layar */
      background: var(--panel);
      border: 1px solid var(--accent);
      color: var(--accent2);
      padding: 10px 25px;
      border-radius: 30px;
      font-family: 'Patrick Hand', cursive;
      font-size: 16px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
      z-index: 9999;
      transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s;
      opacity: 0;
      pointer-events: none;
      /* Agar tidak menghalangi klik di bawahnya */
    }

    .toast-notif.muncul {
      transform: translate(-50%, 0);
      opacity: 1;
    }
