:root {
  --paper: #efe4d2;
  --paper-strong: #e4d4bc;
  --ink: #23170f;
  --ink-soft: #655447;
  --accent: #7f2f1d;
  --accent-soft: #c57541;
  --line: rgba(35, 23, 15, 0.12);
  --card: rgba(255, 250, 242, 0.84);
  --shadow: 0 22px 48px rgba(60, 32, 12, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.42), transparent 28%),
    radial-gradient(circle at right 18%, rgba(127, 47, 29, 0.08), transparent 24%),
    linear-gradient(160deg, #f3ebdf 0%, #e8dbc8 52%, #ddceb9 100%);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(82, 54, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 54, 31, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.35;
}

a {
  color: inherit;
}

.page-shell {
  position: relative;
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.topbar,
.hero,
.panel,
.flash {
  backdrop-filter: blur(10px);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 247, 237, 0.74);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand h1,
.hero h2,
.panel h3 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  letter-spacing: 0.02em;
}

.brand p,
.hero p,
.panel p {
  margin: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #4b140a);
  color: #fef4e7;
  font-weight: 700;
  font-size: 1.15rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-link {
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid transparent;
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  border-color: rgba(127, 47, 29, 0.18);
  background: rgba(255, 255, 255, 0.55);
}

.hero {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 20px;
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 251, 244, 0.88), rgba(239, 228, 210, 0.72)),
    var(--card);
  box-shadow: var(--shadow);
}

.detail-hero {
  grid-template-columns: 1.6fr 1fr;
}

.hero-copy {
  display: grid;
  gap: 10px;
}

.hero-copy h2 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.hero-copy p {
  color: var(--ink-soft);
  line-height: 1.5;
}

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

.stat {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(127, 47, 29, 0.14);
  background: rgba(255, 255, 255, 0.54);
}

.stat span {
  display: block;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  font-weight: 700;
  color: var(--accent);
}

.stat small {
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  justify-content: flex-end;
}

.panel,
.flash {
  margin-bottom: 20px;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.flash {
  border-color: rgba(127, 47, 29, 0.22);
  background: rgba(255, 248, 239, 0.88);
}

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

.panel-head.compact {
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.search-input,
.select-input,
.edit-form input,
.edit-form textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(35, 23, 15, 0.16);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
}

.search-input {
  max-width: 480px;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.select-input {
  min-width: 220px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), #5d1d11);
  color: #fff7ef;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  box-shadow: 0 10px 24px rgba(127, 47, 29, 0.22);
}

.button:hover {
  filter: brightness(1.05);
}

.button-secondary,
.button-link {
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  border: 1px solid rgba(35, 23, 15, 0.12);
  box-shadow: none;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 22px;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
  background: rgba(255, 255, 255, 0.6);
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(35, 23, 15, 0.08);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: rgba(234, 220, 199, 0.96);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.data-table tbody tr:hover {
  background: rgba(255, 252, 247, 0.82);
}

.strong-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.mini-link,
.badge-link,
.badge-chip {
  display: inline-flex;
  margin: 0 6px 6px 0;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(127, 47, 29, 0.18);
  background: rgba(255, 255, 255, 0.74);
}

.mini-link,
.badge-link {
  text-decoration: none;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.count-chip,
.warning-chip,
.ok-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.count-chip {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(35, 23, 15, 0.1);
}

.warning-chip {
  background: rgba(127, 47, 29, 0.12);
  color: #6f2414;
}

.ok-chip {
  background: rgba(64, 111, 75, 0.12);
  color: #295636;
}

.muted {
  color: var(--ink-soft);
}

.detail-path {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.92rem;
  word-break: break-word;
}

.edit-form {
  display: grid;
  gap: 14px;
}

.edit-form label {
  display: grid;
  gap: 8px;
}

.edit-form span {
  font-weight: 600;
}

.form-hint {
  margin: -4px 0 0;
  color: var(--ink-soft);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.image-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 22px;
  border: 1px solid rgba(35, 23, 15, 0.1);
  background: rgba(255, 255, 255, 0.68);
}

.image-link {
  display: block;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(180deg, #e9d6bd 0%, #d9c3a7 100%);
  aspect-ratio: 0.78;
}

.image-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-copy {
  display: grid;
  gap: 4px;
}

.image-title {
  font-weight: 700;
  word-break: break-word;
}

.image-meta {
  color: var(--ink-soft);
  font-size: 0.92rem;
  word-break: break-word;
}

.viewer-panel {
  display: grid;
  gap: 18px;
}

.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.viewer-canvas {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 68vh;
  padding: 24px;
  overflow: auto;
  border-radius: 24px;
  border: 1px solid rgba(35, 23, 15, 0.1);
  background:
    linear-gradient(180deg, rgba(233, 214, 189, 0.55) 0%, rgba(217, 195, 167, 0.34) 100%),
    rgba(255, 255, 255, 0.65);
}

.viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  margin: auto;
}

.viewer-stage.is-loupe-active,
.viewer-stage.is-loupe-active .viewer-image {
  cursor: crosshair;
}

.viewer-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  font-size: 1.9rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink-strong);
  background: rgba(255, 248, 237, 0.9);
  border: 1px solid rgba(35, 23, 15, 0.16);
  box-shadow: 0 16px 32px rgba(35, 23, 15, 0.16);
  z-index: 2;
}

.viewer-arrow-left {
  left: 18px;
}

.viewer-arrow-right {
  right: 18px;
}

.viewer-arrow:hover,
.viewer-arrow:focus-visible {
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.98);
}

.viewer-arrow.is-disabled {
  opacity: 0.38;
  pointer-events: none;
}

.viewer-loupe {
  position: absolute;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  border: 2px solid rgba(104, 58, 20, 0.28);
  box-shadow: 0 24px 44px rgba(35, 23, 15, 0.24);
  background: rgba(255, 250, 242, 0.96);
  z-index: 3;
}

.viewer-loupe.is-hidden {
  display: none;
}

.viewer-loupe-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.viewer-image {
  display: block;
  max-width: min(92vw, 1500px);
  max-height: none;
  transform-origin: center center;
  transition: transform 0.18s ease;
  box-shadow: 0 22px 48px rgba(35, 23, 15, 0.18);
  border-radius: 18px;
}

.notes-block {
  margin-top: 18px;
}

@media (max-width: 980px) {
  .hero,
  .detail-hero {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .viewer-toolbar {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 16px 12px 28px;
  }

  .topbar,
  .hero,
  .panel,
  .flash {
    padding: 18px;
    border-radius: 22px;
  }

  .brand {
    align-items: flex-start;
  }

  .viewer-arrow {
    width: 46px;
    height: 46px;
    font-size: 1.55rem;
  }

  .viewer-arrow-left {
    left: 10px;
  }

  .viewer-arrow-right {
    right: 10px;
  }

  .viewer-loupe {
    width: 170px;
    height: 170px;
  }

  .data-table {
    min-width: 780px;
  }

  .toolbar-form {
    width: 100%;
  }

  .select-input {
    min-width: 0;
  }
}
