:root {
  color-scheme: dark;
  --bg: #080a10;
  --panel: rgba(18, 22, 31, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f6fa;
  --muted: #98a2b3;
  --accent: #c7a56d;
  --accent-strong: #ddbd87;
  --danger: #e85d75;
  --success: #76d4a4;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(199, 165, 109, 0.16), transparent 28%),
    linear-gradient(180deg, #0a0d14 0%, #06080d 62%, #05070c 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.login-card,
.panel,
.delete-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card {
  width: min(430px, 100%);
  margin: 10vh auto 0;
  padding: 32px;
}

.app {
  display: grid;
  gap: 20px;
}

.topbar,
.panel-head,
.action-row,
.progress-head,
.progress-meta,
.archive-row,
.archive-meta,
.dialog-actions,
.pagination-row,
.archive-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 8px 4px 4px;
}

.topbar-meta {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.96;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.08rem;
}

.muted,
.status-line,
.archive-meta,
.archive-empty,
#current-magazine-meta {
  color: var(--muted);
}

.stack,
.upload-form,
.delete-form,
.archive-browser,
.archive-list {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 24px;
}

.upload-form {
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.2fr) auto;
  align-items: end;
}

.archive-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(8, 10, 15, 0.92);
  color: var(--text);
}

.field input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.file-field input {
  padding-top: 11px;
}

.button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #17120a;
  font-weight: 700;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border);
}

.button.danger {
  background: var(--danger);
  color: white;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(199, 165, 109, 0.28);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(199, 165, 109, 0.08);
  font-size: 0.9rem;
}

.progress-card {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  margin-top: 2px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-soft);
}

.progress-bar {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

#progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #eed3a0);
}

.magazine-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.magazine-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.magazine-tab.is-active {
  border-color: rgba(199, 165, 109, 0.34);
  background: rgba(199, 165, 109, 0.1);
  color: var(--accent-strong);
}

.magazine-tab-count {
  color: var(--muted);
}

.archive-browser {
  margin-top: 6px;
}

.archive-list {
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.025);
}

.archive-row {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.archive-row:first-child {
  border-top: 0;
}

.archive-info {
  display: grid;
  gap: 5px;
}

.archive-file {
  font-weight: 600;
  word-break: break-word;
}

.archive-actions {
  display: flex;
  gap: 10px;
}

.archive-empty {
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
}

.pagination-row {
  justify-content: flex-end;
}

.status-line {
  min-height: 20px;
}

.status-line.error {
  color: var(--danger);
}

.status-line.success {
  color: var(--success);
}

.delete-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  background: transparent;
}

.delete-dialog::backdrop {
  background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(8px);
}

.delete-form {
  padding: 24px;
}

@media (max-width: 980px) {
  .upload-form,
  .archive-toolbar {
    grid-template-columns: 1fr;
  }

  .action-row {
    justify-content: flex-start;
  }

  .archive-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 100%);
    padding: 18px 0 28px;
  }

  .login-card,
  .panel,
  .delete-form {
    border-radius: 20px;
  }

  .login-card,
  .panel {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .progress-head,
  .progress-meta,
  .dialog-actions,
  .pagination-row,
  .archive-browser-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-meta {
    justify-items: start;
  }

  .archive-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}
