:root {
  color-scheme: light dark;
  --bg: #0f1510;
  --card: #171d18;
  --surface: #20281f;
  --surface-subtle: #121812;
  --fg: #fbfcf7;
  --muted: #c6cebd;
  --text-disabled: #788372;
  --border: #2e392e;
  --border-strong: #4a5746;
  --accent: #d6b35c;
  --accent-soft: rgb(125 147 80 / 0.2);
  --accent-text: #dfe8b4;
  --camera: #7d9350;
  --camera-hover: #90a65d;
  --camera-text: #0f1510;
  --library: #d6b35c;
  --library-hover: #c49a3f;
  --library-text: #0f1510;
  --send: #34d399;
  --send-hover: #2fba86;
  --send-text: #0f1510;
  --danger: #fca5a5;
  --danger-button: #fca5a5;
  --danger-button-hover: #f87171;
  --danger-button-text: #2a0d0d;
  --success-soft: rgb(52 211 153 / 0.16);
  --shadow: 0 1.25rem 3rem rgba(0, 0, 0, 0.28);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f4ed;
    --card: #ffffff;
    --surface: #eef1e8;
    --surface-subtle: #fafbf7;
    --fg: #1f2a1f;
    --muted: #556353;
    --text-disabled: #8a9489;
    --border: #dbe0d3;
    --border-strong: #bcc7b0;
    --accent: #b2872f;
    --accent-soft: rgb(79 111 56 / 0.14);
    --accent-text: #3f5c2e;
    --camera: #4f6f38;
    --camera-hover: #3e582b;
    --camera-text: #ffffff;
    --library: #b2872f;
    --library-hover: #c49a3f;
    --library-text: #1f2a1f;
    --send: #047857;
    --send-hover: #036a4d;
    --send-text: #ffffff;
    --danger: #991b1b;
    --danger-button: #991b1b;
    --danger-button-hover: #7f1d1d;
    --danger-button-text: #ffffff;
    --success-soft: rgb(5 150 105 / 0.14);
    --shadow: 0 1rem 2.5rem rgba(25, 50, 36, 0.12);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  background: radial-gradient(circle at top, color-mix(in srgb, var(--camera) 12%, var(--bg)), var(--bg) 22rem);
  color: var(--fg);
  min-height: 100vh;
  min-height: 100dvh;
}
.wrap {
  max-width: 30rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.upload-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 1.15rem;
  box-shadow: var(--shadow);
}
.page-header { margin-bottom: 1rem; }
.secure-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.secure-mark svg {
  width: 2rem;
  height: 2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1 { font-size: clamp(1.45rem, 6vw, 1.9rem); line-height: 1.15; margin: 0.65rem 0 0.45rem; text-align: center; }
.lead, .formats, .muted { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.lead { margin: 0; }
.security-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
}
.security-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-disabled);
  background: var(--surface-subtle);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0.72;
}
.security-note p { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.4; }
#status {
  margin: 1rem 0;
  padding: 0.7rem 0.8rem;
  border-left: 3px solid var(--accent);
  border-radius: 0.35rem;
  background: var(--surface);
  font-weight: 650;
  line-height: 1.35;
}
#status:empty { display: none; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.source-actions {
  border: 0;
  padding: 0;
  margin: 1.1rem 0 0;
}
.source-actions legend {
  padding: 0;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
}
button, .file-action {
  display: block;
  width: 100%;
  margin: 0.5rem 0;
  font: inherit;
}
button, .file-action {
  border: 0;
  border-radius: 0.7rem;
  padding: 0.8rem 1rem;
  min-height: 3rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms ease, opacity 140ms ease;
}
button:not(:disabled):active, .file-action:active { transform: translateY(1px); }
button:disabled { opacity: 0.62; cursor: not-allowed; }
.file-action.camera { background: var(--camera); color: var(--camera-text); }
.file-action.camera:hover { background: var(--camera-hover); }
.file-action.library { background: var(--library); color: var(--library-text); }
.file-action.library:hover { background: var(--library-hover); }
.file-action-title, .file-action-hint { display: block; }
.file-action-hint { margin-top: 0.15rem; font-size: 0.78rem; font-weight: 500; }
.send-button { background: var(--send); color: var(--send-text); margin-top: 0.75rem; }
.send-button:not(:disabled):hover { background: var(--send-hover); }
.send-button:disabled {
  background: var(--surface);
  color: var(--text-disabled);
  border: 1px solid var(--border);
  opacity: 1;
}
.success-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-top: 0.8rem;
}
.success-actions button {
  margin: 0;
}
.danger-button {
  background: var(--danger-button);
  color: var(--danger-button-text);
}
.danger-button:not(:disabled):hover {
  background: var(--danger-button-hover);
}
button.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
.visually-hidden:focus-visible + .file-action,
.file-action:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.visually-hidden:disabled + .file-action {
  opacity: 0.5;
  pointer-events: none;
}
.preview {
  display: grid;
  grid-template-columns: 5.75rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.65rem;
  margin: 0.25rem 0 0.65rem;
  background: var(--surface);
  text-align: left;
}
.preview:has(.file-list) {
  grid-template-columns: 1fr;
  align-items: stretch;
}
.file-list-header { min-width: 0; }
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.file-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--surface-subtle);
}
.file-list-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.file-list-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 800;
}
.file-list-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 650;
}
.file-list-size {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}
.file-list-remove {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
}
.preview img {
  display: block;
  width: 5.75rem;
  height: 5.75rem;
  object-fit: contain;
  border-radius: 0.5rem;
  background: #080b09;
}
.preview-copy { min-width: 0; }
.preview-label { margin: 0 0 0.3rem; font-size: 0.86rem; font-weight: 750; }
.preview-details { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.preview-placeholder {
  display: grid;
  place-items: center;
  width: 5.75rem;
  height: 5.75rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}
.progress-wrap { min-height: 0; }
progress { width: 100%; margin-top: 0.5rem; accent-color: var(--send); }
#progress-text { margin: 0.45rem 0 0; }
#progress-text:empty { display: none; }
.formats { margin: 1rem 0 0; text-align: center; font-size: 0.75rem; }
.formats strong { color: var(--fg); font-weight: 700; }
.err { color: var(--danger); }

@media (min-width: 34rem) {
  .wrap { padding: 2rem 1rem; }
  .upload-card { padding: 1.5rem; }
}

@media (max-width: 22rem) {
  .wrap { padding-left: 0.65rem; padding-right: 0.65rem; }
  .upload-card { padding: 0.9rem; }
  .preview { grid-template-columns: 5rem minmax(0, 1fr); }
  .preview img, .preview-placeholder { width: 5rem; height: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
  button, .file-action { transition: none; }
}
