:root {
  color-scheme: dark;
  --graphite: #0d1117;
  --anthracite: #171b22;
  --surface: #1c2028;
  --surface-raised: #23252d;
  --border: #40312b;
  --terracotta: #c96e4b;
  --terracotta-dark: #a94f34;
  --copper: #e0a276;
  --brown: #8b624c;
  --warm-white: #f8eee5;
  --muted: #aa9b94;
  --success: #9fd0ab;
  --danger: #ee9d8d;
  --shadow: 0 20px 55px rgb(0 0 0 / 35%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--graphite); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--warm-white);
  background:
    radial-gradient(circle at 85% -10%, rgb(201 110 75 / 14%), transparent 38%),
    linear-gradient(180deg, #111319, var(--graphite) 42%);
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: .16;
}
.ambient-one { top: 20%; right: -10rem; background: var(--terracotta); }
.ambient-two { bottom: 10%; left: -12rem; background: var(--brown); }

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: auto;
  padding: max(1rem, env(safe-area-inset-top)) 1.15rem .8rem;
  background: linear-gradient(180deg, rgb(13 17 23 / 96%), rgb(13 17 23 / 72%), transparent);
  backdrop-filter: blur(14px);
}

.brand { display: flex; gap: .7rem; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  border-radius: .85rem;
  color: #18110e;
  font-weight: 900;
  background: linear-gradient(135deg, var(--copper), var(--terracotta));
  box-shadow: 0 8px 22px rgb(201 110 75 / 24%);
}
.brand strong { display: block; font-size: .96rem; letter-spacing: -.01em; }
.brand small { display: block; margin-top: .14rem; color: #b18c78; font-size: .61rem; letter-spacing: .15em; }

.network-pill {
  display: flex;
  gap: .4rem;
  align-items: center;
  min-height: 2rem;
  padding: .4rem .65rem;
  border: 1px solid #2d4032;
  border-radius: 999px;
  color: var(--success);
  background: #17221b;
  font-size: .72rem;
}
.network-pill span { width: .48rem; height: .48rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgb(159 208 171 / 10%); }
.network-pill.offline { color: var(--copper); background: #292019; border-color: #4d372c; }

main { width: min(100%, 720px); margin: auto; padding: .8rem 1.15rem calc(3rem + env(safe-area-inset-bottom)); }
.screen { animation: arrive .38s ease both; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } }

.auth-screen { max-width: 34rem; margin: 6vh auto 0; }
.eyebrow, .status-kicker { color: #b98e77; font-size: .7rem; font-weight: 800; letter-spacing: .14em; }
h1 { margin: .65rem 0 .8rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.65rem, 11vw, 4.5rem); line-height: .92; letter-spacing: -.045em; }
h1 em { color: var(--copper); font-weight: 400; }
h2 { margin: .3rem 0; color: #fff8f1; font-size: 1.3rem; letter-spacing: -.02em; }
.lede { max-width: 34rem; margin: 0 0 1.6rem; color: var(--muted); font-size: .95rem; line-height: 1.65; }

.surface {
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: linear-gradient(145deg, rgb(30 33 41 / 94%), rgb(20 23 29 / 94%));
  box-shadow: var(--shadow);
}

.form-stack { display: grid; gap: 1rem; padding: 1.15rem; }
.form-stack label { display: grid; gap: .45rem; color: var(--muted); font-size: .76rem; font-weight: 700; }
.form-stack label span { color: #746c68; font-weight: 500; }
input, select, textarea {
  width: 100%;
  min-height: 3.25rem;
  border: 1px solid #49362e;
  border-radius: .85rem;
  outline: none;
  color: var(--warm-white);
  background: #11151b;
  padding: .78rem .9rem;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgb(201 110 75 / 14%); }
.invite-card { margin-top: 1rem; border-color: #604333; }
.invite-card p { margin: .35rem 0 0; color: var(--muted); font-size: .82rem; }

.button {
  display: inline-flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: .9rem;
  padding: .78rem 1rem;
  color: white;
  font-weight: 800;
}
.button:disabled { cursor: wait; opacity: .58; }
.button-primary { background: linear-gradient(135deg, #d17a55, var(--terracotta-dark)); box-shadow: 0 11px 25px rgb(169 72 48 / 23%); }
.button-secondary { border: 1px solid #503a31; background: #191c23; }
.button-danger { border: 1px solid #713d35; background: #3c2421; color: #ffd8d0; }
.button-ghost { border: 1px solid #383238; background: transparent; color: var(--muted); }
.button:focus-visible, .capture-card:focus-within, .icon-button:focus-visible, .avatar-button:focus-visible { outline: 3px solid rgb(224 162 118 / 45%); outline-offset: 3px; }

.welcome-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.avatar-button, .icon-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid #49372f;
  border-radius: 50%;
  color: var(--copper);
  background: #251e1b;
  font-size: .72rem;
  font-weight: 900;
}

.capture-grid { display: grid; gap: .8rem; }
.capture-card { cursor: pointer; user-select: none; }
.capture-primary {
  display: grid;
  min-height: 12.5rem;
  place-items: center;
  align-content: center;
  gap: .25rem;
  border-radius: 1.4rem;
  color: white;
  background: linear-gradient(145deg, #d07a55, #aa4d32);
  box-shadow: 0 18px 38px rgb(169 72 48 / 28%);
}
.capture-primary strong { font-size: 1.05rem; }
.capture-primary small { color: #ffe4d7; }
.capture-icon { font-size: 3.5rem; line-height: 1; transform: rotate(90deg); }
.capture-secondary {
  display: flex;
  min-height: 4.8rem;
  align-items: center;
  gap: .9rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: var(--anthracite);
  padding: .8rem 1rem;
}
.capture-secondary strong, .capture-secondary small { display: block; }
.capture-secondary small { margin-top: .15rem; color: var(--muted); }
.file-icon { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: .75rem; color: var(--copper); background: #2a211d; font-size: 1.5rem; }

.selection-panel { margin-top: 1rem; padding: 1rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.count-badge { display: grid; width: 2.3rem; height: 2.3rem; place-items: center; border-radius: .75rem; color: var(--copper); background: #2a211d; font-weight: 900; }
.file-list { display: grid; gap: .55rem; margin: 1rem 0; padding: 0; list-style: none; }
.file-row { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: .65rem; align-items: center; border: 1px solid #332c29; border-radius: .9rem; background: #12161c; padding: .55rem; }
.file-preview { width: 3.2rem; height: 3.2rem; border-radius: .65rem; background: #262127 center/cover no-repeat; }
.file-details { min-width: 0; }
.file-details strong, .file-details small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-details strong { font-size: .78rem; }
.file-details small { margin-top: .25rem; color: var(--muted); font-size: .68rem; }
.file-actions { display: grid; grid-template-columns: repeat(2, 2rem); gap: .25rem; }
.file-actions button { width: 2rem; height: 2rem; border: 1px solid #40342f; border-radius: .55rem; color: var(--muted); background: #211c1a; }
.compact-form { padding: 0; }
.quality-note { border: 1px solid #2e4535; border-radius: .8rem; color: var(--success); background: #17211b; padding: .75rem; font-size: .76rem; line-height: 1.45; }

.queue-summary { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; padding: 1rem; }
.queue-count { text-align: right; }
.queue-count strong { display: block; color: var(--copper); font-size: 1.65rem; line-height: 1; }
.queue-count span { color: var(--muted); font-size: .66rem; }
.queue-list, .history-list { display: grid; gap: .55rem; margin-top: .7rem; }
.queue-item, .history-item { display: flex; align-items: center; justify-content: space-between; gap: .8rem; border: 1px solid #302a28; border-radius: .9rem; background: #14181e; padding: .8rem; }
.queue-item strong, .queue-item small, .history-item strong, .history-item small { display: block; }
.queue-item small, .history-item small { margin-top: .2rem; color: var(--muted); font-size: .7rem; }
.state { flex: 0 0 auto; border-radius: 999px; padding: .35rem .55rem; color: var(--copper); background: #2a211d; font-size: .65rem; font-weight: 800; }
.state.error { color: var(--danger); background: #351f1d; }
.retry-button { width: 100%; margin-top: .7rem; }

.history-section { margin-top: 2rem; }
.empty-state { margin: .8rem 0; color: #786d67; font-size: .82rem; text-align: center; }
.privacy-hint { margin: 2rem .5rem 0; color: #716862; font-size: .68rem; line-height: 1.5; text-align: center; }
.notice { display: grid; gap: .2rem; margin: .75rem 0; border: 1px solid #57402f; border-radius: .9rem; color: var(--copper); background: #241d18; padding: .8rem; font-size: .75rem; }
.notice span { color: var(--muted); line-height: 1.4; }
.notice-error { border-color: #743f35; color: var(--danger); background: #2c1c1b; }

dialog { max-width: 30rem; border: 0; border-radius: 1.25rem; color: var(--warm-white); background: #171b22; padding: 0; box-shadow: 0 30px 90px #000b; }
dialog::backdrop { background: rgb(2 4 7 / 76%); backdrop-filter: blur(5px); }
.dialog-card { display: grid; gap: .75rem; padding: 1.2rem; }
.dialog-card p { margin: .2rem 0 .6rem; color: var(--muted); line-height: 1.55; }

.toast { position: fixed; z-index: 30; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 1rem; max-width: 36rem; margin: auto; border: 1px solid #654634; border-radius: .9rem; color: var(--warm-white); background: #241d19; box-shadow: var(--shadow); padding: .9rem; font-size: .8rem; text-align: center; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(1px, 1px, 1px, 1px) !important; white-space: nowrap !important; }
code { color: var(--copper); }

@media (min-width: 620px) {
  .capture-grid { grid-template-columns: 1.4fr 1fr; }
  .capture-secondary { min-height: 12.5rem; align-content: center; flex-direction: column; justify-content: center; text-align: center; }
}

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