:root {
  color-scheme: light;
  --navy: #10253c;
  --navy-2: #193752;
  --ink: #18222d;
  --muted: #697785;
  --line: #dce2e5;
  --paper: #ffffff;
  --canvas: #f2f3ef;
  --soft: #f7f8f6;
  --teal: #087f76;
  --teal-dark: #075f59;
  --teal-soft: #e4f2ef;
  --amber: #c97a16;
  --amber-soft: #fff2dc;
  --red: #b64242;
  --red-soft: #fae9e7;
  --blue: #326c9c;
  --blue-soft: #e8f0f7;
  --shadow: 0 20px 60px rgba(16, 37, 60, .09);
  --radius: 16px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

/* [hidden] 속성은 오버레이/아코디언처럼 display:flex를 지정하는 규칙과 함께 쓰이면
   무시된다(동일 우선순위에서는 UA 기본 규칙보다 저자 규칙이 항상 우선하기 때문).
   hidden을 표시 여부의 단일 진실 소스로 쓰기 위해 전역으로 강제한다. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 8% 8%, rgba(8,127,118,.06), transparent 26rem),
    var(--canvas);
  overflow: hidden;
}

button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  background: var(--soft);
  border-color: #c4cdd1;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

kbd {
  font: inherit;
  font-size: .75em;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  color: var(--muted);
}

input[type="number"] {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 56px;
  padding: 2px 4px;
}

input[type="number"]:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8,127,118,.12);
}

input[type="range"] {
  flex: 1;
  accent-color: var(--teal);
}

select {
  font: inherit;
  color: var(--ink);
  color-scheme: light;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
}

select option {
  color: var(--ink);
  background: #fff;
}

/* ---------- Header ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  color: #fff;
  background:
    linear-gradient(115deg, rgba(16,37,60,.98) 0%, rgba(16,37,60,.94) 55%, rgba(8,127,118,.9) 100%);
  border-bottom: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 10px 30px rgba(16,37,60,.16);
  flex-shrink: 0;
  flex-wrap: wrap;
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 14px;
  margin-right: 2px;
  border-right: 1px solid rgba(255,255,255,.14);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.05));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 6px 14px rgba(0,0,0,.18);
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 5px;
}

.brand-copy strong {
  display: block;
  font-size: 13px;
  letter-spacing: -.01em;
}

.brand-copy small {
  display: block;
  margin-top: 1px;
  color: #a7d9d0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .13em;
}

.app-header button {
  color: #e9eff3;
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.18);
}

.app-header button:hover,
.app-header button:focus-visible {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.32);
}

.mode-tabs {
  display: flex;
  gap: 6px;
}

.mode-button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 6px 16px rgba(8,127,118,.35);
}

.mode-button.active:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar.develop-only {
  display: none;
}

.mode-develop .toolbar.develop-only {
  display: flex;
  flex-wrap: wrap;
}

.folder-name,
.status-text {
  color: #cfe0da;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-text {
  margin-left: auto;
}

/* ---------- Layout ---------- */

.app-main {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--canvas);
}

.view {
  display: none;
  height: 100%;
}

.view.active {
  display: flex;
}

#library-view.active {
  display: flex;
  flex-direction: column;
}

/* ---------- Library: toolbar / grid / loupe ---------- */

.library-toolbar {
  display: flex;
  gap: 20px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-group button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 4px 12px rgba(8,127,118,.24);
}

.library-viewport {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  padding: 16px;
  background: var(--canvas);
}

.library-spacer {
  position: relative;
  width: 100%;
}

.library-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.thumbnail-card {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(16,37,60,.05);
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.thumbnail-card:hover {
  border-color: #c4cdd1;
  box-shadow: var(--shadow);
}

.thumbnail-card.focused {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8,127,118,.4);
}

.thumbnail-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--soft);
}

.thumb-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.badge-flag {
  color: #ffd35c;
  font-size: 1rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.badge-flag.is-reject {
  color: #ff6b6b;
}

.badge-rating {
  color: #ffd35c;
  font-size: .75rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
  margin-left: auto;
}

.badge-label-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .4);
}

