:root {
  --bg0: #0c1117;
  --bg1: #141c26;
  --bg2: #1c2734;
  --line: rgba(232, 236, 242, 0.1);
  --text: #e8ecf2;
  --muted: #8b97a8;
  --accent: #3dd6c6;
  --accent-dim: rgba(61, 214, 198, 0.16);
  --danger: #ff6b7a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: clamp(12px, 2.5vw, 16px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font-display: "Outfit", "IBM Plex Sans KR", sans-serif;
  --font-body: "IBM Plex Sans KR", "Outfit", sans-serif;
  /* photo-first: compact chrome, larger content */
  --space: clamp(6px, 1.6vw, 12px);
  --space-lg: clamp(8px, 2vw, 16px);
  --fs: clamp(0.88rem, 0.82rem + 0.25vw, 0.98rem);
  --fs-sm: clamp(0.68rem, 0.65rem + 0.2vw, 0.78rem);
  --fs-lg: clamp(1.05rem, 0.95rem + 0.45vw, 1.3rem);
  --btn-pad-y: 6px;
  --btn-pad-x: 10px;
  --touch: 36px;
  --app-max: 720px;
  --cols: 2;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 214, 198, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(88, 140, 255, 0.1), transparent 50%),
    linear-gradient(180deg, #0a0e14 0%, var(--bg0) 40%, #0d1520 100%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

.app {
  max-width: var(--app-max);
  width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--space) + var(--safe-b));
}

.topbar {
  padding: calc(8px + var(--safe-t)) var(--space-lg) 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 8, 14, 0.88);
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-gate.hidden {
  display: none !important;
}

.browser-gate {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(4, 8, 14, 0.92);
  display: grid;
  place-items: center;
  padding: 20px;
}

.browser-gate.hidden {
  display: none !important;
}

.browser-gate-card {
  width: min(100%, 400px);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
}

.browser-gate-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
}

.browser-gate-steps {
  margin: 12px 0 18px;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.browser-gate-steps li + li {
  margin-top: 6px;
}

.browser-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.browser-gate-note {
  margin: 12px 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.45;
}

.browser-gate-note.hidden {
  display: none !important;
}

.install-banner {
  margin: 0 var(--space-lg) 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(61, 214, 198, 0.35);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.install-banner.hidden {
  display: none !important;
}

.install-banner p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text);
  flex: 1;
}

.install-banner-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.auth-card {
  width: min(380px, 100%);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-card h2 {
  margin: 0;
  font-family: var(--font-display);
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.search-input {
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 220px;
  font: inherit;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 30px;
  outline: none;
}

.search-input:focus {
  border-color: rgba(61, 214, 198, 0.55);
}

.btn.full {
  width: 100%;
}

.devices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50dvh;
  overflow: auto;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
}

.device-row.current {
  border-color: rgba(61, 214, 198, 0.45);
  background: var(--accent-dim);
}

.device-row .meta {
  flex: 1;
  min-width: 0;
}

.device-row strong {
  display: block;
  font-size: 0.88rem;
}

.device-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
}

.brand-mark {
  width: clamp(12px, 3vw, 14px);
  height: clamp(12px, 3vw, 14px);
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #5b8cff);
  box-shadow: 0 0 0 4px var(--accent-dim);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  word-break: break-all;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 4px clamp(8px, 2.5vw, 14px) 6px;
  padding: 3px;
  background: rgba(20, 28, 38, 0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  position: sticky;
  top: max(4px, var(--safe-t));
  z-index: 20;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 4px;
  min-height: 34px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

main {
  flex: 1;
  padding: 4px var(--space-lg) var(--space-lg);
  width: 100%;
  min-width: 0;
}

.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: var(--btn-pad-y) var(--btn-pad-x);
  min-height: var(--touch);
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn.sm {
  font-size: 0.75rem;
  padding: 5px 9px;
  min-height: 30px;
  border-radius: 8px;
  font-weight: 600;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, #2fc4b4, #3dd6c6 40%, #5b8cff);
  border-color: transparent;
  color: #041018;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: rgba(255, 107, 122, 0.12);
  border-color: rgba(255, 107, 122, 0.35);
  color: var(--danger);
}

.btn.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 0;
  font-size: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.field.grow {
  flex: 1;
  min-width: 160px;
}

.field input,
.field select {
  font: inherit;
  color: var(--text);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: rgba(61, 214, 198, 0.55);
}

/* Explorer chrome */
.explorer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.explorer-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.address-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg1);
}

