/* 사진 색 판단을 방해하지 않도록 무채색 UI만 쓴다 */
:root {
  --top-h: 48px;          /* 상단바 높이 — 좁은 화면에서 바뀐다 */
  --bg: #1b1b1b;
  --panel: #232323;
  --panel2: #2b2b2b;
  --line: #3a3a3a;
  --text: #e8e8e8;
  --muted: #9b9b9b;
  --view: #474747;
  --ok: #58b585;
  --warn: #d9a441;
  --bad: #e36a5f;
  --radius: 6px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.4;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  /* 한글은 어절 단위로 줄바꿈한다 (코딩표준 §9.2) */
  word-break: keep-all;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }

button {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { background: #353535; }
button.on { background: #e8e8e8; color: #141414; border-color: #e8e8e8; }
button.primary { background: #e8e8e8; color: #141414; border-color: #e8e8e8; font-weight: 600; }
input, select {
  font: inherit; color: var(--text); background: #161616; border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 8px; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 1px solid #bdbdbd; outline-offset: 0; }
input[type=range] { accent-color: #d6d6d6; padding: 0; background: transparent; border: 0; }

.small { font-size: 11px; }
.muted { color: var(--muted); }

/* ── 상단 ── */
.topbar {
  height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  overflow: hidden;   /* 창이 좁아져도 가로 스크롤이 생기지 않게 */
}
.topbar > * { min-width: 0; }
.brand { font-weight: 700; white-space: nowrap; }
.brand .sub { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }
.folder { flex: 1 1 120px; display: flex; gap: 6px; max-width: 760px; min-width: 0; }
.folder input { flex: 1; min-width: 0; }
.folder button { flex: none; }
.top-actions { display: flex; gap: 6px; margin-left: auto; flex: none; }
.top-actions > * { flex: none; }
.more-wrap { display: flex; gap: 6px; }
.more-btn { display: none; font-size: 16px; line-height: 1; }

.layout {
  --col-list: 270px;
  --col-panel: 390px;
  display: grid; grid-template-columns: var(--col-list) minmax(0, 1fr) var(--col-panel);
  height: calc(100dvh - var(--top-h));
}
body.no-list .layout { --col-list: 0px; }
body.no-panel .layout { --col-panel: 0px; }
body.no-list .sidebar, body.no-panel .panel { display: none; }
body.no-histo .histo-wrap { display: none; }

/* ── 파일 목록 ── */
.sidebar { grid-column: 1; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.summary { padding: 12px; border-bottom: 1px solid var(--line); }
.summary:empty { display: none; }
.summary .short { display: none; }
.sum-title { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.sum-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.sum-stats div { background: var(--panel2); border-radius: 4px; padding: 5px 4px; text-align: center; }
.sum-stats b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.sum-stats span { font-size: 10px; color: var(--muted); }
.sum-k { font-size: 12px; margin-top: 4px; }
.sum-session { font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

.file-list { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.file-list li { display: flex; gap: 10px; padding: 6px; border-radius: 6px; cursor: pointer; align-items: center; }
.file-list li:hover { background: var(--panel2); }
.file-list li.on { background: #3a3a3a; box-shadow: inset 3px 0 0 #e8e8e8; }
.file-list img { width: 72px; height: 48px; object-fit: cover; border-radius: 3px; background: #111; flex: none; }
.fi { min-width: 0; }
.fn { font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.badges .k { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 11px; font-weight: 600;
  line-height: 17px; border: 1px solid currentColor; white-space: nowrap;
}
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.neutral { color: var(--muted); }

/* ── 뷰어 ── */
.viewer { grid-column: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; gap: 10px; align-items: center; padding: 6px 10px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
/* 뷰포트 배경은 중간 회색 — 주변색이 WB 판단을 끌고 가지 않게 */
.viewport { position: relative; flex: 1; overflow: hidden; background: var(--view); cursor: grab; touch-action: none; }
.viewport.picking { cursor: crosshair; }
.viewport.dragging { cursor: grabbing; }
.viewport.splitting { cursor: ew-resize; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage canvas, .stage img { position: absolute; left: 0; top: 0; display: block; box-shadow: 0 0 0 1px #0006; }
.vtag {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; white-space: nowrap;
  padding: 5px 9px; border-radius: 4px; background: rgba(18, 18, 18, .78); color: #d8d8d8;
  font-size: 11px; line-height: 1.35; font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px #0006;
}
.vtag b { display: block; font-size: 13px; color: #fff; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #e0e0e0; pointer-events: none; font-size: 14px; text-shadow: 0 1px 2px #0008; }
.viewer-msg:empty { display: none; }
.statusbar {
  height: 26px; padding: 0 10px; display: flex; align-items: center; gap: 16px; font-size: 12px;
  color: var(--muted); background: var(--panel); border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
}

/* ── 우측 패널 ── */
.panel { grid-column: 3; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.histo-wrap { padding: 10px 12px 6px; border-bottom: 1px solid var(--line); }
#histo { width: 100%; height: 110px; display: block; background: #141414; border-radius: 4px; }
.histo-info { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.histo-info .alert { color: var(--bad); font-weight: 600; }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.histo-btn { flex: none !important; width: 34px; color: var(--muted); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 9px 0; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--text); background: transparent; }
.tab-body { overflow: auto; flex: 1; padding: 12px; }
.tab { display: none; }
.tab.on { display: block; }

.card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.card-k { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; font-weight: 600; }
.big { font-size: 16px; font-weight: 600; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.advice { border-color: #5a5a5a; }
.advice-text { font-size: 14px; line-height: 1.5; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0 0; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.note { margin-top: 6px; font-size: 12px; color: var(--warn); }
.warn-list { margin: 0; padding-left: 16px; color: var(--warn); font-size: 12px; }
.meter { position: relative; height: 6px; background: #1a1a1a; border-radius: 3px; margin-top: 8px; overflow: hidden; }
.meter i { position: absolute; top: 0; bottom: 0; }
.meter .zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: #888; }

/* 보정 탭 */
.nx .nx-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: baseline; }
.nx .nx-grid span { color: var(--muted); font-size: 12px; }
.nx .nx-grid b { font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
.nx .nx-grid b.sub { font-size: 12px; font-weight: 500; color: var(--muted); }
.nx-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.nx-head .card-k { margin: 0; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.group-title { margin: 14px 0 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.slider { display: grid; grid-template-columns: 70px 1fr 66px; gap: 8px; align-items: center; margin: 5px 0; }
.slider label { color: #cfcfcf; }
.slider input[type=number] { width: 66px; padding: 3px 5px; text-align: right; font-variant-numeric: tabular-nums; }
.slider .span2 { grid-column: span 2; }
.slider.temp input[type=range] { background: linear-gradient(90deg, #d88a3c55, #0000 50%, #5c8ad855); border-radius: 3px; }
.slider.tint input[type=range] { background: linear-gradient(90deg, #c25cc255, #0000 50%, #5cc26a55); border-radius: 3px; }
.iso-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 4px 78px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.iso-row select { font-size: 11px; padding: 2px 4px; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 10px 0 0; }
details.hint > summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details.hint p { margin: 4px 0; }

/* 재촬영 탭 */
.opt .combo { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.opt ul, .tips { margin: 6px 0 0; padding-left: 16px; font-size: 12px; }
.tips li { margin-bottom: 4px; }
.opt-meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

.sim-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; line-height: 1.5; }
.sim-row button { flex: none; }
.sim-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 4px 0; }
.sim-form select { font-size: 12px; padding: 3px 4px; }
.sim-active { margin-top: 8px; font-size: 12px; }
.sim-active button { margin-left: 6px; padding: 1px 8px; }
.card.sim-on { border-color: #b98a2e; box-shadow: inset 3px 0 0 #d9a441; }
.ratio { font-weight: 600; font-variant-numeric: tabular-nums; }
.ratio.up { color: var(--warn); }
.ratio.down { color: var(--ok); }

/* 메타데이터 탭 */
details.ifd { border-top: 1px solid var(--line); }
details.ifd summary { cursor: pointer; padding: 7px 0; font-weight: 600; }
table.tags { width: 100%; border-collapse: collapse; font-size: 11px; font-family: ui-monospace, Consolas, monospace; margin-bottom: 8px; }
table.tags td { border-top: 1px solid #333; padding: 3px 4px; vertical-align: top; word-break: break-all; }
table.tags td:first-child { color: var(--muted); white-space: nowrap; }
table.tags td:nth-child(2) { white-space: nowrap; }

/* 기준점 */
.point-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.marker { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid; }
.marker.gray { border-color: #a8a8a8; background: rgba(128, 128, 128, .45); box-shadow: 0 0 0 1px #000; }
.marker.white { border-color: #fff; background: rgba(255, 255, 255, .25); box-shadow: 0 0 0 1px #000; }
.marker.black { border-color: #000; background: rgba(0, 0, 0, .45); box-shadow: 0 0 0 1.5px #fff; }
.marker b { position: absolute; left: 15px; top: -13px; font-size: 11px; font-style: normal; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.points .seg button { padding: 2px 8px; font-size: 12px; }
.pt-list { list-style: none; margin: 6px 0 4px; padding: 0; font-size: 12px; }
.pt-list li { display: grid; grid-template-columns: 12px 44px 1fr 24px; gap: 6px; align-items: center; padding: 3px 0; border-top: 1px solid #353535; }
.pt-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-del { padding: 0 6px; line-height: 18px; }
.pt-sum { font-size: 12px; margin-top: 5px; }
.pt-opt { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 8px; color: #cfcfcf; }
.pt-opt input[type=number] { width: 54px; padding: 2px 4px; text-align: right; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid #888; }
.dot.gray { background: #808080; }
.dot.white { background: #f5f5f5; }
.dot.black { background: #000; border-color: #bbb; }

/* 수평 맞추기 */
.viewport.leveling { cursor: crosshair; }
.level-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; overflow: visible; }
.lv-line { stroke: #ffd24a; stroke-width: 2; stroke-dasharray: 7 4; }
.lv-dot { fill: #ffd24a; stroke: #000; stroke-width: 1; }
.lv-text { fill: #fff; font-size: 13px; font-weight: 600; paint-order: stroke; stroke: #000; stroke-width: 3px; }
.rot-input { display: inline-flex; align-items: center; gap: 4px; color: #cfcfcf; }
.rot-input input { width: 62px; padding: 2px 4px; text-align: right; }

/* 크롭 */
.viewport.cropping { cursor: crosshair; }
.crop-bar { display: inline-flex; gap: 6px; align-items: center; }
.crop-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.crop-box { position: absolute; left: 0; top: 0; outline: 1px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .62); pointer-events: auto; cursor: move; }
.crop-grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent 33.1%, #fff6 33.1%, #fff6 33.4%, transparent 33.4%, transparent 66.5%, #fff6 66.5%, #fff6 66.8%, transparent 66.8%),
    linear-gradient(to bottom, transparent 33.1%, #fff6 33.1%, #fff6 33.4%, transparent 33.4%, transparent 66.5%, #fff6 66.5%, #fff6 66.8%, transparent 66.8%);
}
.crop-box span { position: absolute; width: 12px; height: 12px; background: #f2f2f2; border: 1px solid #222; pointer-events: auto; }
.crop-box [data-h=nw] { left: -6px; top: -6px; cursor: nwse-resize; }
.crop-box [data-h=n] { left: calc(50% - 6px); top: -6px; cursor: ns-resize; }
.crop-box [data-h=ne] { right: -6px; top: -6px; cursor: nesw-resize; }
.crop-box [data-h=e] { right: -6px; top: calc(50% - 6px); cursor: ew-resize; }
.crop-box [data-h=se] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.crop-box [data-h=s] { left: calc(50% - 6px); bottom: -6px; cursor: ns-resize; }
.crop-box [data-h=sw] { left: -6px; bottom: -6px; cursor: nesw-resize; }
.crop-box [data-h=w] { left: -6px; top: calc(50% - 6px); cursor: ew-resize; }

/* 내보내기 */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-row { display: flex; gap: 8px; align-items: center; }
.range-row input { flex: 1; }
.range-row output { width: 28px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.dlg label.check { flex-direction: row; align-items: center; gap: 6px; }
.export-progress:empty { display: none; }
.export-progress progress { width: 100%; height: 6px; accent-color: #d6d6d6; }
.export-progress .msg { font-size: 12px; margin-top: 4px; word-break: break-all; }
.export-log { list-style: none; margin: 6px 0 0; padding: 0; max-height: 150px; overflow: auto; font-size: 11px; font-family: ui-monospace, Consolas, monospace; color: var(--muted); }
.export-log .err { color: var(--bad); }

/* 로그인 · 폴더 탐색 */
.login-msg { min-height: 18px; font-size: 12px; color: var(--bad); }
.browse-path { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; color: #cfcfcf; }
.browse-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.browse-list li { padding: 10px 12px; border-bottom: 1px solid #333; cursor: pointer; }
.browse-list li:last-child { border-bottom: 0; }
.browse-list li:hover { background: var(--panel2); }
.browse-list li.root { color: #fff; font-weight: 600; }
.viewport.dropping { outline: 3px dashed #d9a441; outline-offset: -8px; }

/* 대화상자 */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(500px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.dlg h3 { margin: 0; font-size: 15px; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #cfcfcf; }
.dlg .hint { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 6px; }
.keys dd { text-align: left; }

.drawer-btn { flex: none; }
.drawer-btn.on { background: #3a3a3a; color: #fff; }
.drawer-back { display: none; }

@media (max-width: 1280px) {
  .layout { --col-list: 220px; --col-panel: 350px; }
  .brand .sub { display: none; }
  .file-list img { width: 56px; height: 38px; }
}

/* ── 태블릿 · 모바일: 목록과 패널을 서랍으로 ── */
@media (max-width: 1000px) {
  :root { --top-h: 52px; }
  .topbar { gap: 8px; padding: 0 8px; }
  .brand { font-size: 13px; }
  .brand .sub { display: none; }
  .folder { max-width: none; }
  .top-actions { gap: 4px; }
  .folder { min-width: 120px; }
  .more-btn { display: inline-block; }
  .more-wrap {
    display: none; position: fixed; top: var(--top-h); right: 6px; z-index: 40;
    flex-direction: column; gap: 4px; padding: 6px; min-width: 140px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #000a;
  }
  .more-wrap.open { display: flex; }
  .more-wrap button { width: 100%; text-align: left; }
  .layout { display: block; }
  .viewer { height: 100%; }
  .sidebar, .panel {
    position: fixed; top: var(--top-h); bottom: 0; z-index: 30; width: min(86vw, 380px);
    transition: transform .18s ease; box-shadow: 0 0 24px #0008;
  }
  .sidebar { left: 0; transform: translateX(-102%); border-right: 1px solid var(--line); }
  .panel { right: 0; transform: translateX(102%); border-left: 1px solid var(--line); }
  .sidebar.open, .panel.open { transform: none; }
  body.resizing .sidebar, body.resizing .panel { transition: none; }
  .drawer-back { display: block; position: fixed; inset: var(--top-h) 0 0; background: #0009; z-index: 25; }
  body.no-list .sidebar, body.no-panel .panel { display: flex; }   /* 서랍은 접기 대신 여닫기 */
  /* 가로 스크롤은 마우스로 조작이 안 된다 — 좁으면 여러 줄로 쌓는다 */
  .toolbar { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .crop-bar, #levelBar { flex-wrap: wrap; gap: 6px; }
  .statusbar { font-size: 11px; }
  .tab-body { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
}

/* 아주 좁은 창: 제목을 숨겨 폴더 입력과 버튼에 자리를 준다 */
@media (max-width: 720px) {
  .brand { display: none; }
  .topbar { gap: 6px; padding: 0 6px; }
}

/* 더 좁으면 상단 버튼을 촘촘하게 (마우스 환경 기준, 터치는 아래 coarse 규칙이 우선) */
@media (max-width: 560px) {
  .topbar button { padding: 0 8px; font-size: 12px; }
  .folder input { padding: 0 6px; }
  /* 폴더 입력은 둘째 줄 전체를 쓴다 — 버튼과 자리를 다투지 않게 */
  :root { --top-h: 96px; }
  .topbar { flex-wrap: wrap; align-content: center; row-gap: 6px; }
  .folder { order: 10; flex: 1 0 100%; max-width: none; }
}

/* ── 창이 좁고 충분히 높을 때: 서랍 대신 위아래로 쌓아 목록·미리보기·패널을 한 화면에 ──
   세로 태블릿뿐 아니라 정사각형에 가까운 데스크톱 창도 포함한다(가로가 너무 길면 제외). */
@media (max-width: 1200px) and (min-height: 560px) and (max-aspect-ratio: 3 / 2) {
  .drawer-back { display: none !important; }
  /* 쌓기 배치에서 목록·패널 버튼은 '접기/펴기' 스위치가 된다 */
  body.no-list .sidebar, body.no-panel .panel { display: none; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: calc(100dvh - var(--top-h));
  }
  .sidebar {
    grid-column: 1; grid-row: 1;
    position: static; transform: none; transition: none; box-shadow: none;
    flex-direction: column; width: auto; height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  /* 요약은 필름스트립 위 한 줄 */
  .summary {
    flex: none; display: flex; align-items: center; gap: 10px;
    padding: 3px 8px; white-space: nowrap; overflow: hidden;
    border-bottom: 1px solid var(--line); border-right: 0;
  }
  .sum-title { margin: 0; flex: none; }
  .sum-stats { display: flex; gap: 8px; margin: 0; flex: none; }
  .sum-stats div { display: flex; align-items: baseline; gap: 4px; padding: 1px 6px; }
  .sum-stats b { display: inline; font-size: 12px; }
  .sum-stats span { font-size: 10px; }
  .sum-k { margin: 0; flex: none; font-size: 11px; }
  .sum-session, .summary .note { display: none; }   /* 한 줄에는 담지 않는다 */
  .file-list { flex: none; height: 96px; display: flex; flex-direction: row; gap: 6px; overflow-x: auto; overflow-y: hidden; }
  .file-list li { flex: 0 0 auto; width: 148px; flex-direction: column; align-items: stretch; gap: 4px; }
  .file-list img { width: 100%; height: 58px; }
  .viewer { grid-column: 1; grid-row: 2; height: auto; min-height: 0; }
  .panel {
    grid-column: 1; grid-row: 3;
    position: static; transform: none; transition: none; box-shadow: none;
    width: auto; height: clamp(240px, 36dvh, 560px);
    border-left: 0; border-top: 1px solid var(--line);
  }
  .histo-wrap { padding: 8px 12px 4px; }
  #histo { height: 84px; }
}

/* 쌓기 배치인데 창이 높지 않을 때: 위아래를 줄여 미리보기에 자리를 준다 */
@media (max-width: 1200px) and (min-height: 560px) and (max-aspect-ratio: 3 / 2) and (max-height: 800px) {
  .file-list { height: 80px; }
  .file-list img { height: 44px; }
  .panel { height: clamp(220px, 32dvh, 300px); }
  #histo { height: 72px; }
}

/* 버튼이 여러 줄로 쌓이는 폭에서는 툴바를 촘촘하게 */
@media (max-width: 760px) {
  .toolbar { gap: 4px; padding: 5px 6px; }
  .toolbar button { padding: 0 8px; font-size: 12px; }
  .toolbar .muted { font-size: 11px; }
}

/* 쌓기 배치인데 폭이 좁을 때: 요약과 썸네일을 줄여 필름스트립이 제 구실을 하게 */
@media (max-width: 760px) and (min-height: 560px) and (max-aspect-ratio: 3 / 2) {
  .summary { gap: 6px; padding: 2px 6px; font-size: 11px; }
  .summary .full { display: none; }
  .summary .short { display: inline; }
  .sum-stats { gap: 4px; }
  .sum-stats div { padding: 1px 4px; }
  .file-list li { width: 116px; }
  .panel { height: clamp(200px, 30dvh, 280px); }
}

/* 더 좁으면 요약 한 줄에서 제목과 배지를 덜어낸다(값은 title 로 남는다) */
@media (max-width: 470px) and (min-height: 560px) and (max-aspect-ratio: 3 / 2) {
  .sum-title { display: none; }
  .sum-k .badge { display: none; }
}

/* 높이가 아주 빠듯한 쌓기 배치: 툴바 줄이 늘어난 만큼 위아래를 더 줄인다 */
@media (max-width: 1200px) and (min-height: 560px) and (max-aspect-ratio: 3 / 2) and (max-height: 640px) {
  .file-list { height: 72px; }
  .file-list img { height: 34px; }
  .file-list li { width: 104px; font-size: 11px; }
  .panel { height: clamp(150px, 26dvh, 200px); }
  #histo { height: 56px; }
}

/* 손가락 조작: 버튼과 핸들을 키운다 */
@media (pointer: coarse) {
  button { padding: 8px 12px; }
  .seg button { padding: 8px 10px; }
  .tabs button { padding: 12px 0; }
  .crop-box span { width: 22px; height: 22px; }
  .crop-box [data-h=nw], .crop-box [data-h=w], .crop-box [data-h=sw] { left: -11px; }
  .crop-box [data-h=ne], .crop-box [data-h=e], .crop-box [data-h=se] { right: -11px; }
  .crop-box [data-h=nw], .crop-box [data-h=n], .crop-box [data-h=ne] { top: -11px; }
  .crop-box [data-h=sw], .crop-box [data-h=s], .crop-box [data-h=se] { bottom: -11px; }
  .crop-box [data-h=n], .crop-box [data-h=s] { left: calc(50% - 11px); }
  .crop-box [data-h=e], .crop-box [data-h=w] { top: calc(50% - 11px); }
  .marker { width: 26px; height: 26px; left: -13px; top: -13px; }
  .pt-del { padding: 4px 10px; }
  .file-list li { padding: 10px 8px; }
  .browse-list li { padding: 14px 12px; }
}
