@font-face { font-family: "UI"; src: url(../fonts/BeVietnamPro-Regular.woff2) format("woff2"); font-weight: 400; }
@font-face { font-family: "UI"; src: url(../fonts/BeVietnamPro-Medium.woff2) format("woff2"); font-weight: 500; }
@font-face { font-family: "UI"; src: url(../fonts/BeVietnamPro-Bold.woff2) format("woff2"); font-weight: 700; }

:root {
  --yellow: #F5D547; --yellow-l: #F9E691; --yellow-d: #7A6000;
  --ink: #121212; --bg: #F7F6F2; --white: #fff; --gray: #6B675E; --line: #E4E1D8;
  --cobalt: #2F5BEA; --warn: #B3261E;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 "UI", system-ui, sans-serif; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; background: var(--ink); color: var(--white);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 400; color: #bdb9ae; }
.brand .dot {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--yellow); color: var(--ink); font-weight: 700;
}

main { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(340px, 800px); gap: 24px; padding: 20px; max-width: 1560px; margin: 0 auto; }
@media (max-width: 860px) { main { grid-template-columns: 1fr; } .stage { position: static !important; } }

.stage { position: sticky; top: 76px; align-self: start; }
.canvas-wrap {
  position: relative; width: 100%; max-width: calc((100vh - 150px) * 0.8); margin: 0 auto;
  aspect-ratio: 4 / 5; border-radius: 6px; overflow: hidden; background: #2a2a2a;
  box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(0,0,0,.12);
}
#frame { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#frame.dragging { cursor: grabbing; }
.canvas-wrap.over { outline: 3px dashed var(--yellow); outline-offset: -6px; }
.drop-hint {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); pointer-events: none;
  text-align: center; color: var(--yellow-l); font-weight: 500; font-size: 15px;
  background: rgba(0,0,0,.45); padding: 12px 18px; border-radius: 6px;
}
.drop-hint small { color: #cfcabe; font-weight: 400; }
.hint { text-align: center; color: var(--gray); font-size: 12px; margin: 8px 0 0; }
.warnings { list-style: none; padding: 0; margin: 10px auto 0; max-width: calc((100vh - 150px) * 0.8); }
.warnings li { color: var(--warn); background: #FBEDEB; border-radius: 4px; padding: 6px 10px; margin-top: 6px; font-size: 13px; }

.panel { display: flex; flex-direction: column; gap: 14px; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--white); padding: 12px 14px 14px; }
legend { font-weight: 700; padding: 0 6px; }
label { display: block; font-weight: 500; margin-top: 8px; }
label small { font-weight: 400; color: var(--gray); }
input:not([type]), input[inputmode], textarea, select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px;
  font: 400 14px/1.4 "UI", system-ui, sans-serif; color: var(--ink); background: #FCFBF8;
}
#time, #date, #num { font-family: ui-monospace, "JetBrains Mono", monospace; }
textarea { resize: vertical; white-space: pre; overflow-x: auto; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--yellow); border-color: var(--yellow-d); }
input[type=color] { display: block; width: 100%; height: 36px; margin-top: 4px; border: 1px solid var(--line); border-radius: 4px; padding: 2px; background: #FCFBF8; }
.grid3 { display: grid; grid-template-columns: 0.7fr 1fr 1.3fr; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

.slider { display: grid; grid-template-columns: 80px 1fr 52px; align-items: center; gap: 8px; }
.slider input { width: 100%; accent-color: var(--yellow-d); }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--gray); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--white); color: var(--ink); font: 500 14px "UI", system-ui, sans-serif;
}
label.btn { margin: 0; }
.btn:hover:not(:disabled) { background: var(--yellow-l); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--yellow); border-color: var(--yellow); font-weight: 700; }
.btn.primary:hover { background: var(--yellow-l); }
.btn.small { margin-top: 10px; padding: 6px 10px; font-size: 13px; }

