:root {
  --ivory: #faf7f1;
  --cream: #f3ede2;
  --ink: #2e332e;
  --sage: #55604f;
  --sage-light: #8a937f;
  --gold: #b08d57;
  --gold-light: #cbb489;
  --white: #fffdf9;
  --error: #8a3c2b;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Jost', 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(203, 180, 137, .2), transparent 55%),
    var(--ivory);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.65;
  letter-spacing: .02em;
}

[hidden] { display: none !important; }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--sage); outline-offset: 4px; }

.topbar {
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: rgba(250, 247, 241, .96);
  border-bottom: 1px solid #e5d8c1;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-inner {
  width: min(100%, 900px);
  min-height: 72px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  font: 500 1.5rem var(--serif);
}
.brand img { width: 34px; height: 34px; }
.brand em { color: var(--gold); font-weight: 400; }
.languages { display: flex; gap: 2px; margin-left: auto; }
.languages button {
  min-width: 42px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--sage);
  font: 400 .8rem var(--sans);
  cursor: pointer;
}
.languages button[aria-pressed="true"] { background: var(--cream); color: var(--ink); box-shadow: inset 0 -2px var(--gold); }
.home-link {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd2bd;
  border-radius: 8px;
  background: transparent;
  color: var(--sage);
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.home-link:hover { border-color: var(--gold-light); background: var(--cream); color: var(--ink); }
.home-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }

.upload-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) 1.25rem 4rem;
  flex: 1;
}
.upload-card { text-align: center; }
.section-label {
  margin: 0 0 .75rem;
  color: var(--gold);
  font-size: .68rem;
  letter-spacing: .42em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font: 500 clamp(2.4rem, 8vw, 4rem)/1.08 var(--serif);
}
.intro { max-width: 590px; margin: 1.25rem auto 2.5rem; color: var(--sage); font: 400 clamp(1.1rem, 3.5vw, 1.3rem)/1.7 var(--serif); }

.session-check, .message-panel {
  margin: 2rem auto;
  padding: 1.5rem;
  border: 1px solid #e5d8c1;
  border-radius: 14px;
  background: rgba(255, 253, 249, .82);
  color: var(--sage);
}
.session-check { display: flex; align-items: center; justify-content: center; gap: .8rem; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gold-light);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.message-panel h2 { margin: 0 0 .7rem; color: var(--ink); font: 500 1.8rem var(--serif); }
.message-panel p { margin: 0 auto 1.25rem; max-width: 480px; }

.field { margin: 0 auto 1.5rem; text-align: left; }
.field label { display: block; margin-bottom: .55rem; color: var(--sage); font-size: .76rem; letter-spacing: .18em; text-transform: uppercase; }
.field label span { letter-spacing: normal; text-transform: none; color: var(--sage-light); }
.field input {
  width: 100%;
  padding: .95rem 1rem;
  border: 1px solid #d9ccb5;
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
}

.drop-zone {
  min-height: 210px;
  padding: 2rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1.5px dashed var(--gold-light);
  border-radius: 16px;
  background: rgba(255, 253, 249, .78);
  color: var(--sage);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--gold); background: var(--white); transform: translateY(-1px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-mark { color: var(--gold); font: 300 3rem/1 var(--serif); }
.drop-zone strong { color: var(--ink); font: 500 clamp(1.35rem, 5vw, 1.7rem) var(--serif); }
.drop-zone > span:last-child { font-size: .85rem; }
.connection-note { margin: 1rem auto 0; color: var(--sage-light); font-size: .8rem; }

.upload-queue { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .85rem; margin-top: 2rem; text-align: left; }
.upload-item {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 1rem;
  overflow: hidden;
  border: 1px solid #e5d8c1;
  border-radius: 12px;
  background: var(--white);
}
.upload-item-top { min-width: 0; display: flex; align-items: baseline; gap: 1.8rem; }
.upload-copy { min-width: 0; overflow: hidden; flex: 1; }
.upload-name { min-width: 0; max-width: 100%; display: flex; overflow: hidden; color: var(--ink); font: 400 1rem/1.4 var(--sans); white-space: nowrap; }
.upload-name-leading { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-name-trailing { flex: 0 0 auto; white-space: nowrap; }
.upload-meta { margin-top: .15rem; color: var(--sage-light); font-size: .78rem; }
.upload-state { width: 7.5rem; min-width: 0; flex: 0 0 7.5rem; overflow: hidden; color: var(--sage); font: 400 1rem/1.4 var(--sans); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.upload-state[data-state="complete"] { color: var(--sage); font-weight: 500; }
.upload-state[data-state="error"] { color: var(--error); }
.progress-track { height: 5px; margin-top: .8rem; overflow: hidden; border-radius: 999px; background: var(--cream); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-light), var(--gold)); transition: width .2s ease; }
.retry-button, .secondary-button {
  display: inline-block;
  margin-top: .8rem;
  padding: .7rem 1rem;
  border: 1px solid var(--gold-light);
  border-radius: 8px;
  background: transparent;
  color: var(--sage);
  text-decoration: none;
  cursor: pointer;
}
.retry-button:hover, .secondary-button:hover { border-color: var(--gold); color: var(--ink); }
.global-status { min-height: 1.6em; margin: 1.5rem 0 0; color: var(--sage); }
.global-status[data-state="error"] { color: var(--error); }
.global-status-top { margin: 2rem 0 1.5rem; }
.global-status-top + .upload-queue { margin-top: 0; }
.global-status-top:empty { display: none; }
.global-status-top:empty + .upload-queue { margin-top: 2rem; }

footer { padding: 2.5rem 1.5rem 3rem; text-align: center; }
footer p { margin: 0; }
footer .names { font: 500 1.6rem var(--serif); }
footer .names span { color: var(--gold); font-style: italic; }
footer .date { margin-top: .4rem; color: var(--sage-light); font-size: .68rem; letter-spacing: .3em; text-transform: uppercase; }

@media (max-width: 480px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar-inner { min-height: 64px; gap: 8px; }
  .brand { font-size: 1.1rem; gap: 5px; }
  .brand img { width: 26px; height: 26px; }
  .languages button { min-width: 34px; padding: 0 4px; }
  .home-link { width: 44px; height: 44px; flex-basis: 44px; }
  .upload-shell { padding-top: 2.75rem; }
  .drop-zone { min-height: 180px; }
  .upload-item-top { gap: 1.8rem; }
}

@media (max-width: 350px) {
  .brand img { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.8s; }
  .drop-zone, .progress-bar { transition: none; }
}
