@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Libre+Baskerville:wght@400;700&display=swap');

:root {
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: #fbf7f7;
  --ink: #384143;
  --muted: #7f6f6f;
  --line: rgba(56, 65, 67, 0.14);
  --accent: #967e7e;
  --accent-soft: #eadfdf;
  --danger: #ab2f2f;
  --shadow: 0 24px 64px rgba(56, 65, 67, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top right, rgba(150, 126, 126, 0.18), transparent 24%),
    linear-gradient(180deg, #fffdfc 0%, #f8f3f1 100%);
}

a,
button,
input {
  font: inherit;
}

h1,
h2,
h3 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-weight: 400;
}

.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.summary-card,
.card,
.modal,
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-card {
  width: min(480px, 100%);
  padding: 32px;
}

.eyebrow {
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  color: var(--muted);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2.3rem, 5vw, 4rem);
  line-height: 1.02;
}

h2,
h3,
p {
  margin-top: 0;
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.message {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
}

.message.is-error {
  color: var(--danger);
  border-color: rgba(171, 47, 47, 0.18);
  background: rgba(171, 47, 47, 0.08);
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

button,
.button,
.admin-link {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease;
}

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

button,
.button-primary {
  background: var(--ink);
  color: #fff;
}

.button-secondary,
.button-ghost,
.admin-link {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  color: var(--ink);
}

.button-secondary {
  background: var(--accent-soft);
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.caption {
  margin-top: 18px;
  font-size: 0.92rem;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.page-library .hero {
  position: sticky;
  top: 12px;
  z-index: 35;
  padding: 18px 20px;
  margin: -6px -20px 24px;
  background: rgba(255, 253, 252, 0.9);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 18px 40px rgba(56, 65, 67, 0.08);
  backdrop-filter: blur(14px);
}

.hero-main {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex: 1;
  min-width: 0;
}

.hero-admin {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-copy {
  min-width: 0;
}

.hero-bar {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.hero-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.hero-heading h1 {
  margin-bottom: 10px;
}

.lede {
  margin: 0;
  max-width: 60ch;
  margin-bottom: 0;
}

.session-indicator {
  flex-shrink: 0;
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.94rem;
  text-align: right;
}

.session-indicator strong {
  color: var(--ink);
}

.inline-form {
  display: inline;
}

.link-button {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin-left: 8px;
  text-decoration: underline;
}

.menu-shell {
  position: relative;
  flex-shrink: 0;
  z-index: 20;
}

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 52px;
  height: 52px;
  padding: 0;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  border-radius: 999px;
  background: currentColor;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  min-width: 240px;
  padding: 16px;
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.menu-panel[hidden] {
  display: none !important;
}

.menu-label {
  margin: 0 0 4px;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.menu-link {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.96rem;
  font-weight: 500;
  text-align: left;
}

.menu-link-active {
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--line);
  color: var(--ink);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head-column {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.library-toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.library-toolbar-row h2 {
  margin-bottom: 0;
}

.library-sort-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.library-sort-label {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.library-sort-direction {
  min-width: 52px;
  padding-inline: 0;
  text-align: center;
}

.search-input {
  width: min(340px, 100%);
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  font-size: 1.08rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(56, 65, 67, 0.04);
  outline: none;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 280px));
  justify-content: start;
  align-items: start;
  gap: 16px;
}

.card {
  width: 280px;
  min-height: 332px;
  padding: 20px;
  display: grid;
  grid-template-rows: minmax(56px, auto) auto 1fr;
  gap: 16px;
}

.card h3 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.artwork-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(150, 126, 126, 0.18), rgba(56, 65, 67, 0.08)),
    var(--surface-soft);
}

.artwork-frame img,
.artwork-link {
  display: block;
  width: 100%;
  height: 100%;
}

.artwork-frame img {
  object-fit: cover;
  object-position: center;
}

.artwork-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.85), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.08));
}

.artwork-placeholder span {
  max-width: 18ch;
  font-size: 0.92rem;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-self: end;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(56, 65, 67, 0.35);
  pointer-events: none;
  z-index: 50;
}

.modal-backdrop.is-open {
  display: flex;
  pointer-events: auto;
}

.modal {
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
}

.result-modal {
  width: min(920px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.preview-stage {
  min-height: 240px;
  max-height: 70vh;
  overflow: auto;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.preview-pages {
  display: none;
  gap: 16px;
}

.preview-pages img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.preview-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
}

.admin-shell {
  display: grid;
  gap: 24px;
}

.admin-hero-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  align-items: stretch;
}

.admin-hero-copy {
  padding: 28px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.summary-card {
  padding: 18px 20px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
}

.admin-panel {
  padding: 24px;
}

.admin-message {
  margin-bottom: 18px;
}

.admin-actions-grid {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.log-filter-form {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.log-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.log-search-field {
  grid-column: 1 / -1;
}

.log-file-label {
  font-size: 0.96rem;
  line-height: 1.6;
  word-break: break-word;
}

.log-entry-list {
  display: grid;
  gap: 16px;
}

.log-entry-card {
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.log-entry-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.log-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.log-chip-level-info {
  color: #0b7a75;
  border-color: rgba(11, 122, 117, 0.2);
  background: rgba(11, 122, 117, 0.08);
}

.log-chip-level-warning {
  color: #8a5a12;
  border-color: rgba(244, 162, 97, 0.26);
  background: rgba(244, 162, 97, 0.12);
}

.log-chip-level-error {
  color: var(--danger);
  border-color: rgba(171, 47, 47, 0.2);
  background: rgba(171, 47, 47, 0.08);
}

.log-chip-level-debug {
  color: #445a71;
  border-color: rgba(68, 90, 113, 0.18);
  background: rgba(68, 90, 113, 0.08);
}

.log-entry-title {
  margin: 14px 0 0;
  font-size: 1.2rem;
}

.log-context-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.log-context-panel summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.log-context-panel pre {
  margin: 12px 0 0;
  padding: 16px;
  border-radius: 16px;
  overflow: auto;
  background: #f7f1e7;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

.admin-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.admin-select-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.admin-select {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
}

.status-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.status-line {
  margin: 4px 0 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(236, 226, 210, 0.7);
  border: 1px solid var(--line);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.status-line.is-complete {
  color: #0b7a75;
  background: rgba(11, 122, 117, 0.12);
  border-color: rgba(11, 122, 117, 0.2);
}

.status-line.is-running {
  color: #234a73;
  background: rgba(35, 74, 115, 0.12);
  border-color: rgba(35, 74, 115, 0.18);
}

.status-line.is-complete .status-dot {
  background: #0b7a75;
}

.status-line.is-running .status-dot {
  background: #234a73;
}

.status-line.is-cancelled,
.status-line.is-error {
  color: var(--danger);
  background: rgba(171, 47, 47, 0.08);
  border-color: rgba(171, 47, 47, 0.16);
}

.status-line.is-cancelled .status-dot,
.status-line.is-error .status-dot {
  background: var(--danger);
}

.result-error {
  margin-top: 0;
  margin-bottom: 14px;
}

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.modal-stat {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.modal-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.modal-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
}

.admin-select:disabled,
.button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.result-log-panel {
  margin-top: 20px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(251, 247, 247, 0.88);
}

.log-list {
  margin: 14px 0 0;
  padding-left: 22px;
  max-height: 320px;
  overflow: auto;
}

.log-entry-header {
  list-style: none;
  margin-left: -20px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(11, 122, 117, 0.08);
  color: var(--ink);
  font-weight: 700;
}

.log-entry-step {
  color: var(--muted);
  line-height: 1.55;
}

.log-entry-separator {
  list-style: none;
  margin: 10px 0 8px -20px;
  border-top: 1px solid var(--line);
  height: 0;
}

.metric {
  display: grid;
  gap: 4px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.metric:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  font-size: 1.35rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.users-toolbar {
  flex-wrap: wrap;
  align-items: end;
}

.users-toolbar label {
  min-width: 180px;
  flex: 1 1 220px;
}

.users-search {
  width: 100%;
}

.stamp {
  color: var(--muted);
  font-size: 0.95rem;
}

.users-filter-count {
  margin-bottom: 16px;
}

.grid-form {
  gap: 18px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.checkbox-row input {
  width: auto;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.12);
  border: 1px solid rgba(11, 122, 117, 0.18);
  color: #0b7a75;
  font-weight: 700;
}

.badge.is-inactive {
  background: rgba(171, 47, 47, 0.08);
  border-color: rgba(171, 47, 47, 0.16);
  color: var(--danger);
}

.stack {
  display: grid;
  gap: 12px;
}

.users-stack {
  min-width: 420px;
}

.subtle-panel {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.subtle-panel h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.compact-form {
  gap: 14px;
}

.users-inline-action {
  display: flex;
  align-items: end;
}

.users-inline-action .button {
  width: 100%;
}

.table-empty {
  margin-top: 16px;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(236, 226, 210, 0.55);
}

@media (max-width: 760px) {
  .admin-hero-grid,
  .hero,
  .modal-head,
  .hero-actions,
  .library-toolbar-row,
  .library-sort-form {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .log-filter-grid,
  .log-entry-topline {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .admin-select-label {
    justify-content: space-between;
  }

  .admin-hero-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-bar {
    flex-direction: column;
    gap: 14px;
  }

  .page-library .hero {
    top: 8px;
    margin: -4px -8px 20px;
    padding: 16px;
  }

  .page-shell {
    width: min(100% - 20px, 1180px);
  }

  .session-indicator {
    padding: 0;
    text-align: left;
  }

  .menu-panel {
    min-width: min(240px, calc(100vw - 40px));
  }

  .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .card {
    width: 100%;
    min-height: 0;
  }

  .result-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-columns,
  .three-columns {
    grid-template-columns: 1fr;
  }

  .users-stack {
    min-width: 0;
  }
}