.drop {
  display: block; margin: 0; padding: 14px; text-align: center; border: 1.5px dashed #cfcabe; border-radius: 6px;
  color: var(--gray); cursor: pointer; font-weight: 400;
}
.drop:hover, .drop.over { border-color: var(--yellow-d); background: #FFFBEA; color: var(--ink); }
.crop canvas { max-width: 100%; border: 1px solid var(--line); border-radius: 3px; margin-top: 4px; background: #fff; }
.status { margin-top: 8px; font-size: 13px; }
.status .ok { color: #1F6B2E; }
.status .bad { color: var(--warn); }

.src { font-size: 12px; color: var(--gray); margin-top: 4px; }
.src b { font-weight: 500; color: var(--ink); }
.src.weak b { color: var(--yellow-d); }
.src.bad { color: var(--warn); }
.note { font-size: 12px; color: var(--gray); margin: 6px 0 0; }

/* ảnh chụp + ô nhập */
.split { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 16px; }
@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } }
.shot-col { position: sticky; top: 76px; align-self: start; }
.drop small { color: var(--gray); }
.shot { margin-top: 10px; }
.shot-scroll { max-height: calc(100vh - 230px); overflow: auto; border: 1px solid var(--line); border-radius: 4px; background: #eee; }
#shotCanvas { display: block; width: 100%; cursor: zoom-in; }
.shot-scroll.zoom #shotCanvas { width: 230%; cursor: zoom-out; }
.shot-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.shot-tools .btn.small { margin-top: 0; }
.legend { font-size: 11px; color: var(--gray); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 4px; }
.lg-title { border: 2px solid #E0B800; } .lg-desc { border: 2px solid var(--cobalt); }
.lg-posts { border: 2px solid #1F8A3B; } .lg-time { border: 2px solid #8a8a8a; } .lg-warn { background: rgba(255,120,40,.55); }
.crop canvas { max-width: 150px; }

.report { list-style: none; margin: 6px 0 4px; padding: 0; font-size: 13px; }
.report li { padding: 3px 0 3px 22px; position: relative; }
.report li::before { position: absolute; left: 2px; top: 3px; }
.report .ok::before { content: "✓"; color: #1F6B2E; }
.report .soat::before { content: "!"; color: #C25E00; font-weight: 700; left: 6px; }
.report .bad { color: var(--warn); }
.report .bad::before { content: "✕"; color: var(--warn); }
.report .info { color: var(--gray); }
.report .info::before { content: "i"; color: var(--gray); left: 6px; font-style: italic; }

/* tô chữ cần soát */
.hl-wrap { position: relative; margin-top: 4px; background: #FCFBF8; border-radius: 4px; }
.hl-wrap .hl-input { position: relative; z-index: 1; background: transparent !important; margin-top: 0 !important; }
.hl-back {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  border: 1px solid transparent; padding: 8px 10px; color: transparent;
  font: 400 14px/1.4 "UI", system-ui, sans-serif; white-space: pre;
}
.hl-back mark { color: transparent; background: rgba(255,140,40,.45); border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,140,40,.45); }
.hl-wrap.unread .hl-input { border-color: var(--warn); }
#time + .hl-back, .hl-wrap:has(#time) .hl-back, .hl-wrap:has(#num) .hl-back, .hl-wrap:has(#date) .hl-back { font-family: ui-monospace, "JetBrains Mono", monospace; }

/* ô cần kiểm tra */
.hl-wrap.check .hl-input { border-color: #E07B00; box-shadow: 0 0 0 1px #E07B00; }
.check-note { font-size: 12px; color: #B05F00; margin-top: 3px; font-weight: 500; }
.check-note:empty { display: none; }
.status { font-size: 13px; color: var(--gray); }
.status:empty { display: none; }
#shotCrop canvas { margin-top: 6px; }

/* nâng cao */
details.adv { border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
details.adv > summary { cursor: pointer; font-weight: 700; padding: 12px 14px; list-style: none; display: flex; justify-content: space-between; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::after { content: "▸"; color: var(--gray); }
details.adv[open] > summary::after { content: "▾"; }
details.adv > fieldset { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
