:root {
  --green: #064a2b;
  --green-deep: #03331d;
  --purple: #8b61c4;
  --ink: #141519;
  --muted: #70737b;
  --canvas: #f2f1ee;
  --surface: #ffffff;
  --line: #dfdfdb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-pending .workspace { visibility: hidden; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--green) 0 48%, var(--purple) 48% 49%, #101115 49% 100%);
}

.login-screen[hidden] { display: none; }

.login-card {
  width: min(100%, 420px);
  padding: 34px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.login-card img { width: 76px; height: 76px; margin-bottom: 26px; border-radius: 16px; object-fit: cover; }
.login-card h1 { margin-bottom: 12px; font-size: 2.25rem; }
.login-card > p:not(.eyebrow):not(.login-error) { margin-bottom: 27px; color: var(--muted); line-height: 1.5; }
.login-card label { display: block; margin: 16px 0 7px; color: #404248; font-size: .82rem; font-weight: 750; }
.login-card input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #d8d8d4; border-radius: 9px; background: #fff; color: var(--ink); outline: 0; }
.login-card input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139, 97, 196, .15); }
.login-button { width: 100%; margin-top: 24px; min-height: 46px; }
.login-error { margin: 14px 0 -5px; color: #b3261e; font-size: .84rem; }

button, input { font: inherit; }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 70px; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 54px; }

.brand-lockup { display: flex; align-items: center; gap: 10px; color: var(--green); }
.brand-mark { font-size: 1.65rem; line-height: 1; font-weight: 900; letter-spacing: -0.11em; }
.brand-label { font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.brand-image { width: 42px; height: 42px; display: block; border-radius: 10px; object-fit: cover; }

.status { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.status span { width: 8px; height: 8px; border-radius: 50%; background: #36a269; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.logout { border: 0; padding: 7px 9px; color: var(--muted); background: transparent; font-size: .8rem; font-weight: 700; cursor: pointer; }
.logout:hover { color: var(--green); }

.intro { max-width: 760px; padding: 74px 0 46px; }
.eyebrow { margin: 0 0 10px; color: var(--purple); font-size: .75rem; line-height: 1; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 17px; font-size: clamp(2.15rem, 5vw, 4.6rem); line-height: .99; letter-spacing: -.065em; }
.intro > p:last-child { max-width: 620px; margin-bottom: 0; color: #53565e; font-size: 1.05rem; line-height: 1.55; }

.upload-panel { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(380px, 1.25fr); gap: 28px; padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.panel-copy { padding: 13px 10px; }
h2 { margin-bottom: 8px; font-size: 1.35rem; line-height: 1.1; letter-spacing: -.035em; }
.panel-copy > p:last-child { max-width: 285px; margin-bottom: 0; color: var(--muted); font-size: .92rem; line-height: 1.5; }

.dropzone { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1.5px dashed #b6a4d3; border-radius: 14px; color: var(--green); background: linear-gradient(125deg, #f9f9f7, #f2eff8); text-align: center; cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--purple); background: #eee9f8; transform: translateY(-2px); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 1.25rem; font-weight: 800; }
.dropzone strong { margin-top: 2px; font-size: 1rem; }
.dropzone small { color: var(--muted); font-size: .82rem; }

.results { padding-top: 58px; }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.results-heading .eyebrow { margin-bottom: 8px; }
.results-heading h2 { margin: 0; font-size: 1.55rem; }
.result-actions { display: flex; gap: 9px; }
.button { border: 0; border-radius: 9px; padding: 10px 14px; font-size: .86rem; font-weight: 750; cursor: pointer; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-deep); }
.button.secondary { color: var(--ink); background: #e8e8e4; }

.empty-state { min-height: 245px; display: grid; place-items: center; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: #878a90; font-size: .94rem; }
.empty-state p { z-index: 1; margin: 0; padding: 10px 16px; border-radius: 30px; background: rgba(255,255,255,.86); }
.empty-diagonal { position: absolute; inset: 0; background: linear-gradient(135deg, transparent 49.7%, rgba(139,97,196,.16) 49.7%, rgba(139,97,196,.16) 50.3%, transparent 50.3%); }

.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.result-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 6px 18px rgba(20,21,25,.045); }
.result-card img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; background: #101010; }
.result-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px; }
.result-info strong, .result-info small { display: block; }
.result-info strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.result-info small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.download-link { color: var(--green); font-size: .82rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.download-link:hover { color: var(--purple); }

.history { padding-top: 62px; }
.history-note { max-width: 290px; margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; text-align: right; }
.history-empty { padding: 30px; border: 1px dashed #cfcfc9; border-radius: 14px; color: var(--muted); font-size: .9rem; text-align: center; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.history-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.history-card img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; background: #111; }
.history-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px; }
.history-info strong, .history-info small { display: block; }
.history-info strong { max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.history-info small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.history-actions { display: flex; align-items: center; gap: 10px; }
.delete-link { border: 0; padding: 0; color: #a6403b; background: transparent; font-size: .76rem; font-weight: 750; cursor: pointer; }
.delete-link:hover { color: #74231e; }

@media (max-width: 700px) {
  .workspace { width: min(100% - 28px, 1180px); padding-top: 13px; }
  .topbar { min-height: 42px; }
  .status { font-size: .7rem; }
  .header-actions { gap: 5px; }
  .intro { padding: 51px 0 32px; }
  h1 { font-size: clamp(2.15rem, 12vw, 3.5rem); }
  .upload-panel { grid-template-columns: 1fr; gap: 7px; padding: 18px; }
  .panel-copy { padding: 6px; }
  .panel-copy > p:last-child { max-width: none; }
  .results { padding-top: 44px; }
  .results-heading { align-items: start; flex-direction: column; }
  .history-note { text-align: left; }
}