.thumb-name {
  display: block;
  padding: 6px 8px;
  font-size: .75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.library-statusbar {
  padding: 8px 16px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
  flex-shrink: 0;
}

.library-loupe {
  position: fixed;
  inset: 0;
  background: rgba(242, 243, 239, .97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 50;
}

.library-loupe-image {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.library-loupe-caption {
  color: var(--ink);
  background: rgba(255,255,255,.85);
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.library-loupe-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.empty-message {
  color: var(--muted);
  padding: 32px;
}

/* ---------- Develop mode ---------- */

#develop-view {
  gap: 0;
}

.filmstrip {
  width: 96px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filmstrip-item {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: border-color .14s ease, box-shadow .14s ease;
}

.filmstrip-item:hover {
  border-color: #c4cdd1;
}

.filmstrip-item.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8,127,118,.4);
}

.filmstrip-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background:
    linear-gradient(110deg, #eef1ef 30%, #e2e6e3 45%, #eef1ef 60%) 0 0 / 220% 100%;
}

.filmstrip-item img:not(.loaded) {
  animation: filmstrip-thumb-loading 1.25s ease-in-out infinite;
}

@keyframes filmstrip-thumb-loading {
  to {
    background-position: -220% 0;
  }
}

.filmstrip-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: .65rem;
  color: #ffd35c;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
  pointer-events: none;
}

.develop-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.preview-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #e7eae7;
  overflow: hidden;
}

#photo-canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.photo-fallback-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: #e7eae7;
  pointer-events: none;
}

#photo-canvas:active {
  cursor: grabbing;
}

.preview-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.brush-cursor {
  position: absolute;
  z-index: 3;
  border: 1.5px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  pointer-events: none;
  box-sizing: border-box;
}

.develop-bottombar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.zoom-level {
  min-width: 48px;
  text-align: center;
  color: var(--ink);
}

.image-info {
  margin-left: auto;
  color: var(--muted);
  font-size: .8rem;
}

.develop-sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: var(--soft);
  border-left: 1px solid var(--line);
  padding: 16px 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.histogram-canvas {
  width: 100%;
  height: 80px;
  background: #eef1ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Accordion panels ---------- */

.control-card.accordion {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(16,37,60,.05);
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  text-align: left;
  color: var(--navy);
}

.accordion-header:hover,
.accordion-header:focus-visible {
  transform: none;
  background: var(--soft);
}

.accordion-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  visibility: hidden;
}

.accordion-dot.visible {
  visibility: visible;
}

.accordion-title {
  flex: 1;
  font-weight: 700;
}

.accordion-chevron {
  color: var(--muted);
  transition: transform .15s ease;
}

.control-card.accordion:not(.expanded) .accordion-chevron {
  transform: rotate(-90deg);
}

.accordion-body {
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.slider-row label {
  order: 1;
  color: var(--ink);
  font-size: .82rem;
  cursor: pointer;
}

.slider-row .slider-number {
  order: 2;
  margin-left: auto;
}

.slider-row input[type="range"] {
  order: 3;
  flex: 1 1 100%;
  width: 100%;
}

.slider-row.is-modified label {
  color: var(--teal-dark);
  font-weight: 700;
}

.accordion-body button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

#photo-canvas.panning {
  cursor: grabbing;
}

.control-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(16,37,60,.05);
  padding: 14px;
}

.control-card h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: .95rem;
}

/* ---------- Footer ---------- */

.app-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--paper);
  color: var(--muted);
  font-size: .78rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ---------- Crop tool ---------- */

.crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.crop-rect {
  position: absolute;
  border: 1px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .65);
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.crop-grid-line {
  position: absolute;
  background: rgba(255, 255, 255, .45);
  pointer-events: none;
}

.crop-grid-line.crop-grid-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.crop-grid-line.crop-grid-h {
  left: 0;
  right: 0;
  height: 1px;
}

.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 1px solid var(--teal);
  border-radius: 3px;
  pointer-events: auto;
  touch-action: none;
  transform: translate(-50%, -50%);
}

.crop-handle-nw { left: 0; top: 0; cursor: nwse-resize; }
.crop-handle-n  { left: 50%; top: 0; cursor: ns-resize; }
.crop-handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
.crop-handle-e  { left: 100%; top: 50%; cursor: ew-resize; }
.crop-handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-handle-s  { left: 50%; top: 100%; cursor: ns-resize; }
.crop-handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
.crop-handle-w  { left: 0; top: 50%; cursor: ew-resize; }

.crop-toolbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.94);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  pointer-events: auto;
  z-index: 6;
}

