:root {
  --arsiv-ink: #1c2430;
  --arsiv-muted: #5a6573;
  --arsiv-line: rgba(28, 36, 48, 0.14);
  --arsiv-gold: #9a741d;
  --arsiv-surface: rgba(255, 250, 242, 0.72);
  --arsiv-mani: #5c7a6e;
  --arsiv-toharya: #1a3350;
  --arsiv-phagspa: #1a4336;
  --arsiv-uygur: #163552;
}

.arsiv-page {
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(154, 116, 29, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(47, 111, 126, 0.1), transparent 50%),
    linear-gradient(180deg, #f7f1e6 0%, #ebe4d6 48%, #e4ddd0 100%);
  min-height: 100vh;
  color: var(--arsiv-ink);
}

.arsiv-main {
  max-width: var(--content, 1100px);
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 48px) 96px;
}

.arsiv-hero {
  margin-bottom: 36px;
  position: relative;
}

.arsiv-hero h1 {
  font-family: "Fraunces", "IBM Plex Serif", Georgia, serif;
  font-size: clamp(2rem, 4.2vw, 3.2rem);
  letter-spacing: -0.03em;
  margin: 0.15em 0 0.4em;
  line-height: 1.1;
}

.arsiv-hero .lede {
  max-width: 40rem;
  color: var(--arsiv-muted);
  line-height: 1.55;
  font-size: 1.05rem;
}

.arsiv-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.arsiv-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 16px;
  font: 12px/1.3 var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--arsiv-gold);
}

.arsiv-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}

.arsiv-toolbar button {
  appearance: none;
  border: 1px solid var(--arsiv-line);
  background: var(--arsiv-surface);
  color: var(--arsiv-ink);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: 13px/1.2 var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  cursor: pointer;
}

.arsiv-toolbar button[aria-pressed="true"] {
  border-color: var(--arsiv-gold);
  box-shadow: inset 0 0 0 1px rgba(154, 116, 29, 0.35);
  background: #fff;
}

.arsiv-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.arsiv-card {
  display: grid;
  grid-template-columns: minmax(0, 160px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  border: 1px solid var(--arsiv-line);
  background: var(--arsiv-surface);
  border-radius: 12px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.25s ease;
}

.arsiv-card:hover,
.arsiv-card:focus-visible {
  border-color: rgba(154, 116, 29, 0.55);
  transform: translateY(-2px);
  outline: none;
}

.arsiv-card-thumb {
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #e8dfd0;
  min-height: 110px;
  display: grid;
  place-items: center;
}

.arsiv-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.arsiv-card h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-family: "Fraunces", Georgia, serif;
}

.arsiv-card p {
  margin: 0;
  color: var(--arsiv-muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.arsiv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.arsiv-pill {
  font: 10px/1 var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--arsiv-line);
  background: #fff;
}

.arsiv-pill.alphabet-mani { color: var(--arsiv-mani); border-color: rgba(92, 122, 110, 0.4); }
.arsiv-pill.alphabet-emperyal-toharya { color: var(--arsiv-toharya); border-color: rgba(26, 51, 80, 0.35); }
.arsiv-pill.alphabet-phagspa { color: var(--arsiv-phagspa); border-color: rgba(26, 67, 54, 0.4); }
.arsiv-pill.alphabet-eski-uygur { color: var(--arsiv-uygur); border-color: rgba(22, 53, 82, 0.4); }

.arsiv-detail {
  margin-top: 42px;
  border-top: 1px solid var(--arsiv-line);
  padding-top: 28px;
  display: none;
}

.arsiv-detail.is-open {
  display: block;
  animation: arsiv-fade 0.35s ease;
}

@keyframes arsiv-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.arsiv-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 22px;
}

.arsiv-plate {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--arsiv-line);
  background: #efe6d4;
}

.arsiv-plate img {
  width: 100%;
  display: block;
}

.arsiv-plate figcaption {
  padding: 10px 12px 12px;
  font-size: 0.82rem;
  color: var(--arsiv-muted);
  line-height: 1.4;
}

.arsiv-fields {
  display: grid;
  gap: 14px;
}

.arsiv-field {
  border-left: 3px solid rgba(154, 116, 29, 0.45);
  padding: 4px 0 4px 14px;
}

.arsiv-field h3 {
  margin: 0 0 6px;
  font: 11px/1.2 var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--arsiv-gold);
}

.arsiv-field p,
.arsiv-field pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
  font-family: inherit;
}

.script-mani {
  font-family: "Noto Sans Manichaean", "Noto Sans", serif;
  direction: rtl;
  font-size: 1.55rem;
  line-height: 1.6;
}

.script-phagspa {
  font-family: "Noto Sans Phags Pa", "Noto Sans", serif;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  font-size: 1.45rem;
  line-height: 1.4;
  min-height: 7rem;
}

.script-uygur {
  font-family: "Noto Serif Old Uyghur", "Noto Serif", serif;
  direction: rtl;
  writing-mode: sideways-lr;
  text-orientation: mixed;
  unicode-bidi: plaintext;
  font-size: 1.45rem;
  line-height: 1.35;
  min-height: 7rem;
}

.script-toharya {
  font-family: "Gentium Plus", "Times New Roman", serif;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

.arsiv-glyph-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
}

.arsiv-glyph-strip figure {
  margin: 0;
  text-align: center;
  background: #fffaf2;
  border: 1px solid var(--arsiv-line);
  border-radius: 8px;
  padding: 6px 8px 4px;
}

.arsiv-glyph-strip img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
}

.arsiv-glyph-strip figcaption {
  font: 11px/1.2 var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  color: var(--arsiv-muted);
  margin-top: 4px;
}

.arsiv-sources {
  margin: 10px 0 0;
  padding-left: 1.1rem;
  color: var(--arsiv-muted);
  font-size: 0.9rem;
}

.arsiv-sources a { color: inherit; }

.arsiv-grow-status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px dashed var(--arsiv-line);
  border-radius: 10px;
  background: rgba(255, 250, 242, 0.55);
}

.arsiv-grow-line {
  margin: 0 0 10px;
  color: var(--arsiv-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.arsiv-intake {
  margin-top: 48px;
  padding: 22px 24px;
  border: 1px solid var(--arsiv-line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(154, 116, 29, 0.08), transparent 40%),
    var(--arsiv-surface);
}

.arsiv-intake h2 {
  margin: 0 0 8px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.45rem;
}

.arsiv-intake .lede {
  margin: 0 0 16px;
  color: var(--arsiv-muted);
  max-width: 42rem;
  line-height: 1.5;
}

.arsiv-intake form {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.arsiv-intake label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--arsiv-muted);
}

.arsiv-intake label.wide { grid-column: 1 / -1; }

.arsiv-intake input,
.arsiv-intake select,
.arsiv-intake textarea {
  width: 100%;
  border: 1px solid var(--arsiv-line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--arsiv-ink);
  font: inherit;
}

.arsiv-intake .message {
  grid-column: 1 / -1;
  margin: 0;
  min-height: 1.2em;
  font-size: 0.9rem;
}

.arsiv-intake .message.ok { color: #176b4d; }
.arsiv-intake .message.err { color: #a83e4c; }

.arsiv-rahim-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 780px) {
  .arsiv-card,
  .arsiv-detail-grid,
  .arsiv-intake form {
    grid-template-columns: 1fr;
  }
  .script-phagspa,
  .script-uygur {
    writing-mode: horizontal-tb;
    direction: ltr;
    min-height: 0;
  }
}
