/* ArthaSketch Lapangan — tanpa CDN, font sistem, offline */
:root {
  --ink: #1c1917; --ink2: #292524; --line: #44403c; --mute: #a8a29e; --paper: #f8fafc;
  --brand: #b45309; --brand2: #f59e0b; --brown: #7a4b24; --ok: #059669; --bad: #dc2626; --blue: #2563eb;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: #f5f5f4; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
.hidden { display: none !important; }
#app { display: flex; flex-direction: column; height: 100%; }

/* header */
#top { display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--sat)) 8px 6px; background: var(--ink); border-bottom: 1px solid var(--ink2); }
.proj { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; text-align: left; padding: 2px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand2), var(--brown)); display: grid; place-items: center; font-weight: 900; color: #fff; flex: none; font-size: 17px; }
.pt { display: flex; flex-direction: column; min-width: 0; }
.pt b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt small { font-size: 11px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.savedot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.savedot.busy { background: var(--brand2); } .savedot.err { background: var(--bad); }
.hbtn { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-radius: 10px; background: var(--ink2); font-size: 13px; font-weight: 700; flex: none; }
.hbtn.accent { background: var(--brand2); color: #1c1917; }
@media (max-width: 420px) { .hbtn span { display: none; } }

/* sub bar */
#sub { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: #231f1d; border-bottom: 1px solid #000; overflow-x: auto; scrollbar-width: none; }
#sub::-webkit-scrollbar { display: none; }
.seg { display: flex; background: var(--ink); border-radius: 10px; padding: 3px; flex: none; }
.seg button { padding: 7px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--mute); white-space: nowrap; }
.seg button.on { background: #f5f5f4; color: var(--ink); }
.chip { padding: 7px 10px; border-radius: 10px; background: var(--ink2); font-size: 12.5px; font-weight: 700; white-space: nowrap; flex: none; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 11.5px; color: #d6d3d1; white-space: nowrap; padding: 0 4px; font-variant-numeric: tabular-nums; }
.pill.warn { color: #fbbf24; font-weight: 700; }

/* stage */
#stage { position: relative; flex: 1; background: var(--paper); overflow: hidden; }
#cv { display: block; touch-action: none; position: absolute; inset: 0; }
.hint { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(330px, 86%); background: rgba(255, 255, 255, .94); border: 1px solid #e2e8f0; color: #334155; border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.45; box-shadow: 0 8px 30px rgba(0, 0, 0, .08); }
.hint b { color: #0f172a; }
.finish { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fbbf24; font-weight: 800; font-size: 13px; padding: 10px 16px; border-radius: 99px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); border: 1px solid #f59e0b88; white-space: nowrap; }
.zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.zoom button, .hist button { width: 42px; height: 42px; border-radius: 12px; background: rgba(28, 25, 23, .9); color: #fff; font-size: 20px; font-weight: 700; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
.hist { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; }
.flags { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.flag { padding: 9px 11px; border-radius: 12px; background: rgba(28, 25, 23, .85); color: #a8a29e; font-size: 12px; font-weight: 800; }
.flag.on { color: #34d399; }
#toast { position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%); background: #0f172a; color: #fff; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 12px; max-width: 90%; text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
#toast.on { opacity: 1; }

/* toolbar */
#tools { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 6px 6px calc(6px + var(--sab)); background: var(--ink); border-top: 1px solid var(--ink2); }
#tools button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border-radius: 12px; color: #d6d3d1; font-size: 11px; font-weight: 700; }
#tools button i { font-style: normal; font-size: 19px; line-height: 1.1; }
#tools button.on { background: var(--brand2); color: var(--ink); }
#tools button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* sheet */
#sheetWrap { position: fixed; inset: 0; background: rgba(12, 10, 9, .55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
#sheet { background: #fff; color: #1c1917; width: 100%; max-width: 560px; max-height: 92%; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0, 0, 0, .3); -webkit-user-select: text; user-select: text; }
#sheet.wide { max-width: 860px; }
@media (min-width: 700px) { #sheetWrap { align-items: center; } #sheet { border-radius: 20px; } }
.sh-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid #f0eeec; }
.sh-head h2 { margin: 0; font-size: 16px; flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sh-head h2 small { font-weight: 500; color: #78716c; font-size: 12px; }
#shClose { width: 34px; height: 34px; border-radius: 10px; background: #f5f5f4; font-size: 15px; }
#shBody { padding: 12px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; }
#shFoot { display: flex; gap: 8px; padding: 10px 16px calc(12px + var(--sab)); border-top: 1px solid #f0eeec; }
#shFoot:empty { display: none; }
#shFoot .btn { flex: 1; }
.tag { display: inline-block; padding: 3px 8px; border-radius: 7px; background: #1e293b; color: #fff; font-size: 12px; font-weight: 800; }
.tag.blue { background: #1d4ed8; } .tag.sky { background: #0284c7; } .tag.brown { background: var(--brown); }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: #57534e; }
.f input, .f select, .f textarea, .search { font: inherit; font-size: 16px; font-weight: 600; color: #1c1917; padding: 10px 12px; border: 1.5px solid #e7e5e4; border-radius: 12px; background: #fafaf9; width: 100%; outline: none; }
.f textarea { resize: vertical; font-weight: 500; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--brand2); background: #fff; }
.f.big input { font-size: 26px; font-weight: 800; padding: 12px 14px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.qchips { display: flex; flex-wrap: wrap; gap: 6px; }
.qchips button { padding: 7px 11px; border-radius: 9px; background: #f5f5f4; font-size: 13px; font-weight: 700; color: #44403c; border: 1px solid #e7e5e4; }
.qchips button.on { background: var(--ink); color: #fff; }
.note { margin: 0; font-size: 12px; color: #78716c; line-height: 1.45; }
.note.warn, .angles .warn { color: var(--bad); font-weight: 700; }
.row { display: flex; gap: 8px; } .row.wrap { flex-wrap: wrap; }
.btn { padding: 12px 14px; border-radius: 12px; font-weight: 800; font-size: 14px; background: #f5f5f4; color: #1c1917; }
.btn.primary { background: var(--brand2); color: #1c1917; }
.btn.ghost { background: #fff; border: 1.5px solid #e7e5e4; font-size: 13px; padding: 9px 12px; }
.btn.danger { color: var(--bad); } .btn.danger.ghost { border-color: #fecaca; }
.btn.block { width: 100%; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.chk input { width: 20px; height: 20px; }
h4 { margin: 6px 0 0; font-size: 13px; color: #44403c; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list button, .roomlist button { text-align: left; padding: 11px 12px; border-radius: 12px; background: #fafaf9; border: 1.5px solid #e7e5e4; font-weight: 700; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.list button small, .roomlist button small { font-weight: 500; color: #78716c; font-size: 11.5px; }
.list button.on, .roomlist button.on { border-color: var(--brand2); background: #fffbeb; }
.roomlist { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.roomlist button { flex: none; min-width: 110px; }
.roomlist .add { border-style: dashed; color: var(--brand); justify-content: center; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pgrid button { padding: 12px 6px; border-radius: 14px; background: #fafaf9; border: 1.5px solid #e7e5e4; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.pgrid button.on { border-color: var(--brand2); background: #fffbeb; }
.pgrid i { font-style: normal; font-size: 24px; } .pgrid b { font-size: 13px; } .pgrid span { font-size: 11px; color: #78716c; text-align: center; }
table.vol { width: 100%; border-collapse: collapse; font-size: 13px; }
table.vol td { padding: 6px 4px; border-bottom: 1px solid #f0eeec; } table.vol td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
canvas.prev { width: 100%; height: 190px; border-radius: 12px; border: 1px solid #e7e5e4; background: #fff; }
.photos .ph-row { display: flex; gap: 8px; overflow-x: auto; }
.photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; background: #eee; cursor: pointer; }
.ph-add { width: 72px; height: 72px; border-radius: 10px; border: 1.5px dashed #d6d3d1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.ph-add span { font-size: 11px; font-weight: 700; color: #78716c; }
.arc { display: flex; align-items: stretch; gap: 6px; margin-bottom: 6px; }
.arc .arc-main { flex: 1; text-align: left; padding: 10px 12px; border-radius: 12px; background: #fafaf9; border: 1.5px solid #e7e5e4; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.arc.on .arc-main { border-color: var(--brand2); background: #fffbeb; }
.arc .arc-main small { color: #78716c; font-size: 11.5px; }
.arc > button:not(.arc-main) { width: 44px; border-radius: 12px; background: #f5f5f4; }
.arc .danger { color: var(--bad); }
.warnbox { background: #fef2f2; color: #b91c1c; border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; line-height: 1.5; }
.okbox { background: #ecfdf5; color: #047857; border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 700; }
.exgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.btn.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: #fafaf9; border: 1.5px solid #e7e5e4; font-size: 20px; }
.btn.tile b { font-size: 14px; } .btn.tile small { font-size: 11.5px; font-weight: 500; color: #78716c; }
.exprev { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.exprev img { height: 150px; border: 1px solid #e7e5e4; border-radius: 6px; flex: none; }
.watext { width: 100%; height: 50vh; font: 13px/1.4 ui-monospace, Menlo, monospace; border: 1px solid #e7e5e4; border-radius: 10px; padding: 10px; }
ol.help { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.5; display: flex; flex-direction: column; gap: 8px; }

/* dialog & foto */
#dlgWrap { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .5); display: grid; place-items: center; padding: 20px; }
#dlg { background: #fff; color: #1c1917; border-radius: 18px; padding: 18px; max-width: 360px; width: 100%; }
#dlg p { margin: 0 0 16px; font-size: 14.5px; line-height: 1.5; }
.dlg-btns { display: flex; gap: 8px; justify-content: flex-end; }
.dlg-btns button { padding: 11px 16px; border-radius: 12px; font-weight: 800; background: #f5f5f4; }
.dlg-btns .danger { background: var(--bad); color: #fff; } .dlg-btns .primary { background: var(--brand2); }
#photoView { position: fixed; inset: 0; z-index: 55; background: #000; display: flex; flex-direction: column; }
#photoView img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.pv-btns { display: flex; gap: 8px; padding: 10px 12px calc(12px + var(--sab)); }
.pv-btns button { flex: 1; padding: 12px; border-radius: 12px; background: #292524; color: #fff; font-weight: 800; }
.pv-btns .danger { color: #fca5a5; }

/* cetak */
#printArea { display: none; }
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { overflow: visible; height: auto; background: #fff; }
  #app, #sheetWrap, #dlgWrap, #photoView { display: none !important; }
  #printArea { display: block; }
  #printArea img { display: block; width: 100%; height: auto; page-break-after: always; break-after: page; }
}