/* ---------- Modal dialogs ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 36, .5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(16,37,60,.25);
  padding: 22px;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-dialog h3 {
  margin: 0;
  color: var(--navy);
}

.modal-hint {
  color: var(--muted);
  font-size: .78rem;
  margin: 0;
}

.modal-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-row label {
  width: 70px;
  flex-shrink: 0;
  color: var(--ink);
  font-size: .85rem;
}

.modal-value {
  min-width: 32px;
  text-align: right;
  color: var(--ink);
  font-size: .85rem;
}

.modal-actions {
  justify-content: flex-end;
}

.modal-actions button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 6px 16px rgba(8,127,118,.28);
}

.modal-actions button.primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.modal-radio-group {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.modal-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  width: auto;
  color: var(--ink);
  font-size: .85rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width .2s ease;
}

/* ---------- 질감·효과 슬라이더 그룹 구분선 ---------- */

.slider-group-label {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.accordion-body .slider-group-label:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ---------- 톤 커브 에디터 (B7) ---------- */

.curve-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.curve-tabs {
  display: flex;
  gap: 4px;
  align-items: center;
}

.curve-tab {
  padding: 4px 10px;
  font-size: .78rem;
  box-shadow: inset 0 -2px 0 0 transparent;
}

.curve-tab.active {
  box-shadow: inset 0 -2px 0 0 var(--tab-color, #087f76);
  background: var(--soft);
}

.curve-reset {
  margin-left: auto;
  padding: 4px 10px;
  font-size: .75rem;
}

.curve-canvas {
  width: 100%;
  aspect-ratio: 6 / 5;
  background: #eef1ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}

.curve-hint {
  margin: 0;
}

/* ---------- HSL 패널 (B8) ---------- */

.hsl-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hsl-tabs {
  display: flex;
  gap: 4px;
}

.hsl-tab {
  flex: 1;
  padding: 6px 8px;
  font-size: .82rem;
}

.hsl-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.hsl-page {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hsl-slider-row label {
  position: relative;
  padding-left: 14px;
}

.hsl-slider-row label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--swatch-color, #888);
}

/* ---------- 컬러 그레이딩 (B9) ---------- */

.grading-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.grading-range {
  min-width: 0;
}

.grading-range-title {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .76rem;
  text-align: center;
}

.grading-wheel {
  position: relative;
  width: min(100%, 88px);
  aspect-ratio: 1;
  margin: 0 auto 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle, #777 0%, rgba(119, 119, 119, 0) 72%),
    conic-gradient(from 90deg, #f33, #ff3, #3f3, #3ff, #33f, #f3f, #f33);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, .3), 0 3px 10px rgba(16,37,60,.08);
  cursor: crosshair;
  touch-action: none;
}

.grading-wheel:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.grading-wheel-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--marker-hue, #f00);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .9);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.grading-luminance {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.grading-luminance label {
  order: initial;
  text-align: center;
}

.grading-luminance input[type='range'] {
  order: initial;
  width: 100%;
}

.grading-luminance .slider-number {
  order: initial;
  margin-left: 0;
  width: 100%;
}

.grading-hint {
  grid-column: 1 / -1;
  margin: 0;
}

/* ---------- 얼굴별 보정 패널 (D1, D3~D7) ---------- */

.face-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.face-panel-status,
.face-selected-label {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}

.face-panel-status.is-loading {
  color: var(--ink);
}

.face-panel-status.is-error {
  color: var(--red);
  line-height: 1.45;
}

.face-thumb-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 1px 5px;
}

.face-thumb {
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--soft);
  overflow: hidden;
}

.face-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.face-thumb.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8,127,118,.35);
  background: var(--teal-soft);
}

.face-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.face-selected-label {
  color: var(--ink);
  font-weight: 700;
}

.face-section-title {
  margin: 5px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--navy);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
}

/* ---------- Phase 9 마스킹 · 힐링 ---------- */

.mask-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.mask-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mask-add-row button {
  min-width: 0;
  font-size: .72rem;
}

.mask-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mask-list-item {
  flex: 1 1 44%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mask-list-item.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.mask-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.mask-actions,
.mask-brush-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mask-actions > * {
  flex: 1;
}

.mask-actions label {
  color: var(--ink);
  font-size: .78rem;
}

.panel-hint {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.45;
}

#photo-canvas.local-tool-active {
  cursor: crosshair;
}

/* ---------- 라이브러리 비교 뷰 (H7) ---------- */

.thumbnail-card.compare-selected {
  border-color: #f5c518;
  box-shadow: 0 0 0 2px rgba(245, 197, 24, .55);
}

.thumbnail-card.survey-selected {
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, .55);
}

