:root {
  --bg: #f3f4f1; --surface: #fff; --sunken: #eceee9; --line: #d9dcd4; --fg: #1d2420; --muted: #5d665f;
  --accent: #23517a; --accent-soft: #e2ebf3; --on-accent: #fff;
  --before: #b5650d; --after: #12786b; --after-soft: #dcf0ec; --tag-fg: #fff;
  --warn: #a2332b; --warn-soft: #f7e3e1; --shade: rgba(16, 22, 18, .72);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151917; --surface: #1d2220; --sunken: #121513; --line: #333a36; --fg: #e8ece9; --muted: #9aa49d;
    --accent: #7fb0dc; --accent-soft: #22303c; --on-accent: #0e1a24;
    --before: #e09a4f; --after: #4fc0ad; --after-soft: #183530; --tag-fg: #111411;
    --warn: #ec8b7d; --warn-soft: #3d2220; --shade: rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand { font-weight: 800; display: flex; gap: 0; align-items: baseline; }
.brand .b { color: var(--before); } .brand .a { color: var(--after); }

/* sign-in */
#auth { max-width: 420px; margin: 0 auto; padding: max(40px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); display: grid; gap: 20px; font-size: 16px; }
#auth .brand { font-size: 30px; letter-spacing: -.5px; }
#auth .box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: grid; gap: 14px; }
#auth h1 { font-size: 20px; }
#auth .muted { font-size: 14px; }
#auth label { font-size: 14px; font-weight: 600; display: grid; gap: 6px; }
#auth input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 11px 12px; width: 100%; }
#auth .code { font-size: 26px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
#auth button { font-weight: 600; border-radius: 8px; padding: 12px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); min-height: 46px; }
#auth button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
#auth button:disabled { opacity: .5; cursor: default; }
#auth .link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 500; }
#auth .err { color: var(--warn); font-size: 14px; }

/* app frame */
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.inner { max-width: 1120px; margin: 0 auto; }
.app-head { background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.app-head .inner { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding-block: 10px; }
.app-head .brand { font-size: 18px; text-decoration: none; }
.me { margin-left: auto; font-size: 13px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.me b { color: var(--fg); font-weight: 600; }
@media (max-width: 480px) { .me { order: 3; flex-basis: 100%; margin-left: 0; } .app-head .brand { margin-right: auto; } }
.app-head a.btn { text-decoration: none; color: inherit; }
main { padding-block: 20px 72px; }
main .inner { display: grid; gap: 20px; min-width: 0; }

/* common */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 12px; cursor: pointer; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--on-accent); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 99px; white-space: nowrap; background: var(--sunken); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--after-soft); color: var(--after); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.panel h3 { font-size: 15px; font-weight: 600; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; font-weight: 500; }
.input { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 10px; width: 100%; font-size: 16px; }
textarea.input { resize: vertical; min-height: 72px; line-height: 1.5; }
.count { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.count.full { color: var(--warn); }
.empty { color: var(--muted); font-size: 14px; padding: 22px 18px; border: 1px dashed var(--line); border-radius: 10px; display: grid; gap: 6px; }
.empty strong { color: var(--fg); }
.err-line { color: var(--warn); font-size: 13px; overflow-wrap: anywhere; }
.err-line ul { padding-left: 18px; }
figure { margin: 0; position: relative; aspect-ratio: 4 / 3; background: var(--sunken); overflow: hidden; }
figure img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 600; letter-spacing: .05em; padding: 1px 6px; border-radius: 3px; color: var(--tag-fg); z-index: 2; }
.tag.b { background: var(--before); } .tag.a { background: var(--after); }
.sec-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.sec-head h2 { font-size: 17px; }

/* list */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .input { width: auto; }
#q { flex: 1 1 220px; min-width: 0; }
.chipf { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chipf[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); flex: none; }
.seg button { border: 0; background: none; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.toolbar .seg { margin-left: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card { text-align: left; padding: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; overflow: hidden; cursor: pointer; display: grid; grid-template-rows: auto 1fr; }
.card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); }
.card-body { padding: 10px 12px 12px; display: grid; gap: 6px; align-content: start; }
.card-body h3 { font-size: 15px; font-weight: 600; }
.addr { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.card-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.nophoto { width: 100%; height: 100%; display: grid; place-content: center; color: var(--muted); font-size: 12px; }
.sbs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); min-width: 0; }
.sbs figure { background: #000; }
.sbs img { object-fit: contain; }
.rows { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.rowi { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; width: 100%; }
.rowi:last-child { border-bottom: 0; }
.rowi:hover { background: var(--sunken); }
.rowi .split { border-radius: 6px; overflow: hidden; }
.rowi .tag { font-size: 9px; left: 3px; top: 3px; padding: 0 4px; }
.rowi-main { display: grid; gap: 2px; min-width: 0; }
.rowi .chips { justify-content: flex-end; max-width: 260px; }
@media (max-width: 640px) { .rowi { grid-template-columns: 110px minmax(0, 1fr); } .rowi .chips { grid-column: 2; justify-content: flex-start; } }
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

/* job detail */
.back { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 14px; font-weight: 500; justify-self: start; }
.job-head { display: grid; gap: 6px; }
.job-head h1 { font-size: clamp(22px, 3.4vw, 28px); line-height: 1.25; }
.job-sub { font-size: 12px; color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.side { display: grid; gap: 12px; min-width: 0; }
.pairs { display: grid; gap: 16px; min-width: 0; }
.pair { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.pair.wide { grid-template-columns: minmax(0, 1fr); }
.pair.fresh { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 720px) { .pair { grid-template-columns: minmax(0, 1fr); } }
.pair-info { padding: 14px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.pair-title { font-weight: 600; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-variant-numeric: tabular-nums; }
.cmp { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 72vh; overflow: hidden; background: #000; user-select: none; -webkit-user-select: none; touch-action: pan-y; cursor: ew-resize; }
.cmp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.cmp .cb { clip-path: inset(0 50% 0 0); background: #000; }
.cl { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3); z-index: 1; }
.cl::after { content: "◀ ▶"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: #222; font-size: 11px; padding: 6px 7px; border-radius: 99px; white-space: nowrap; letter-spacing: -1px; }
.cmp .tag.a { left: auto; right: 6px; }
/* The range input is kept for keyboards; dragging is handled by pointer events on .cmp (iOS only moves a range by its thumb). */
.cmp input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; z-index: 3; }
.cmp:focus-within .cl { background: var(--accent); }
.tray { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 4px; scroll-snap-type: x proximity; }
.tray button { flex: 0 0 132px; scroll-snap-align: start; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; display: grid; }
.tray button[aria-pressed="true"] { border-color: var(--accent); }
.tray .cap { padding: 5px 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.check { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 13px; font-weight: 700; z-index: 2; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); font-size: 14px; display: grid; gap: 8px; justify-items: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.upl { position: relative; cursor: pointer; }
.upl input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upl:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sending */
.chat { background: var(--sunken); border-radius: 10px; padding: 14px; }
.bubble { background: var(--surface); border-radius: 10px; overflow: hidden; max-width: 300px; display: grid; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.bubble-body { padding: 8px 10px; display: grid; gap: 2px; font-size: 13px; overflow-wrap: anywhere; }
.send-actions { display: grid; gap: 8px; }
.send-actions .btn { justify-content: center; min-height: 44px; }
.linkbox { font-size: 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.msgs { display: grid; gap: 6px; font-size: 14px; padding: 0; }
.msgs li { background: var(--sunken); border-radius: 8px; padding: 6px 10px; list-style: none; overflow-wrap: anywhere; white-space: pre-wrap; }
@media (max-width: 720px) { .job-send { display: none; } }

/* people */
.people { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.person { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.kv { display: grid; gap: 2px; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.kv b { font-size: 15px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }

/* upload progress and review */
.review { background: var(--surface); border: 2px solid var(--accent); border-radius: 12px; padding: 14px; display: grid; gap: 10px; scroll-margin-top: 12px; min-width: 0; }
.review .cmp, .review .sbs { border-radius: 8px; overflow: hidden; }
.review progress { width: 100%; height: 8px; accent-color: var(--accent); }
.rv-actions { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.rv-actions .btn { justify-content: center; min-height: 44px; white-space: normal; text-align: center; line-height: 1.25; }

/* phone action bar */
.actionbar { display: none; }
@media (max-width: 720px) {
  body.has-bar .actionbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; gap: 8px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  body.has-bar .actionbar > * { flex: 1; justify-content: center; min-height: 46px; font-size: 15px; }
  body.has-bar main { padding-bottom: 96px; }
  body.has-bar .toast { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
  body.has-bar .drop { display: none; }
}
@media (max-width: 600px) { .pair .sbs, .review .sbs, .modal .sbs { grid-template-columns: minmax(0, 1fr); } }

/* modal and toast */
.modal { position: fixed; inset: 0; z-index: 50; background: var(--shade); display: grid; place-items: center; overflow-y: auto;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.modal-card { background: var(--surface); border-radius: 12px; width: min(900px, 100%); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.modal-card.narrow { width: min(460px, 100%); }
.modal .cmp { border-radius: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; width: max-content; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