.breadcrumb {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.crumb {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.crumb:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.crumb.current {
  color: var(--text);
  cursor: default;
}

.crumb-sep {
  color: var(--muted);
  opacity: 0.45;
  font-size: 0.85rem;
  user-select: none;
  flex-shrink: 0;
}

.explorer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0 4px;
}

.tool-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tool-right {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tool-right.has-selection {
  display: flex;
}

.sel-count {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 2px;
}

.drag-hint {
  display: none;
}

.explorer-body {
  margin-top: 4px;
}

.folder-list {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.folder-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(28, 39, 52, 0.95), rgba(20, 28, 38, 0.95));
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.folder-item:hover {
  border-color: rgba(61, 214, 198, 0.45);
  background: rgba(61, 214, 198, 0.08);
}

.folder-item .folder-open {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.folder-item .folder-open:active {
  opacity: 0.9;
}

.folder-item .folder-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.folder-item .folder-rename {
  flex-shrink: 0;
  align-self: center;
  margin-right: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.folder-item .folder-rename:hover,
.folder-item .folder-rename:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.folder-icon {
  width: 28px;
  height: 22px;
  border-radius: 3px 3px 5px 5px;
  background: linear-gradient(180deg, #4ae0d0, #2aa89c);
  position: relative;
  flex-shrink: 0;
}

.folder-icon::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 0;
  width: 11px;
  height: 6px;
  border-radius: 2px 2px 0 0;
  background: #2aa89c;
}

.folder-item strong {
  font-weight: 600;
}

.folder-item.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px rgba(61, 214, 198, 0.35);
}


.photo-card.selectable {
  position: relative;
}

.photo-card .sel-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.7);
  display: grid;
  place-items: center;
  pointer-events: auto;
}

.photo-card .sel-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.photo-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.photo-card.dragging {
  opacity: 0.55;
}

.share-badge {
  margin: 8px 0 0;
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 10px;
  border-radius: 999px;
}

.share-app .topbar {
  padding-bottom: 4px;
}

.viewer-modal {
  max-width: min(960px, calc(100vw - 16px));
  width: 100%;
  padding: 0;
  border: 0;
  background: #05080c;
}

.viewer-modal::backdrop {
  background: rgba(0, 0, 0, 0.85);
}

.viewer {
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
}

.viewer-stage {
  height: clamp(240px, 62dvh, 640px) !important;
  border-radius: 0;
}

.viewer-info {
  padding: 14px 16px 18px;
  background: var(--bg1);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viewer-info h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  word-break: break-all;
}

.viewer-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.gallery-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(20, 28, 38, 0.7);
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.gallery-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.gallery-map-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg2);
  min-height: 420px;
  height: min(62dvh, 560px);
}

.gallery-map {
  width: 100%;
  height: 100%;
  min-height: 420px;
  z-index: 1;
}

.map-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  margin: 0;
  background: rgba(12, 17, 23, 0.88);
}

.map-empty.hidden {
  display: none !important;
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-family: var(--font-body);
}

.leaflet-popup-content .map-pop {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 140px;
}

.leaflet-popup-content .map-pop img {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.leaflet-popup-content .map-pop button {
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 600;
  background: #2aa89c;
  color: #041018;
  cursor: pointer;
}

.list-count {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.scroll-sentinel {
  height: 1px;
  margin: 8px 0 16px;
}

.scroll-sentinel::after {
  content: "불러오는 중…";
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 8px;
}

.scroll-sentinel.done::after {
  content: "모두 표시됨";
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(4px, 1.2vw, 8px);
}

.photo-card {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card .badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.72);
  color: var(--accent);
  backdrop-filter: blur(6px);
}

.photo-card .sel-check {
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.photo-card .sel-check input {
  width: 13px;
  height: 13px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  line-height: 1.5;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

/* Camera — native-style full stage */
.app.camera-mode .topbar {
  display: none;
}

.app.camera-mode main {
  padding: 0 0 calc(8px + var(--safe-b));
}

.app.camera-mode .tabs {
  margin: 8px 12px;
}

.camera-screen {
  position: relative;
  margin: 0 calc(var(--space-lg) * -1);
  height: calc(100dvh - clamp(72px, 18vw, 96px) - var(--safe-t));
  min-height: min(420px, 70dvh);
}

.app.camera-mode .camera-screen {
  height: calc(100dvh - clamp(64px, 16vw, 80px) - var(--safe-t));
}

.camera-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  border-radius: 0;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
}

.cam-hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 14px calc(18px + var(--safe-b));
  pointer-events: none;
}

.cam-hud > * {
  pointer-events: auto;
}

.cam-hud-top,
.cam-hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-chip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 12, 18, 0.55);
  color: #fff;
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 5px 9px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

