:root {
  color-scheme: light;
  --background: #f7f8f3;
  --surface: #fff;
  --ink: #1a251c;
  --muted: #566158;
  --line: #dde3da;
  --soft: #eef2e9;
  --accent: #d6eca8;
  --accent-hover: #e6f2cb;
  --green: #284830;
  --green-hover: #1a3522;
  --danger: #992e2c;
  --danger-soft: #fff1ee;
  --notice: #ecf5df;
  --radius: 20px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--background);
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 280px; margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
:focus-visible { outline: 2px solid #42714d; outline-offset: 3px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  flex: 0 0 auto;
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner {
  max-width: 1280px;
  min-height: 77px;
  margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 11px; font-size: 1rem; font-weight: 650; letter-spacing: -.025em; }
.brand-mark, .login-mark, .empty-mark, .camera-placeholder-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
}
.brand-mark { width: 40px; height: 40px; color: var(--accent); background: var(--green); }
.brand-mark .icon { width: 22px; height: 22px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.32;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: var(--green-hover); }
.button-quiet { background: transparent; color: var(--green); }
.button-quiet:hover:not(:disabled) { background: var(--soft); }
.button-secondary { background: white; border-color: var(--line); color: var(--ink); }
.button-secondary:hover:not(:disabled) { background: var(--soft); }
.button-accent { background: var(--accent); color: #19271c; }
.button-accent:hover:not(:disabled) { background: var(--accent-hover); }
.button-danger { background: var(--danger); color: white; }
.button-danger:hover:not(:disabled) { background: #7b2220; }
.text-danger { color: var(--danger); }
.icon-button { padding: 0; min-width: 44px; }

.page { max-width: 1280px; margin: 0 auto; padding: 42px clamp(16px, 4vw, 48px) 64px; }
.boot-status { color: var(--muted); margin-bottom: 10px; }
.login-screen { min-height: max(460px, 68dvh); display: grid; place-items: center; }
.login-card {
  width: min(100%, 425px);
  padding: clamp(24px, 7vw, 38px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 12px 42px #202d1410;
}
.login-mark { width: 52px; height: 52px; margin-bottom: 20px; color: var(--green); background: var(--accent); }
.login-mark .icon { width: 26px; height: 26px; }
.login-card h1 { font-size: clamp(1.65rem, 6vw, 2.13rem); letter-spacing: -.065em; line-height: 1.08; }
.login-card > p { margin-top: 12px; font-size: .96rem; line-height: 1.55; }
.login-card form { display: grid; gap: 11px; margin-top: 26px; }
.login-card label { font-size: .88rem; font-weight: 650; }
.login-card input {
  width: 100%;
  min-height: 49px;
  padding: 11px 13px;
  border: 1px solid #cbd4c8;
  border-radius: 9px;
  color: var(--ink);
  background: #fbfcf9;
}
.login-card .button-primary { justify-content: space-between; margin-top: 5px; }
.login-error { color: var(--danger); font-size: .88rem; overflow-wrap: anywhere; }

.vault-screen { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.section-nav { display: none; }
.panel {
  min-width: 0;
  padding: clamp(17px, 2.6vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-header :is(h1, h2) { font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1.1; font-weight: 700; letter-spacing: -.065em; }
.panel-description { margin: 9px 0 20px; color: var(--muted); line-height: 1.5; font-size: .94rem; }
.status-tag, .item-count { color: var(--green); background: var(--soft); padding: 6px 9px; border-radius: 99px; font-size: .76rem; font-weight: 650; white-space: nowrap; }
.status-tag::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 6px 1px 0; border-radius: 100%; background: #708171; }
.status-tag[data-state="live"] { background: var(--notice); }
.status-tag[data-state="live"]::before { background: #3a7144; }
.status-tag[data-state="recording"] { background: var(--danger-soft); color: var(--danger); }
.status-tag[data-state="recording"]::before { background: #c23a39; }

.capture-stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 230px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: radial-gradient(ellipse at 50% 35%, #2e4633, #1a291f 70%);
  color: #edf4e7;
}
.capture-stage:has(video:not([hidden]), img:not([hidden])) { background: #101a13; }
.capture-stage:has(video:not([hidden]), img:not([hidden])) .stage-corner { display: none; }
.capture-stage video, .capture-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#camera-preview[data-facing="user"] { transform: scaleX(-1); }
.stage-corner { position: absolute; width: 24px; height: 24px; border: 1px solid #bad1ab78; border-radius: 1px; pointer-events: none; }
.corner-top-left { top: 17px; left: 17px; border-right: 0; border-bottom: 0; border-top-left-radius: 6px; }
.corner-top-right { top: 17px; right: 17px; border-left: 0; border-bottom: 0; border-top-right-radius: 6px; }
.corner-bottom-left { bottom: 17px; left: 17px; border-top: 0; border-right: 0; border-bottom-left-radius: 6px; }
.corner-bottom-right { bottom: 17px; right: 17px; border-top: 0; border-left: 0; border-bottom-right-radius: 6px; }
.camera-placeholder { z-index: 1; display: grid; justify-items: center; gap: 13px; padding: 26px; text-align: center; }
.camera-placeholder p { font-size: .95rem; font-weight: 600; }
.camera-placeholder-icon { width: 55px; height: 55px; background: #d6eca81c; color: var(--accent); }
.camera-placeholder-icon .icon { width: 25px; height: 25px; }
.close-camera {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #ffffff3d;
  border-radius: 10px;
  background: #16241bde;
  color: white;
}
.close-camera:hover { background: #16241b; }
.recording-timer {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 7px 10px;
  border-radius: 99px;
  background: #1b1113d9;
  color: white;
  font-size: .86rem;
  font-variant-numeric: tabular-nums;
}
.recording-timer::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #ff7378; }

.capture-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; gap: 9px; margin-top: 17px; }
.mode-control { justify-self: start; display: flex; padding: 3px; background: var(--soft); border-radius: 10px; }
.mode-button {
  min-height: 39px;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 650;
}
.mode-button[aria-pressed="true"] { background: white; color: var(--ink); box-shadow: 0 1px 2px #2848301a; }
.shutter {
  display: grid;
  place-items: center;
  width: 57px;
  height: 57px;
  padding: 5px;
  border: 2px solid var(--green);
  border-radius: 50%;
  background: white;
}
.shutter span { width: 100%; height: 100%; border-radius: 50%; background: var(--green); transition: border-radius .15s, transform .15s; }
.shutter:hover:not(:disabled) span { background: var(--green-hover); }
.shutter[data-mode="video"] span { background: #bf4545; }
.shutter[data-mode="video"]:hover:not(:disabled) span { background: #a23535; }
.shutter[data-recording="true"] span { border-radius: 9px; transform: scale(.65); }
.flip-button { justify-self: end; min-width: 44px; padding-inline: 9px; }
.video-options { min-height: 45px; margin-top: 11px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: .84rem; column-gap: 12px; }
.audio-option { display: flex; align-items: center; gap: 5px; min-height: 44px; color: var(--green); cursor: pointer; font-weight: 650; }
.audio-option input { accent-color: var(--green); width: 16px; height: 16px; margin: 0 3px; }
.review-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.upload-progress { flex-basis: 100%; font-size: .83rem; color: var(--muted); }
.upload-progress progress { display: block; width: 100%; height: 11px; margin: 7px 0 4px; accent-color: var(--green); }
.action-status, .notice { line-height: 1.45; overflow-wrap: anywhere; }
.action-status { margin: 12px 0; font-size: .875rem; color: var(--muted); }
.action-status[data-tone="error"] { color: var(--danger); }
.notice { grid-column: 1 / -1; padding: 12px 15px; color: var(--green); font-size: .9rem; background: var(--notice); border-radius: 10px; }
.notice[data-tone="error"] { color: var(--danger); background: var(--danger-soft); }

.library-empty {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 244px;
  padding: 24px 14px;
  text-align: center;
  background: #fafbf7;
  border: 1px dashed #cfd8c9;
  border-radius: 15px;
}
.empty-mark { width: 49px; height: 49px; margin-bottom: 13px; color: var(--green); background: var(--soft); }
.empty-mark .icon { width: 23px; height: 23px; }
.library-empty h3 { margin-bottom: 5px; font-weight: 650; font-size: 1rem; }
.library-empty p { font-size: .88rem; line-height: 1.4; }
.media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(130px, 46%), 1fr)); gap: 11px; list-style: none; margin: 0; padding: 0; }
.media-list:empty { display: none; }
.media-card { display: block; width: 100%; padding: 0; text-align: left; background: white; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.media-card:hover { border-color: #8da691; }
.thumbnail-wrap { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--soft); overflow: hidden; }
.thumbnail-wrap img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-kind { position: absolute; right: 7px; bottom: 7px; color: white; background: #18241ee8; border-radius: 6px; padding: 4px 6px; font-size: .72rem; font-variant-numeric: tabular-nums; }
.media-kind .icon { width: 15px; height: 15px; margin-right: 3px; }
.media-date { display: block; padding: 8px 9px; color: var(--muted); font-size: .75rem; white-space: nowrap; }

.viewer {
  width: min(calc(100% - 28px), 760px);
  max-height: calc(100% - 22px);
  padding: clamp(12px, 3vw, 22px);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: auto;
}
.viewer::backdrop { background: #101d15bc; }
.viewer-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.viewer-header h2 { font-size: 1.25rem; letter-spacing: -.04em; }
.viewer-details, #viewer-details { margin-top: 3px; font-size: .83rem; }
.viewer-content { overflow: hidden; display: grid; place-items: center; border-radius: 10px; background: #101a13; }
.viewer-content img, .viewer-content video { width: 100%; max-height: 67dvh; object-fit: contain; display: block; }
.viewer-actions { display: flex; justify-content: end; margin-top: 7px; }
.delete-confirmation { margin-top: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.delete-confirmation p { flex: 1 0 100%; font-size: .9rem; color: var(--danger); }

@media (max-width: 760px) {
  .topbar-inner { min-height: 65px; }
  .page { padding-top: 19px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .vault-screen { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .section-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; }
  .nav-button { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: .9rem; font-weight: 650; }
  .nav-button[aria-pressed="true"] { color: var(--green); background: white; box-shadow: 0 1px 2px #2848301c; }
  [data-view="capture"] #library-panel, [data-view="library"] #capture-panel { display: none; }
  .login-screen { min-height: 64dvh; }
}

@media (max-width: 380px) {
  .brand { gap: 7px; font-size: .93rem; }
  .brand-mark { height: 34px; width: 34px; border-radius: 10px; }
  .topbar-inner #lock-button { padding-inline: 6px; }
  .flip-button span { display: none; }
  .capture-toolbar { gap: 5px; }
}

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