.badge-compare {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #f5c518;
  color: #1a1a1a;
  font-size: .7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

.badge-compare:empty {
  display: none;
}

.library-compare {
  position: fixed;
  inset: 0;
  background: rgba(242, 243, 239, .97);
  display: flex;
  z-index: 50;
}

.library-survey {
  position: fixed;
  inset: 0;
  padding: 56px 24px 54px;
  overflow: auto;
  background: rgba(242, 243, 239, .97);
  z-index: 50;
}

.survey-grid {
  min-height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: center;
  gap: 14px;
}

.survey-item {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 3px 10px rgba(16,37,60,.05);
}

.survey-item img {
  display: block;
  width: 100%;
  height: min(32vh, 320px);
  object-fit: contain;
  background: var(--soft);
}

.survey-item figcaption {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.survey-item figcaption span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.survey-item figcaption button {
  color: var(--red);
}

.compare-pane {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.compare-pane:last-of-type {
  border-right: none;
}

.compare-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.compare-caption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  color: var(--ink);
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: .8rem;
  pointer-events: none;
}

.compare-hint-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: .78rem;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

@media (max-width: 960px) {
  .app-header {
    gap: 8px;
    padding: 8px;
  }

  .app-header .toolbar {
    gap: 6px;
  }

  .mode-develop .toolbar.develop-only {
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }

  .mode-develop .toolbar.develop-only button {
    flex: 0 0 auto;
  }

  .app-header button {
    padding: 6px 8px;
  }

  .status-text {
    flex-basis: 100%;
    margin-left: 0;
  }

  .develop-sidebar {
    width: 260px;
  }

  .filmstrip {
    width: 72px;
  }
}

@media (max-width: 700px) {
  .filmstrip {
    display: none;
  }

  .app-header {
    align-content: flex-start;
    padding: 6px 8px;
  }

  .app-header > .toolbar:not(.develop-only) {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }

  .app-header > .toolbar:not(.develop-only) > * {
    flex: 0 0 auto;
  }

  .status-text {
    min-width: 0;
    flex-basis: auto;
    width: 100%;
    font-size: .85rem;
  }

  #develop-view {
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  .develop-center {
    width: 100%;
    min-height: 180px;
    flex: 0 0 44%;
  }

  .develop-sidebar {
    width: 100%;
    min-height: 0;
    flex: 1 1 auto;
    border-top: 1px solid var(--line);
    border-left: none;
    padding: 10px;
    scrollbar-gutter: auto;
  }

  .histogram-canvas {
    flex: 0 0 80px;
  }

  .develop-bottombar {
    padding: 6px 8px;
    overflow-x: auto;
  }

  .develop-bottombar > * {
    flex: 0 0 auto;
  }

  .image-info {
    margin-left: 0;
  }

  .app-footer {
    display: none;
  }

  .survey-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .filmstrip {
    display: none;
  }

  .app-header {
    gap: 6px;
    padding: 5px 8px;
  }

  .status-text {
    display: none;
  }

  #develop-view {
    min-height: 0;
    flex-direction: row;
  }

  .develop-center {
    min-height: 0;
    flex: 1 1 auto;
  }

  .develop-sidebar {
    width: min(300px, 38vw);
    min-height: 0;
    flex: 0 0 min(300px, 38vw);
    border-top: none;
    border-left: 1px solid var(--line);
    padding: 8px 10px;
  }
}

/* 시작 암호 잠금 */

body.app-locked {
  overflow: hidden;
}

.password-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(8,127,118,.08), transparent 42%),
    var(--canvas);
}

.password-card {
  width: min(100%, 380px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.password-brand {
  margin: 0 0 12px;
  color: var(--teal-dark);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
}

.password-card h1 {
  margin: 0;
  color: var(--navy);
  font-size: 1.45rem;
}

.password-description {
  margin: 10px 0 24px;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.55;
}

.password-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: .8rem;
}

.password-card input {
  box-sizing: border-box;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.password-card input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8,127,118,.14);
}

.password-card button {
  width: 100%;
  height: 42px;
  margin-top: 8px;
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
  box-shadow: 0 8px 20px rgba(8,127,118,.24);
}

.password-card button:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.password-card button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

/* ---------- iPad(OPFS) 라이브러리 선택 대화상자 ---------- */

.library-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.library-picker-row {
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.library-picker-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: .85rem;
}

/* ---------- PWA 업데이트 토스트 ---------- */

.update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 200;
  font-size: .85rem;
  color: var(--ink);
}

.update-toast button {
  padding: 6px 10px;
}

.update-toast button:first-of-type {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.password-error {
  min-height: 2.4em;
  margin: 8px 0 0;
  color: var(--red);
  font-size: .78rem;
  line-height: 1.4;
}
