:root {
  color-scheme: light;
  --paper: #f5f2ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #18322e;
  --muted: #6d7773;
  --line: #dfe2da;
  --accent: #df6948;
  --accent-dark: #b94b31;
  --green: #1f5a4d;
  --green-soft: #dcebe5;
  --gold: #e9ad3c;
  --danger: #b33d38;
  --shadow: 0 18px 55px rgb(22 48 43 / 10%);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgb(223 105 72 / 28%); outline-offset: 2px; }

.app-shell {
  display: grid;
  grid-template: 74px minmax(0, 1fr) / 236px minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(245 242 234 / 92%);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.1rem; letter-spacing: -.02em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px 5px 12px 5px; color: white; background: var(--green); font: 700 1.2rem Georgia, serif; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.scope-button { display: inline-flex; max-width: min(34vw, 360px); min-height: 38px; align-items: center; gap: 7px; padding: 7px 11px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; color: var(--green); background: var(--surface); cursor: pointer; }
.scope-button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-label { color: var(--muted); font-size: .82rem; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--green-soft); color: var(--green); }
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-chip--muted { background: #ebe9e3; color: var(--muted); }
.status-chip--warning { background: #f6e7cc; color: #8c5b0d; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; }

.sidebar {
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 18px 24px;
  border-right: 1px solid var(--line);
}
.primary-nav { display: grid; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.nav-item span { width: 22px; font-size: 1.22rem; text-align: center; }
.nav-item:hover { background: rgb(255 255 255 / 60%); color: var(--ink); }
.nav-item.is-active { color: var(--green); background: var(--green-soft); font-weight: 750; }
.sidebar-note { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: rgb(255 253 248 / 70%); }
.sidebar-note p { margin: 7px 0 0; color: var(--muted); font-size: .77rem; line-height: 1.55; }

.main-content { min-width: 0; padding: 44px clamp(24px, 4vw, 70px) 80px; }
.view { display: none; max-width: 1280px; margin: 0 auto; }
.view.is-active { display: block; animation: fade-up .28s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(7px); } }
.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.view-header h1 { margin: 5px 0 7px; font: 500 clamp(2rem, 4vw, 3.1rem)/1 Georgia, "Times New Roman", serif; letter-spacing: -.04em; }
.view-header p { margin: 0; color: var(--muted); }
.view-actions { display: flex; align-items: flex-end; gap: 10px; }
.photo-view-switch { margin: 0; }
.display-mode { display: grid; gap: 5px; color: var(--muted); font-size: .7rem; font-weight: 750; }
.display-mode select { min-height: 42px; padding: 8px 34px 8px 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--surface); }
.eyebrow { color: var(--accent-dark); font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.button { min-height: 42px; padding: 10px 17px; border: 1px solid var(--green); border-radius: 11px; color: white; background: var(--green); font-weight: 750; cursor: pointer; transition: transform .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); background: #17483e; }
.button:disabled { opacity: .45; transform: none; cursor: not-allowed; }
.button--secondary { border-color: var(--line); color: var(--ink); background: var(--surface); }
.button--secondary:hover { background: white; }
.button--danger { border-color: #f0cbc7; color: var(--danger); background: #fff5f3; }
.button--full { width: 100%; }
.text-button { padding: 4px; border: 0; color: var(--green); background: transparent; font-weight: 700; cursor: pointer; }
.is-hidden { display: none !important; }

.summary-strip { display: flex; min-height: 42px; align-items: center; gap: 22px; margin-bottom: 18px; color: var(--muted); font-size: .82rem; }
.summary-strip strong { color: var(--ink); }
.review-guide { margin: -8px 0 22px; padding: 20px; }
.review-guide-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.review-guide-heading h2 { margin: 4px 0 0; font: 500 1.35rem Georgia, "Times New Roman", serif; }
.review-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.review-steps li { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 7px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.review-steps strong { font-size: .88rem; }
.review-steps span { flex: 1; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.review-steps .button { width: 100%; margin-top: 4px; }
.review-tip { margin: 13px 2px 0; color: var(--muted); font-size: .76rem; }
.active-scope { display: grid; max-width: 1280px; grid-template-columns: minmax(220px, .9fr) minmax(240px, 1.4fr) auto; align-items: center; gap: 18px; margin: 0 auto 26px; padding: 16px 18px; }
.active-scope strong, .active-scope small { display: block; }
.active-scope strong { margin: 4px 0; }
.active-scope small { color: var(--muted); }
.active-scope-paths { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; }
.scope-path-chip, .scope-empty { max-width: 100%; padding: 6px 9px; overflow: hidden; border-radius: 999px; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.scope-path-chip { color: var(--green); background: var(--green-soft); }
.scope-empty { color: var(--danger); background: #fbecea; }
.folder-path-focus { cursor: help; }
.folder-path-focus:focus-visible { outline: 3px solid rgb(223 105 72 / 28%); outline-offset: 2px; }
.folder-path-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(720px, calc(100vw - 24px));
  padding: 9px 11px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 9px;
  color: white;
  background: rgb(24 50 46 / 96%);
  box-shadow: 0 10px 28px rgb(22 48 43 / 24%);
  font-size: .75rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  pointer-events: none;
  white-space: pre-wrap;
}
.folder-path-tooltip[hidden] { display: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 17px; }
.photo-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 20px rgb(22 48 43 / 4%); }
.photo-thumb { position: relative; display: grid; width: 100%; aspect-ratio: 4 / 3; place-items: center; overflow: hidden; border: 0; background: #e7e8e1; cursor: pointer; }
.photo-thumb img { transition: filter .2s ease; }
.photo-thumb:hover img { filter: brightness(.96); }
.photo-placeholder { color: #89908d; font-size: .78rem; }
.photo-badges { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.mini-badge { padding: 5px 7px; border-radius: 999px; color: white; background: rgb(24 50 46 / 78%); backdrop-filter: blur(8px); font-size: .68rem; font-weight: 800; }
.mini-badge--star { color: #493500; background: rgb(244 194 63 / 88%); }
.mini-badge--delete { background: rgb(151 59 53 / 88%); }
.photo-meta { padding: 13px 14px 14px; }
.photo-title { overflow: hidden; margin: 0 0 4px; font-size: .91rem; text-overflow: ellipsis; white-space: nowrap; }
.photo-path { overflow: hidden; margin: 0 0 11px; color: var(--muted); font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.photo-controls { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stars { display: flex; gap: 0; }
.star { padding: 1px 2px; border: 0; color: #c9c7bf; background: transparent; font-size: 1.05rem; line-height: 1; cursor: pointer; }
.star.is-on { color: var(--gold); }
.toggle-row { display: flex; gap: 5px; }
.toggle { padding: 5px 7px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: white; font-size: .68rem; cursor: pointer; }
.toggle.is-on { border-color: #aed1c5; color: var(--green); background: var(--green-soft); font-weight: 800; }
.toggle--delete.is-on { border-color: #d9aaa5; color: var(--danger); background: #fbecea; }
.load-more { display: flex; justify-content: center; padding-top: 26px; }
.photo-load-sentinel { min-height: 48px; padding: 18px 0 0; color: var(--muted); text-align: center; font-size: .82rem; }

.review-deck { width: min(100%, 820px); margin: 0 auto; }
.review-deck-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: 10px; color: var(--muted); }
.review-deck-top strong { color: var(--ink); font-size: .88rem; }
.review-deck-top small { text-align: center; }
.review-deck-card { overflow: hidden; transform-origin: 50% 100%; transition: transform .18s ease; will-change: transform; }
.review-deck-card:focus-visible { outline: 3px solid rgb(223 105 72 / 28%); outline-offset: 4px; }
.review-deck-image { position: relative; display: flex; width: 100%; height: auto; min-height: 0; align-items: center; justify-content: center; overflow: visible; background: transparent; cursor: grab; touch-action: pan-y; user-select: none; }
.review-deck-image:active { cursor: grabbing; }
.review-deck-image .photo-placeholder { display: grid; width: 100%; min-height: clamp(280px, 52dvh, 620px); place-items: center; background: #e7e8e1; }
.review-deck-image img { display: block; width: auto; height: auto; max-width: 100%; max-height: 72dvh; object-fit: scale-down; object-position: center; image-orientation: from-image; pointer-events: none; }
.review-swipe-hint { position: absolute; z-index: 2; top: 24px; padding: 9px 13px; border: 3px solid currentColor; border-radius: 9px; background: rgb(255 255 255 / 82%); font-weight: 900; letter-spacing: .08em; opacity: 0; pointer-events: none; }
.review-swipe-hint--delete { left: 22px; color: var(--danger); transform: rotate(-7deg); }
.review-swipe-hint--keep { right: 22px; color: var(--green); transform: rotate(7deg); }
.review-deck-details { padding: 17px 20px 20px; }
.review-deck-title { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.review-deck-title h2 { overflow: hidden; margin: 0; font: 500 1.35rem Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.review-deck-title p { grid-column: 1; overflow: hidden; margin: 0; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.review-star { grid-row: 1 / 3; grid-column: 2; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; color: #bbb8ae; background: white; font-size: 1.65rem; cursor: pointer; }
.review-star.is-on { color: var(--gold); background: #fff9df; }
.review-current-status { display: flex; justify-content: center; margin: 14px 0 10px; }
.review-current-status span { padding: 5px 10px; border-radius: 999px; color: var(--muted); background: #eeece5; font-size: .7rem; font-weight: 800; }
.review-deck-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; }
.review-action { min-height: 52px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: white; font-weight: 850; cursor: pointer; }
.review-action--delete { border-color: #e4bbb7; color: var(--danger); background: #fff5f3; }
.review-action--keep { border-color: #a8cbbf; color: var(--green); background: #edf7f2; }
.review-action--later { min-width: 70px; color: var(--muted); }
.review-action:disabled { opacity: .48; cursor: wait; }
.review-complete { padding: 40px 24px; text-align: center; }
.review-complete h2 { margin: 7px 0 8px; font: 500 1.8rem Georgia, serif; }
.review-complete p { margin: 0; color: var(--muted); }
.review-complete-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }

.selection-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; margin-bottom: 20px; padding: 16px; }
.selection-toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: .75rem; font-weight: 750; }
.selection-toolbar select { min-height: 40px; padding: 8px 34px 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.selection-toolbar .segmented { margin: 0; }
.selection-toolbar > .button { margin-left: auto; }
.selection-thresholds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: -4px 0 20px; padding: 18px 20px; }
.selection-thresholds label { display: grid; gap: 9px; min-width: 0; }
.selection-thresholds label > span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.selection-thresholds output { color: var(--accent-dark); font-weight: 850; }
.selection-thresholds input[type="range"] { min-height: 28px; padding: 0; accent-color: var(--green); cursor: pointer; }
.selection-thresholds small { color: var(--muted); }
.selection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 17px; }
.selection-card { position: relative; }
.selection-card.is-excluded { opacity: .6; }
.selection-thumb { position: relative; display: flex; width: 100%; height: auto; min-height: 0; aspect-ratio: auto; align-items: center; justify-content: center; padding: 0; overflow: hidden; border: 0; background: transparent; cursor: pointer; }
.selection-thumb .photo-placeholder { display: grid; width: 100%; min-height: 180px; aspect-ratio: 4 / 3; place-items: center; background: #e7e8e1; }
.selection-card .selection-thumb img { display: block; width: auto; height: auto; max-width: 100%; max-height: 320px; object-fit: scale-down; object-position: center; image-orientation: from-image; transition: filter .2s ease; }
.selection-card .selection-thumb:hover img { filter: brightness(.96); }
.selection-score { position: absolute; top: 10px; left: 10px; padding: 6px 9px; border-radius: 999px; color: white; background: rgb(24 50 46 / 84%); font-size: .73rem; font-weight: 800; }
.selection-body { display: grid; gap: 9px; }
.selection-reasons { min-height: 48px; margin: 0; padding-left: 18px; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.selection-body .button { text-align: center; text-decoration: none; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #ebe9e2; }
.photo-filter-switch { margin-bottom: 16px; }
.segment { padding: 8px 14px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-weight: 700; cursor: pointer; }
.segment.is-active { color: var(--ink); background: var(--surface-strong); box-shadow: 0 2px 8px rgb(20 40 36 / 8%); }
.stack-list { display: grid; gap: 13px; }
.panel, .list-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 24px rgb(22 48 43 / 4%); }
.list-card { padding: 17px; }
.duplicate-card { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; }
.duplicate-file { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 13px; min-width: 0; }
.duplicate-thumb { width: 78px; height: 59px; overflow: hidden; border-radius: 11px; background: #e7e8e1; }
.duplicate-file strong, .duplicate-file small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duplicate-file small { margin-top: 5px; color: var(--muted); }
.duplicate-file.is-delete-candidate { padding: 7px; border-radius: 12px; background: #fff1ef; }
.duplicate-review-button { min-height: 34px; margin-top: 9px; padding: 6px 9px; font-size: .7rem; }
.match-score { min-width: 72px; color: var(--accent-dark); text-align: center; font: 600 1rem Georgia, serif; }
.candidate-label { grid-column: 1 / -1; color: var(--danger); font-size: .72rem; font-weight: 800; }

.notice { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; padding: 14px 17px; border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; background: #fff7ef; }
.notice span { color: var(--muted); font-size: .82rem; }
.folder-card { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 22px; }
.folder-side { min-width: 0; }
.folder-side h3 { overflow: hidden; margin: 0 0 6px; text-overflow: ellipsis; white-space: nowrap; }
.folder-side p { margin: 0; color: var(--muted); font-size: .78rem; }
.folder-metrics { min-width: 155px; text-align: center; }
.folder-metrics strong { display: block; font: 500 1.9rem Georgia, serif; }
.folder-metrics small, .folder-metrics span { display: block; color: var(--muted); font-size: .72rem; }
.folder-metrics span { margin-top: 4px; }
.folder-list-summary { margin: -8px 0 14px; color: var(--muted); font-size: .78rem; }
.folder-actions { grid-column: 1 / -1; display: flex; justify-content: center; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }

.job-launcher { margin-bottom: 26px; padding: 20px; }
.job-scope { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.job-scope strong, .job-scope small { display: block; }
.job-scope strong { margin: 5px 0; overflow-wrap: anywhere; }
.job-scope small { color: var(--muted); }
.account-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; padding: 18px 20px; }
.account-panel strong, .account-panel small { display: block; }
.account-panel strong { margin: 5px 0; }
.account-panel small { color: var(--muted); }
.account-actions { display: flex; align-items: center; gap: 12px; }
.google-account-config { flex: 1; min-width: 0; }
.google-account-config label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.google-account-config input { max-width: 420px; }
.job-launcher label { display: block; margin-bottom: 8px; font-weight: 750; }
.job-launcher label span { color: var(--muted); font-size: .75rem; font-weight: 400; }
input { width: 100%; min-height: 45px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.job-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.deletion-review { margin-bottom: 26px; padding: 20px; }
.deletion-review-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.deletion-review-heading h2 { margin: 5px 0 6px; font: 500 1.45rem Georgia, serif; }
.deletion-review-heading p { margin: 0; color: var(--muted); font-size: .8rem; }
.deletion-review-actions { display: flex; flex: 0 0 auto; gap: 9px; }
.deletion-review-note { margin: 14px 0; padding: 10px 12px; border-radius: 10px; color: var(--muted); background: #fff7ef; font-size: .75rem; line-height: 1.55; }
.deletion-candidate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.deletion-candidate-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: white; }
.deletion-candidate-thumb { display: grid; width: 96px; height: 72px; padding: 0; place-items: center; align-self: center; overflow: hidden; border: 0; background: #e7e8e1; cursor: pointer; }
.deletion-candidate-body { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px; }
.deletion-candidate-body strong, .deletion-candidate-body small { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deletion-candidate-body small, .deletion-candidate-body span { color: var(--muted); font-size: .67rem; }
.deletion-candidate-body .button { min-height: 34px; margin-top: auto; padding: 6px 9px; font-size: .7rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }
.section-heading h2 { margin: 0; font: 500 1.35rem Georgia, serif; }
.job-history-controls { display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: 10px; }
.job-history-controls label { display: grid; gap: 4px; color: var(--muted); font-size: .68rem; font-weight: 750; }
.job-history-controls select { min-height: 38px; padding: 7px 30px 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); }
.job-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 22px; }
.job-pagination span { min-width: 72px; color: var(--muted); font-size: .75rem; text-align: center; }
.job-card { display: grid; grid-template-columns: minmax(160px, .8fr) minmax(180px, 1.4fr) auto; align-items: center; gap: 18px; }
.job-title strong { display: block; }
.job-title small { color: var(--muted); }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: #e6e6df; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s ease; }
.job-message { margin: 7px 0 0; color: var(--muted); font-size: .73rem; }
.job-status { font-size: .74rem; font-weight: 800; text-transform: uppercase; }
.job-status--failed { color: var(--danger); }
.job-status--succeeded { color: var(--green); }
.job-status--cancelled { color: var(--muted); }
.job-status-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.text-button--danger { color: var(--danger); }
.job-result-body h3 { margin: 24px 0 10px; font-size: .9rem; }
.job-result-status { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 11px; background: #eeece5; }
.job-result-status > span:last-child { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.job-result-paths { display: flex; flex-wrap: wrap; gap: 7px; }
.job-result-summary { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(100px, 1fr); margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.job-result-summary dt, .job-result-summary dd { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.job-result-summary dt { color: var(--muted); background: #f0eee7; font-size: .75rem; font-weight: 750; }
.job-result-summary dd { font-size: .82rem; }
.job-result-summary > :nth-last-child(-n + 2) { border-bottom: 0; }

.empty-state { display: grid; min-height: 230px; place-items: center; padding: 30px; border: 1px dashed #c7cbc4; border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font: 500 1.25rem Georgia, serif; }
.skeleton { min-height: 180px; border-radius: var(--radius); background: linear-gradient(90deg, #e9e7e0 25%, #f5f3ed 38%, #e9e7e0 62%); background-size: 400% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.modal { width: min(92vw, 760px); max-height: 90vh; padding: 0; overflow: auto; border: 0; border-radius: 22px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.modal--wide { width: min(94vw, 940px); }
.modal::backdrop { background: rgb(14 31 28 / 55%); backdrop-filter: blur(4px); }
.modal-close { position: sticky; z-index: 3; top: 14px; float: right; display: grid; width: 36px; height: 36px; margin: 14px 14px -50px 0; place-items: center; border: 0; border-radius: 50%; background: rgb(255 255 255 / 88%); box-shadow: 0 4px 14px rgb(0 0 0 / 12%); font-size: 1.25rem; cursor: pointer; }
.detail-preview { display: grid; width: 100%; height: clamp(280px, 62vh, 720px); padding: 12px; place-items: center; overflow: hidden; background: #e7e8e1; }
.detail-preview img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; image-orientation: from-image; }
.detail-body { padding: 24px; }
.detail-body h2 { margin: 0 0 7px; font: 500 1.65rem Georgia, serif; }
.detail-body > p { color: var(--muted); overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.similar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 15px; }
.thumbnail-letterbox { display: grid; width: 100%; aspect-ratio: 4 / 3; place-items: center; overflow: hidden; border-radius: 10px; background: #e7e8e1; }
.photo-thumb img, .duplicate-thumb img, .deletion-candidate-thumb img, .thumbnail-letterbox img { width: 100%; height: 100%; object-fit: contain; object-position: center; image-orientation: from-image; }
.similar-item small { display: block; overflow: hidden; margin-top: 5px; text-overflow: ellipsis; white-space: nowrap; }
.merge-body { padding: 28px; }
.merge-body h2 { margin: 0 0 6px; font: 500 1.8rem Georgia, serif; }
.merge-overview { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin: 20px 0; }
.merge-folder { padding: 14px; border: 1px solid var(--line); border-radius: 12px; overflow-wrap: anywhere; }
.merge-folder.target { border-color: #98c3b5; background: var(--green-soft); }
.operation-list { max-height: 280px; margin: 16px 0; padding: 0; overflow: auto; list-style: none; border: 1px solid var(--line); border-radius: 12px; }
.operation-list li { display: grid; grid-template-columns: 32px 95px 1fr; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .76rem; }
.operation-list li:last-child { border-bottom: 0; }
.confirm-row { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; color: var(--muted); font-size: .82rem; }
.confirm-row input { width: 18px; min-height: 18px; margin-top: 1px; }
.folder-picker { padding: 30px; }
.folder-picker h2 { margin: 5px 0 8px; font: 500 1.7rem Georgia, serif; }
.folder-picker-location-label { display: block; margin-top: 16px; color: var(--muted); font-weight: 750; }
.folder-picker > p { margin: 0 46px 16px 0; color: var(--muted); overflow-wrap: anywhere; }
.folder-picker-actions { display: flex; gap: 9px; margin-bottom: 16px; }
.folder-picker-selection-heading { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.folder-picker-selected { display: grid; gap: 6px; max-height: 140px; margin-bottom: 14px; overflow: auto; }
.folder-picker-selection { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--green-soft); font-size: .78rem; }
.folder-picker-selection span { overflow-wrap: anywhere; }
.folder-picker-draft-note { display: block; margin: -6px 0 12px; color: var(--muted); }
.folder-picker-footer { position: sticky; z-index: 2; bottom: -30px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 16px -30px -30px; padding: 14px 30px; border-top: 1px solid var(--line); background: rgb(255 253 248 / 96%); box-shadow: 0 -8px 24px rgb(22 48 43 / 7%); backdrop-filter: blur(12px); }
.folder-picker-footer strong { font-size: .8rem; }
.folder-picker-list { display: grid; gap: 7px; max-height: 48vh; overflow: auto; }
.folder-picker-item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; text-align: left; }
.folder-picker-item:hover { border-color: #98c3b5; background: var(--green-soft); }
.folder-picker-identity { min-width: 0; }
.folder-picker-identity strong, .folder-picker-identity small { display: block; }
.folder-picker-identity small { overflow: hidden; max-width: 420px; margin-top: 3px; color: var(--muted); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.folder-picker-item-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.folder-picker-select { min-height: 34px; padding: 6px 10px; }

.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 13px 17px; border-radius: 12px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #dfebe4 0, transparent 34%), radial-gradient(circle at 90% 90%, #f4dac8 0, transparent 30%), var(--paper); }
.login-card { width: min(100%, 460px); padding: 38px; border: 1px solid rgb(255 255 255 / 75%); border-radius: 24px; background: rgb(255 253 248 / 90%); box-shadow: var(--shadow); }
.brand--login { margin-bottom: 40px; }
.login-card h1 { margin: 8px 0 12px; font: 500 2.25rem/1.1 Georgia, serif; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.login-card form label { display: block; margin-bottom: 7px; font-size: .82rem; font-weight: 750; }
.login-card form .button { margin-top: 12px; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: .8rem; }
.login-card .login-footnote { margin: 22px 0 0; font-size: .74rem; }
.nextcloud-login-box { display: flex; align-items: center; gap: 13px; margin: 0 0 15px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.nextcloud-login-box strong, .nextcloud-login-box small { display: block; }
.nextcloud-login-box small { overflow: hidden; max-width: 310px; margin-top: 4px; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.nextcloud-cloud { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: #0082c9; font-size: 1.3rem; }
.manual-login-link { display: block; margin-top: 13px; color: var(--green); font-size: .82rem; font-weight: 750; text-align: center; }
.login-progress { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; color: var(--muted); font-size: .82rem; }
.spinner { width: 17px; height: 17px; border: 2px solid #c7d2ce; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .app-shell { display: block; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .topbar { height: 64px; gap: 10px; padding: 0 12px; }
  .brand { flex: 0 0 auto; }
  .topbar-actions { min-width: 0; flex: 1; justify-content: flex-end; gap: 8px; }
  .topbar .status-chip { display: none; }
  .scope-button { min-width: 0; max-width: min(52vw, 360px); }
  .user-label { display: none; }
  .sidebar { position: fixed; z-index: 30; top: auto; right: 0; bottom: 0; left: 0; height: calc(66px + env(safe-area-inset-bottom)); padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-right: 0; background: rgb(245 242 234 / 96%); backdrop-filter: blur(18px); }
  .primary-nav { grid-template-columns: repeat(5, 1fr); }
  .nav-item { flex-direction: column; gap: 2px; padding: 5px; font-size: .68rem; text-align: center; }
  .nav-item span { font-size: 1.08rem; }
  .selection-toolbar { align-items: stretch; flex-direction: column; }
  .selection-toolbar > .button { width: 100%; margin-left: 0; }
  .selection-thresholds { grid-template-columns: 1fr; gap: 18px; }
  .selection-card .selection-thumb img { max-height: 260px; }
  .sidebar-note { display: none; }
  .main-content { padding: 28px 15px 40px; }
  .view-header { align-items: stretch; flex-direction: column; }
  .view-header > .button { width: 100%; }
  .view-actions { align-items: stretch; flex-direction: column; }
  .photo-view-switch { display: grid; grid-template-columns: 1fr 1fr; }
  .view-header h1 { font-size: 2.15rem; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .review-steps { grid-template-columns: 1fr; }
  .active-scope { grid-template-columns: 1fr; }
  .active-scope .button { width: 100%; }
  .scope-path-chip { border-radius: 10px; overflow-wrap: anywhere; white-space: normal; }
  .review-guide-heading { align-items: flex-start; }
  .photo-meta { padding: 10px; }
  .photo-path { display: none; }
  .photo-controls { align-items: flex-end; flex-direction: column; }
  .review-deck { width: 100%; }
  .review-deck-top { grid-template-columns: auto 1fr; }
  .review-deck-top small { display: none; }
  .review-deck-top .text-button { justify-self: end; }
  .review-deck-image img { max-height: 58dvh; }
  .review-deck-details { padding: 14px 12px calc(16px + env(safe-area-inset-bottom)); }
  .review-deck-title h2 { font-size: 1.12rem; }
  .review-deck-actions { gap: 7px; }
  .review-action { min-height: 54px; padding: 9px 10px; }
  .review-action--later { min-width: 62px; }
  .review-complete-actions { align-items: stretch; flex-direction: column; }
  .stars { align-self: flex-start; }
  .duplicate-card, .folder-card { grid-template-columns: 1fr; }
  .duplicate-card .match-score, .folder-metrics { text-align: left; }
  .folder-actions { flex-direction: column; }
  .notice { align-items: flex-start; flex-direction: column; gap: 5px; }
  .job-card { grid-template-columns: 1fr; gap: 10px; }
  .job-history-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .job-history-controls { justify-content: flex-start; }
  .job-status-actions { justify-content: flex-start; }
  .account-panel { align-items: flex-start; flex-direction: column; }
  .job-scope { align-items: stretch; flex-direction: column; }
  .deletion-review-heading { align-items: stretch; flex-direction: column; }
  .deletion-review-actions { display: grid; grid-template-columns: 1fr; }
  .deletion-candidate-grid { grid-template-columns: 1fr; }
  .merge-overview { grid-template-columns: 1fr; }
  #folder-picker-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; overflow: hidden; border-radius: 0; }
  #folder-picker-dialog .modal-close { top: calc(10px + env(safe-area-inset-top)); margin-top: calc(10px + env(safe-area-inset-top)); }
  .folder-picker { display: flex; height: 100%; min-height: 0; flex-direction: column; padding: calc(20px + env(safe-area-inset-top)) 16px 0; overflow: hidden; }
  .folder-picker > p { margin-right: 46px; margin-bottom: 10px; }
  .folder-picker-actions { display: grid; grid-template-columns: 1fr 1.4fr; margin-bottom: 12px; }
  .folder-picker-actions .button { min-height: 44px; padding: 8px 10px; }
  .folder-picker-selected { max-height: min(18dvh, 120px); flex: 0 1 auto; }
  .folder-picker-list { min-height: 140px; max-height: none; flex: 1 1 auto; overscroll-behavior: contain; }
  .folder-picker-item { align-items: stretch; flex-direction: column; }
  .folder-picker-identity small { max-width: 100%; overflow-wrap: anywhere; text-overflow: initial; white-space: normal; }
  .folder-picker-item-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(88px, .55fr); }
  .folder-picker-item-actions .button, .folder-picker-open { min-height: 44px; }
  .folder-picker-footer { position: static; align-items: stretch; flex: 0 0 auto; flex-direction: column; margin: 12px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .folder-picker-footer .button { width: 100%; }
  .toast { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
}

.selection-defect-filter { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.selection-defect-filter .chip { padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; transition: all .15s ease; font-family: inherit; }
.selection-defect-filter .chip:hover { background: #eeebe3; color: var(--text); }
.selection-defect-filter .chip.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

.keyboard-shortcuts-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 14px; padding: 7px 12px; margin-top: 6px; font-size: .8rem; color: var(--muted); background: rgba(0,0,0,.025); border: 1px dashed var(--line); border-radius: 8px; }
.shortcut-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
kbd { display: inline-block; padding: 2px 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .72rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-bottom: 2px solid #ccc; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }

.photo-card { outline: 2px solid transparent; transition: outline-color .15s ease, box-shadow .15s ease; }
.photo-card:focus, .photo-card.is-focused { outline-color: var(--accent); outline-offset: 2px; box-shadow: 0 0 0 3px rgba(0, 112, 90, 0.2); }

.detail-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.detail-nav-buttons { display: flex; gap: 8px; }
.detail-nav-counter { font-size: .85rem; color: var(--muted); font-weight: 500; }
.detail-shortcuts-hint { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 14px; padding: 8px 12px; font-size: .78rem; color: var(--muted); background: rgba(0,0,0,.025); border-radius: 6px; }

.preview-cache-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.preview-cache-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cache-progress-bar-wrapper { width: 100%; height: 8px; background: rgba(0,0,0,.06); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.cache-progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.preview-cache-note { font-size: .82rem; color: var(--muted); margin: 0; line-height: 1.5; }
.button--danger-text { color: #b42318; border-color: rgba(180, 35, 24, .3); }
.button--small { min-height: 34px; padding: 6px 12px; font-size: .8rem; }
.button--primary { border-color: var(--green); color: white; background: var(--green); }
.button--primary:hover { background: #17483e; }

.photo-card { position: relative; }
.photo-card-select {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid white;
  background: rgba(24, 50, 46, 0.4);
  color: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  font-size: .88rem;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
  opacity: 0.55;
}
.photo-card:hover .photo-card-select,
.photo-grid.is-selecting .photo-card-select {
  opacity: 1;
}
.photo-card-select:hover {
  transform: scale(1.12);
  background: rgba(24, 50, 46, 0.75);
}
.photo-card.is-selected {
  outline: 3px solid var(--green) !important;
  outline-offset: -1px;
  box-shadow: 0 0 0 4px rgba(31, 90, 77, 0.25) !important;
}
.photo-card.is-selected .photo-card-select {
  opacity: 1;
  background: var(--green);
  border-color: white;
  color: white;
}

.selection-floating-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px 8px 24px;
  box-shadow: 0 12px 36px rgba(22, 48, 43, 0.22);
  max-width: calc(100vw - 32px);
  animation: selection-bar-in .2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes selection-bar-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.selection-floating-bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
  font-size: .88rem;
  color: var(--ink);
  white-space: nowrap;
}
.selection-floating-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .selection-floating-bar {
    border-radius: 18px;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    bottom: 16px;
    gap: 10px;
  }
  .selection-floating-bar-info {
    justify-content: center;
  }
  .selection-floating-bar-actions {
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .brand > span:last-child { display: none; }
  .scope-button { max-width: none; flex: 1; }
  .brand strong { font-size: .98rem; }
  .photo-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
