:root {
  --bg: #f4f4f1;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --text: #171817;
  --muted: #6b6f69;
  --line: rgba(23, 24, 23, 0.10);
  --accent: #1f6f50;
  --accent-strong: #15523b;
  --accent-soft: #e4f0e9;
  --danger: #a63d34;
  --shadow: 0 20px 60px rgba(32, 38, 34, 0.10);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(31,111,80,.08), transparent 32rem),
    var(--bg);
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px;
  background: var(--accent); color: white; font-weight: 800; box-shadow: 0 8px 20px rgba(31,111,80,.23);
}

.icon-button {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-solid);
  color: var(--text); cursor: pointer; display: grid; place-items: center; font-weight: 700;
}
.icon-button:active { transform: scale(.97); }

.app-shell { width: min(880px, 100%); margin: 0 auto; padding: 20px 16px 48px; }
.session-card {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: 0 10px 35px rgba(25,32,28,.04); backdrop-filter: blur(16px);
}
.eyebrow { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.filename-input {
  width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 17px; font-weight: 700;
  padding: 2px 0; min-width: 0;
}
.filename-input:focus { color: var(--accent-strong); }
.date-pill { padding: 8px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 700; white-space: nowrap; }

.empty-state {
  margin-top: 24px; min-height: 58vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 44px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.camera-orb {
  width: 86px; height: 86px; display: grid; place-items: center; border-radius: 28px; background: var(--accent-soft); margin-bottom: 20px;
}
.camera-orb svg { width: 42px; height: 42px; fill: var(--accent); }
.empty-state h1 { margin: 0; font-size: clamp(28px, 8vw, 42px); letter-spacing: -.04em; }
.empty-state > p { max-width: 520px; color: var(--muted); line-height: 1.8; margin: 12px auto 0; }
.primary-actions { display: flex; gap: 10px; width: min(480px,100%); margin-top: 28px; }
.privacy-note { font-size: 12px !important; margin-top: 16px !important; }

.btn {
  min-height: 48px; border: 0; border-radius: 16px; padding: 0 18px; font-weight: 750; cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { color: white; background: var(--accent); box-shadow: 0 10px 24px rgba(31,111,80,.18); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); }
.btn-small { min-height: 42px; padding: 0 14px; border-radius: 13px; }
.grow { flex: 1 1 0; }

.workspace { margin-top: 24px; }
.workspace-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 14px; }
.workspace-head h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.add-actions { display: flex; gap: 8px; }
.photo-list { display: grid; gap: 12px; }
.photo-card {
  position: relative; display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 13px; align-items: center;
  padding: 10px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(28,34,30,.045);
  touch-action: pan-y;
}
.photo-card.dragging { opacity: .55; outline: 2px dashed var(--accent); }
.photo-thumb-wrap { position: relative; width: 92px; height: 112px; border-radius: 14px; overflow: hidden; background: #e8e8e4; }
.photo-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-index {
  position: absolute; top: 7px; right: 7px; min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center;
  border-radius: 999px; color: white; background: rgba(0,0,0,.66); font-size: 12px; font-weight: 800; backdrop-filter: blur(7px);
}
.photo-info { min-width: 0; }
.photo-name { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 10px; }
.photo-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.tool-button {
  min-width: 42px; height: 38px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text); border-radius: 12px; cursor: pointer;
  font-size: 13px; font-weight: 700;
}
.tool-button.danger { color: var(--danger); }
.tool-button:disabled { opacity: .35; }
.workspace-tips { color: var(--muted); font-size: 12px; text-align: center; padding: 18px 10px; }

.bottom-bar {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(20px) saturate(150%); border-top: 1px solid var(--line);
}
.bottom-inner { width: min(880px,100%); margin: 0 auto; display: flex; gap: 10px; }

.hidden { display: none !important; }
.hidden-input { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.modal {
  width: min(760px, calc(100% - 24px)); border: 0; padding: 0; border-radius: 26px; color: var(--text); background: transparent;
}
.modal::backdrop { background: rgba(15,17,15,.56); backdrop-filter: blur(5px); }
.modal-card { margin: 0; background: var(--surface-solid); border-radius: 26px; padding: 18px; box-shadow: var(--shadow); }
.compact-card { width: min(520px,100%); margin: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 23px; letter-spacing: -.03em; }
.modal-card p { color: var(--muted); line-height: 1.75; }
.about-list { margin: 14px 0 20px; padding-right: 20px; color: var(--muted); line-height: 1.9; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

.crop-stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 18px; background: #111; user-select: none; touch-action: none;
}
.crop-stage canvas { width: 100%; height: 100%; display: block; }
.crop-rect {
  position: absolute; border: 2px solid white; box-shadow: 0 0 0 9999px rgba(0,0,0,.52); cursor: move; touch-action: none;
}
.crop-handle {
  position: absolute; width: 24px; height: 24px; background: white; border: 2px solid var(--accent); border-radius: 50%; box-shadow: 0 3px 12px rgba(0,0,0,.25);
}
.h-tl { top: -12px; left: -12px; cursor: nwse-resize; }
.h-tr { top: -12px; right: -12px; cursor: nesw-resize; }
.h-bl { bottom: -12px; left: -12px; cursor: nesw-resize; }
.h-br { bottom: -12px; right: -12px; cursor: nwse-resize; }
.modal-help { font-size: 12px; text-align: center; margin: 10px 0 0 !important; }

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(112px + env(safe-area-inset-bottom)); transform: translate(-50%, 18px);
  max-width: calc(100% - 32px); padding: 11px 14px; border-radius: 14px; background: #151715; color: white; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; box-shadow: 0 12px 34px rgba(0,0,0,.2); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 560px) {
  .app-shell { padding-inline: 12px; padding-top: 14px; }
  .session-card { grid-template-columns: minmax(0,1fr); align-items: start; }
  .date-pill { width: max-content; }
  .empty-state { margin-top: 14px; min-height: 62vh; padding: 36px 18px; }
  .primary-actions { flex-direction: column; }
  .workspace-head { align-items: center; }
  .workspace-head .eyebrow { margin-bottom: 2px; }
  .photo-card { grid-template-columns: 84px minmax(0,1fr); }
  .photo-thumb-wrap { width: 84px; height: 108px; }
  .tool-button { padding: 0 9px; }
  .bottom-inner { gap: 8px; }
  .bottom-inner .btn { padding-inline: 12px; font-size: 14px; }
  .modal { width: calc(100% - 14px); }
  .modal-card { padding: 14px; border-radius: 22px; }
  .crop-stage { aspect-ratio: 1 / 1; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111411;
    --surface: rgba(29, 33, 29, .88);
    --surface-solid: #1c201c;
    --text: #f2f4f1;
    --muted: #a2a8a0;
    --line: rgba(255,255,255,.10);
    --accent: #4ca579;
    --accent-strong: #63bb8f;
    --accent-soft: #20382b;
    --danger: #ef8b81;
    --shadow: 0 20px 60px rgba(0,0,0,.28);
  }
  .photo-thumb-wrap { background: #292d29; }
}

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