:root {
  --bg: #0c1b2a;
  --primary: #1d4ed8;
  --accent: #f7c948;
  --text: #e7ecf3;
  --muted: #92a3b8;
  --surface: #12263c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  background: linear-gradient(135deg, #0b1726 0%, #12263c 60%, #0b1726 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  background: rgba(12, 27, 42, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.brand a {
  color: white;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 1.05rem;
}

.site-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.site-nav a {
  color: var(--text);
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.site-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.site-main {
  padding: 2.5rem 0 3rem;
  flex: 1 0 auto;
}

.hero {
  background: radial-gradient(circle at 20% 20%, rgba(76, 29, 149, 0.25), transparent 35%),
              radial-gradient(circle at 80% 0%, rgba(29, 78, 216, 0.25), transparent 30%),
              var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.hero h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.hero p {
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 1rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover { transform: translateY(-4px); border-color: rgba(247, 201, 72, 0.5); }

.card h3 { margin-top: 0.2rem; margin-bottom: 0.4rem; }

.card p { color: var(--muted); margin-top: 0; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }

.button {
  display: inline-block;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--primary);
  color: white;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.button.secondary { background: transparent; border-color: rgba(255,255,255,0.3); color: var(--text); }

.section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.section h2 { margin-top: 0; }

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

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

.scan-viewer {
  background: #0a1623;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 1rem;
}

#osd-container {
  width: 100%;
  height: 70vh;
  background: #0b1726;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

#osd-container img { max-width: none; user-select: none; }

.thumb { max-width: 220px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08); }

.osd-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.osd-controls button {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.osd-controls button:hover { background: rgba(255,255,255,0.12); }

.osd-error {
  margin-top: 0.75rem;
  color: #f6b4b4;
}

.entry-header h1 {
  margin: 0.25rem 0 0.5rem;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 1.1rem;
}

.entry-thumb {
  margin-bottom: 1.35rem;
}

.entry-text {
  line-height: 1.75;
  font-size: 1.05rem;
  color: var(--text);
}

.entry-text p { margin: 0 0 0.95rem; }
.entry-text .tei-persname { font-weight: 700; }
.entry-text .tei-placename { font-weight: 700; }
.entry-text .tei-rolename { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.entry-text .tei-foreign { font-style: italic; }

.entries-table-wrapper {
  margin-top: 1.5rem;
  overflow-x: auto;
}

.entries-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 1rem;
}

.entries-table thead th {
  text-align: left;
  padding: 0.75rem 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.entries-table tbody td {
  text-align: left;
  padding: 0.85rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
}

.entries-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.entries-no {
  width: 120px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.entries-date {
  width: 12%;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.entries-name {
  font-weight: 700;
}

.entries-action {
  width: 16%;
  white-space: nowrap;
}

.entries-action .button {
  padding: 0.45rem 0.8rem;
  font-size: 0.95rem;
}

.entries-cards {
  display: none;
  margin-top: 1.5rem;
  gap: 1rem;
  flex-direction: column;
}

.entry-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  gap: 0.45rem;
}

.entry-card-no {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.entry-card-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.entry-card-dates {
  display: grid;
  gap: 0.2rem;
  color: var(--text);
}

.entry-card-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  margin-right: 0.35rem;
}

.entry-card .button {
  justify-self: start;
  margin-top: 0.4rem;
}

@media (max-width: 820px) {
  .entries-table-wrapper { display: none; }
  .entries-cards { display: flex; }
}