.hud-chip strong {
  color: var(--accent);
  font-weight: 700;
}

.folder-chip {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.folder-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 12, 18, 0.55);
  color: #fff;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.thumb-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  cursor: pointer;
}

.thumb-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cam-geo {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(88px + var(--safe-b));
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.shutter {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.12s;
}

.shutter:active {
  transform: scale(0.9);
}

.shutter:disabled {
  opacity: 0.5;
}

.shutter-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.shutter-flash.on {
  animation: flashBlink 0.18s ease-out;
}

@keyframes flashBlink {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* Review after capture */
.review-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #000;
  display: flex;
  flex-direction: column;
}

.review-overlay.hidden {
  display: none !important;
}

.review-full {
  flex: 1;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  background: #000;
  user-select: none;
}

.review-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 18px calc(20px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.85));
}

.review-btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 16px 12px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.review-btn.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.review-btn.save {
  background: var(--accent);
  color: #041018;
}

.review-btn:disabled {
  opacity: 0.5;
}

/* Settings sheet */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  padding: 12px;
}

.sheet.hidden {
  display: none !important;
}

.sheet-card {
  width: 100%;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 18px 18px 14px 14px;
  padding: 18px 16px calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.sheet-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.settings-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  cursor: pointer;
}

.settings-toggle input {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.settings-toggle span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  font-size: 0.88rem;
}

.settings-toggle strong {
  font-weight: 700;
}

.settings-toggle small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Modal */
.modal {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--bg1);
  color: var(--text);
  max-width: min(920px, calc(100vw - 24px));
  width: 100%;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(4, 8, 14, 0.72);
  backdrop-filter: blur(4px);
}

.modal.small {
  max-width: 420px;
}

.modal-body {
  display: grid;
}

.modal-body.pad {
  padding: 20px;
  gap: 14px;
}

.zoom-stage {
  width: 100%;
  height: clamp(220px, 52dvh, 560px);
  background: #000;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  position: relative;
}

.zoom-stage:active {
  cursor: grabbing;
}

.zoom-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}

.zoom-hint {
  margin: 0;
  padding: 6px 14px 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.modal-info {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-info h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  word-break: break-all;
}

.modal-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.map-frame {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 10;
  background: var(--bg2);
}

.map-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.modal-info {
  padding: 10px 12px 12px !important;
  gap: 4px !important;
}

.modal-info h2 {
  font-size: 0.92rem !important;
}

.modal-info p {
  font-size: 0.78rem !important;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.modal-actions .btn,
.modal-actions a.btn {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.75rem;
  border-radius: 8px;
}

.zoom-hint {
  font-size: 0.68rem;
  padding: 4px 10px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%) translateY(120%);
  background: rgba(20, 28, 38, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 100;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ——— Responsive breakpoints ——— */
@media (max-width: 379px) {
  :root {
    --cols: 2;
    --app-max: 100%;
  }

  .hud-chip {
    font-size: 0.68rem;
    padding: 6px 8px;
  }

  .shutter {
    width: 64px;
    height: 64px;
  }

  .thumb-btn,
  .hud-round {
    width: 44px;
    height: 44px;
  }

  .drag-hint {
    font-size: 0.7rem;
  }
}

@media (min-width: 380px) and (max-width: 599px) {
  :root {
    --cols: 2;
  }
}

@media (min-width: 600px) {
  :root {
    --cols: 3;
    --app-max: 860px;
  }
}

@media (min-width: 900px) {
  :root {
    --cols: 4;
    --app-max: 1100px;
  }

  .app {
    box-shadow: 0 0 0 1px var(--line);
  }
}

@media (min-width: 1200px) {
  :root {
    --cols: 5;
    --app-max: 1280px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .topbar {
    padding-top: 6px;
    padding-bottom: 4px;
  }

  .brand h1 {
    font-size: 1.05rem;
  }

  .tabs {
    margin-top: 4px;
    margin-bottom: 4px;
  }

  .camera-screen,
  .app.camera-mode .camera-screen {
    height: calc(100dvh - 56px);
    min-height: 0;
  }

  .viewer-stage,
  .zoom-stage {
    height: clamp(160px, 55dvh, 360px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .view,
  .toast,
  .shutter,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}
