/* Web Lab — một file CSS, không build tool. Mobile-first: trang chụp dùng trên điện thoại. */
:root {
  --bg: #0f1216; --panel: #171b21; --panel2: #1e242c; --line: #2a323c;
  --fg: #e6edf3; --dim: #93a1b1; --accent: #4da3ff; --ok: #3ddc97;
  --warn: #ffb454; --err: #ff6b6b; --r: 10px;
  font-synthesis-weight: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg); font: 15px/1.5 -apple-system, BlinkMacSystemFont,
  "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }

header.top {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header.top h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .2px; }
header.top .sp { flex: 1; }
header.top .crumb { color: var(--dim); font-size: 13px; }
main { padding: 16px; max-width: 1100px; margin: 0 auto; }
main.wide { max-width: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
        padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 14px; margin: 0 0 10px; color: var(--dim); font-weight: 600;
           text-transform: uppercase; letter-spacing: .6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sp { flex: 1; }
.dim { color: var(--dim); }
.small { font-size: 13px; }

button, .btn {
  background: var(--panel2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px; font-size: 14px; cursor: pointer;
  font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f;
                 font-weight: 600; }
button.danger { color: var(--err); }
button.big { padding: 14px 20px; font-size: 16px; }

input, select, textarea {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 14px; width: 100%;
}
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
input[type=range] { padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
         vertical-align: top; }
th { color: var(--dim); font-weight: 500; }
td.num, th.num { text-align: right; font-family: ui-monospace, Menlo, monospace; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px;
        border: 1px solid var(--line); background: var(--panel2); }
.pill.ok { color: var(--ok); border-color: #245c46; }
.pill.warn { color: var(--warn); border-color: #6a4a1c; }
.pill.err { color: var(--err); border-color: #6a2626; }
.pill.run { color: var(--accent); border-color: #1d4a77; }

.bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0;
           transition: width .3s ease; }

.toast-wrap { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60;
              display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
         border-radius: 8px; padding: 10px 12px; font-size: 14px; box-shadow: 0 8px 24px #0008; }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--err); }

.modal { position: fixed; inset: 0; background: #000b; display: grid; place-items: center;
         z-index: 100; padding: 16px; }
.modal .card { max-width: 420px; width: 100%; margin: 0; }

/* --- trang chụp --- */
.capture-wrap { display: grid; gap: 12px; }
#preview { width: 100%; border-radius: var(--r); background: #000; display: block;
           aspect-ratio: 3/4; object-fit: cover; }
.counter { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.counter small { font-size: 18px; color: var(--dim); font-weight: 500; }
.bands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.band { border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center;
        background: var(--panel2); cursor: pointer; }
.band.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.band b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.band span { font-size: 11px; color: var(--dim); }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.shots figure { margin: 0; position: relative; }
.shots img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px;
             border: 1px solid var(--line); display: block; }
.shots .x { position: absolute; top: 2px; right: 2px; background: #000a; border: none;
            color: #fff; border-radius: 99px; width: 20px; height: 20px; padding: 0;
            font-size: 12px; justify-content: center; }
.shots .w { position: absolute; bottom: 2px; left: 2px; font-size: 10px; background: #000a;
            border-radius: 4px; padding: 0 3px; color: var(--warn); }
.shutter { width: 76px; height: 76px; border-radius: 99px; background: #fff; border: 5px solid var(--panel2);
           margin: 0 auto; display: block; }
.shutter:active { transform: scale(.94); }

/* --- viewer --- */
.viewport { position: relative; width: 100%; height: min(72vh, 720px); background: #0b0e12;
            border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.viewport canvas { display: block; width: 100%; height: 100%; }
.vtools { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column;
          gap: 8px; background: #0f1216cc; backdrop-filter: blur(6px); padding: 10px;
          border: 1px solid var(--line); border-radius: 8px; max-width: 230px; }
.vtools .row { gap: 6px; }
.vtools button { padding: 5px 9px; font-size: 12px; }
.vhint { position: absolute; right: 10px; bottom: 10px; font-size: 12px; color: var(--dim);
         background: #0f1216cc; padding: 6px 9px; border-radius: 6px; }
.split { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }

.log { background: #0b0e12; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
       height: 220px; overflow: auto; font-family: ui-monospace, Menlo, monospace;
       font-size: 12px; line-height: 1.6; }
.log div { white-space: pre-wrap; word-break: break-word; }
.log .t { color: var(--dim); }

.steps { display: grid; gap: 6px; }
.step { display: flex; gap: 10px; align-items: center; font-size: 13px; padding: 5px 8px;
        border-radius: 6px; border: 1px solid transparent; }
.step .dot { width: 9px; height: 9px; border-radius: 99px; background: var(--line); flex: none; }
.step.done .dot { background: var(--ok); }
.step.active { border-color: var(--accent); background: #4da3ff12; }
.step.active .dot { background: var(--accent); animation: pulse 1.2s infinite; }
.step.fail .dot { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }
