*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #0e0d0b;
  --bg-elevated: #18160f;
  --ink: #e8dfc8;
  --ink-muted: #8a7f6a;
  --gold: #b58c50;
  --border: #2a261f;
  --rust: #6b3a1e;
  --body: "Cardo", "Garamond", "Georgia", serif;
  --display: "Marcellus", "Cardo", "Garamond", serif;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background-image:
    linear-gradient(rgba(14, 13, 11, 0.82), rgba(14, 13, 11, 0.94)),
    url("bg/primary.jpeg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

button {
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button.ghost { border: none; }
button:disabled { opacity: 0.4; cursor: default; }

.muted { color: var(--ink-muted); }

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- Identity screen ---------- */

#identity-screen { text-align: center; padding-top: 80px; }

#identity-screen h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 36px;
  margin: 24px 0 8px;
  letter-spacing: 0.04em;
}

#identity-screen .muted {
  margin: 0 0 48px;
  font-size: 16px;
}

.identity-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 280px;
  margin: 0 auto;
}

.identity-btn {
  padding: 18px 24px;
  font-size: 26px;
  font-family: var(--display);
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  background: transparent;
  transition: border-color 0.2s, background 0.2s;
}

.identity-btn:hover, .identity-btn:active {
  background: var(--bg-elevated);
  border-color: var(--gold);
  color: var(--gold);
}

/* ---------- Capture screen ---------- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand-name {
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

#settings-btn {
  font-size: 16px;
  color: var(--ink-muted);
  border: none;
  padding: 4px 8px;
}

#settings-btn:active { color: var(--gold); }

.identity-label::before { content: "— "; }

main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#tribute {
  width: 100%;
  background: transparent;
  color: var(--ink);
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  font-size: 24px;
  line-height: 1.4;
  padding: 12px 4px 16px;
  resize: none;
  outline: none;
  caret-color: var(--gold);
}

#tribute::placeholder {
  color: var(--ink-muted);
  font-style: italic;
}

.photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.photo-btn {
  font-size: 16px;
  color: var(--ink-muted);
  padding: 8px 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, border-color 0.2s;
}

.photo-btn:hover, .photo-btn:active {
  color: var(--gold);
  border-color: var(--gold);
}

#photo-preview {
  display: flex;
  align-items: center;
  gap: 8px;
}

#photo-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid var(--border);
}

#photo-remove {
  font-size: 24px;
  color: var(--ink-muted);
  padding: 0 8px;
  line-height: 1;
}

.destinations-label {
  color: var(--ink-muted);
  font-size: 18px;
  margin-top: 8px;
  letter-spacing: 0.02em;
}

.destinations {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.destination {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 14px 18px;
  border: 1px solid var(--border);
  background: rgba(14, 13, 11, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
}

.destination:hover, .destination:active {
  border-color: var(--gold);
  background: rgba(24, 22, 15, 0.75);
}

.destination.sending {
  border-color: var(--gold);
  background: rgba(24, 22, 15, 0.75);
  opacity: 0.6;
}

.dest-name {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.dest-sub {
  font-size: 14px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.destination.inbox { border-style: dashed; }

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.4s ease;
  padding: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#success-overlay {
  background-image:
    linear-gradient(rgba(14, 13, 11, 0.25) 0%, rgba(14, 13, 11, 0.55) 55%, rgba(14, 13, 11, 0.92) 100%),
    url("bg/submitted.jpeg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}

.success-content {
  text-align: center;
  max-width: 360px;
  padding-bottom: 60px;
}

.error-content {
  text-align: center;
  max-width: 360px;
  align-self: center;
}

#error-overlay {
  align-items: center;
}

.tree-mark {
  display: none;
}

.success-text, .error-text {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.success-where {
  margin-top: 8px;
  font-size: 20px;
  color: var(--ink);
  opacity: 0.75;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.error-mark {
  font-size: 48px;
  color: var(--rust);
  margin-bottom: 16px;
  font-weight: 500;
}

.error-detail {
  margin-top: 12px;
  font-size: 14px;
  font-family: ui-monospace, "SF Mono", monospace;
  word-break: break-word;
}

.error-actions {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.error-actions button {
  padding: 12px 24px;
  font-size: 18px;
}
