:root {
  font-family: Inter, "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  color: #151d34; background: #f5f7fc;
  --ink: #151d34; --muted: #526078; --line: #dbe2ef; --blue: #2346d1;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button { white-space: nowrap; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid #526ff3; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
p { line-height: 1.65; color: var(--muted); }
.shell { max-width: 1192px; margin: auto; padding-inline: 32px; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.brand { height: 71px; display: flex; align-items: center; gap: 11px; font-weight: 750; font-size: 18px; letter-spacing: -.3px; }
.brand-icon { display: grid; place-items: center; width: 33px; height: 33px; background: var(--blue); border-radius: 9px; }
.brand-icon i { width: 16px; height: 14px; border: 1.5px solid white; border-radius: 3px; position: relative; }
.brand-icon i::after { content: ""; position: absolute; background: #fff; width: 4px; height: 4px; left: 3px; top: 2px; border-radius: 50%; }
main { padding-block: 46px 68px; }
.intro { margin-bottom: 28px; }
.intro h1 { font-size: clamp(34px, 6vw, 53px); letter-spacing: -.035em; line-height: 1.2; margin-bottom: 11px; }
.workspace { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(248px, 1fr); gap: 22px; align-items: start; }
.panel { background: #fff; border: 1px solid #e0e5ef; border-radius: 19px; box-shadow: 0 3px 10px #1b2b5410; }
.main-panel, .guide, .results { padding: 24px; }
.panel-head, .run-bar, .dialog-head, .merge-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h2 { font-size: 21px; }
.panel-head p { margin-top: 3px; font-size: 15px; }
.drop-zone { margin-top: 18px; padding: 32px 14px; border: 1.5px dashed #a4b3d9; border-radius: 15px; text-align: center; background: #f6f8ff; }
.drop-zone.dragging { background: #e5ecff; border-color: var(--blue); }
.upload-icon { display: grid; place-items: center; width: 53px; height: 53px; border-radius: 15px; background: #e6edff; margin: 0 auto 13px; }
.upload-icon i { width: 20px; height: 12px; border: 2px solid var(--blue); border-top: 0; border-radius: 0 0 4px 4px; position: relative; }
.upload-icon i::before { content: ""; position: absolute; background: var(--blue); width: 2px; height: 15px; left: 7px; top: -8px; }
.upload-icon i::after { content: ""; position: absolute; width: 8px; height: 8px; border-top: 2px solid var(--blue); border-left: 2px solid var(--blue); transform: rotate(45deg); left: 4px; top: -8px; }
.drop-zone h3 { font-size: 22px; }
.drop-zone p { margin-block: 4px 18px; font-size: 14px; }
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.primary, .secondary, .quiet { padding: 9px 15px; min-height: 42px; border-radius: 9px; border: 1px solid transparent; font-weight: 700; }
.primary { color: white; background: var(--blue); }
.primary:hover:not(:disabled) { background: #1937b7; }
.secondary { background: white; border-color: #ced8ed; color: #1c3ea8; }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: #eff3ff; }
.quiet { background: transparent; color: #2443a9; }
.run-bar { padding-top: 17px; }
.run-bar p, .guide p, .merge-bar p { font-size: 14px; }
.guide h2 { margin-bottom: 17px; }
.guide-row { display: flex; gap: 11px; padding: 14px 0; border-top: 1px solid #edf0f6; }
.guide-row:last-child { padding-bottom: 0; }
.mini-icon { display: grid; place-items: center; flex: 0 0 33px; height: 33px; border-radius: 8px; background: #edf2ff; color: #2c47ac; font-size: 18px; font-weight: 750; }
.guide-row h3 { font-size: 16px; margin-bottom: 3px; }
.thumb-strip { display: flex; align-items: center; gap: 7px; margin-top: 14px; flex-wrap: wrap; }
.thumb-strip img { width: 47px; height: 47px; object-fit: cover; border-radius: 6px; background: #edf1f8; }
.progress-area { margin-top: 15px; }
progress { width: 100%; accent-color: var(--blue); }
.notice { margin-top: 12px; padding: 9px 12px; background: #f1f5ff; border-radius: 8px; overflow-wrap: anywhere; }
.results { margin-top: 22px; }
.merge-bar { border-block: 1px solid #e9eef6; padding: 10px 0; margin: 15px 0; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(174px, 1fr)); gap: 12px; margin-top: 14px; }
.group-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; padding-bottom: 9px; }
.cover { display: block; width: 100%; height: 130px; padding: 0; border: 0; background: #edf2ff; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.group-card input[type=text] { display: block; width: calc(100% - 20px); padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; margin: 9px 10px 2px; color: var(--ink); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-inline: 10px; gap: 5px; font-size: 14px; }
.card-meta label { display: flex; gap: 5px; align-items: center; }
.special-title { padding: 9px 10px 0; font-size: 16px; }
dialog { width: min(850px, calc(100vw - 22px)); max-height: 88vh; border: 1px solid var(--line); border-radius: 16px; padding: 17px; color: var(--ink); box-shadow: 0 12px 40px #151d3455; }
dialog::backdrop { background: #151d3480; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; margin-top: 12px; }
.review-item { min-width: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.review-item img { width: 100%; height: 118px; object-fit: contain; background: #f2f4fa; display: block; }
.review-item p { padding: 4px 7px; font-size: 14px; overflow-wrap: anywhere; }
.review-item select, .review-item .quiet { margin: 0 6px 5px; width: calc(100% - 12px); font-size: 14px; }
.review-item select { padding: 5px; background: white; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
@media (max-width: 760px) {
  .shell { padding-inline: 16px; }
  main { padding-block: 29px 40px; }
  .workspace { grid-template-columns: 1fr; gap: 15px; }
  .main-panel, .guide, .results { padding: 16px; }
}
@media (max-width: 420px) {
  .run-bar, .merge-bar { align-items: flex-start; flex-wrap: wrap; }
  .group-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .drop-zone { padding-inline: 8px; }
}
.settings { margin: 18px 0 0; padding: 13px; border: 1px solid var(--line); border-radius: 11px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings legend { padding-inline: 6px; font-size: 15px; font-weight: 700; }
.settings label { display: block; font-size: 14px; margin-bottom: 5px; }
.settings select, .result-tools select { width: 100%; padding: 7px 8px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; }
.weight-setting { grid-column: 1 / -1; }
.weight-setting label { display: flex; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.weight-setting output { color: var(--blue); font-weight: 700; }
.weight-setting input { width: 100%; accent-color: var(--blue); }
.result-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.result-tools select { width: auto; max-width: 100%; }
.group-card .session-tag, .review-item .review-reason { font-size: 13px; overflow-wrap: anywhere; }
.session-tag { padding: 0 10px; }
.cover.review-cover { background: #fff4df; color: #795017; font-weight: 700; }
@media (max-width: 530px) { .settings { grid-template-columns: 1fr; } }
.results .panel-head > .actions { justify-content: flex-end; }
@media (max-width: 560px) {
  .results .panel-head { flex-wrap: wrap; }
  .results .panel-head > .actions { justify-content: flex-start; }
}
