*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #080808;
  --surface: rgba(12, 12, 12, 0.82);
  --surface-soft: rgba(93, 26, 26, 0.06);
  --text: #bfb8af;
  --text-dim: #918b83;
  --heading: #ddd5c8;
  --accent: #5c1a1a;
  --accent-soft: rgba(93, 26, 26, 0.18);
  --link: #a89f94;
  --link-hover: #ddd5c8;
  --rule: #1c1c1c;
  --kala: #6f9b91;
  --sumerian: #a89f94;
  --max-w: 880px;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  font-size: clamp(19px, 1.3vw + 16px, 23px);
  line-height: 1.75;
  min-height: 100vh;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url('images/background-optimized.jpg') center / cover no-repeat;
  opacity: 0.07;
  z-index: -1;
  pointer-events: none;
}

body > nav.top-nav {
  margin: 1rem auto;
  max-width: var(--max-w);
  padding: 0 clamp(20px, 5vw, 52px);
  text-align: center;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.18s;
}

a:hover,
button:hover,
input:hover,
textarea:hover {
  color: var(--link-hover);
}

button,
input,
textarea {
  font: inherit;
}

.wrap,
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 52px);
}

header {
  padding: clamp(52px, 8vw, 88px) 0 clamp(24px, 4vw, 40px);
  border-bottom: 1px solid var(--rule);
}

.site-name,
header h1 {
  font-size: clamp(30px, 5vw, 56px);
  font-weight: 300;
  font-style: normal;
  letter-spacing: 0.2em;
  color: var(--heading);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 1.2rem;
}

.site-rule {
  width: 40px;
  height: 1px;
  background: var(--accent);
  border: none;
  margin-bottom: 1.4rem;
  transition: width 0.3s ease;
}

header:hover .site-rule {
  width: 60px;
}

.site-desc,
header .subtitle {
  font-size: clamp(17px, 1.2vw + 14px, 20px);
  font-style: italic;
  color: var(--text-dim);
  max-width: 600px;
  line-height: 1.85;
  margin-bottom: 2.2rem;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  margin-top: 1.4rem;
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.top-nav a {
  color: var(--text-dim);
  border-bottom: 1px solid transparent;
  transition: color 0.18s, border-color 0.18s;
}

.top-nav a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--accent);
}

.top-nav a[aria-current="page"] {
  color: var(--heading);
  border-bottom-color: var(--accent);
}

.author-nav {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}

.author-nav a,
.platform-links a,
.other-links summary {
  color: var(--text-dim);
  transition: color 0.22s, opacity 0.22s;
  display: inline-block;
  position: relative;
}

.author-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.author-nav a:hover {
  color: var(--link-hover);
  opacity: 1;
}

.author-nav a:hover::after {
  width: 100%;
}

.author-nav .sep,
.platform-links .sep {
  margin: 0 0.5em;
  opacity: 0.3;
}

.books {
  padding: clamp(44px, 7vw, 88px) 0 clamp(20px, 3vw, 44px);
}

.book {
  display: grid;
  grid-template-columns: 152px 1fr;
  gap: clamp(24px, 4.5vw, 52px);
  padding: clamp(20px, 3vw, 36px) 0;
  border-top: 1px solid var(--rule);
  transition: transform 0.22s, opacity 0.22s;
}

.book:first-child {
  border-top: none;
  padding-top: 0;
}

.book:hover {
  transform: translateX(8px);
  opacity: 0.95;
}

.book-cover img {
  width: 152px;
  display: block;
  filter: brightness(0.88) contrast(1.06);
  transition: filter 0.22s, transform 0.22s;
}

.book:hover .book-cover img {
  filter: brightness(1) contrast(1.12);
  transform: scale(1.04);
}

.book-title {
  font-size: clamp(26px, 3.5vw, 42px);
  font-weight: 300;
  font-style: italic;
  color: var(--heading);
  letter-spacing: 0.03em;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}

.book-title a {
  color: inherit;
}

.book-title a:hover {
  color: var(--link-hover);
}

.book-meta {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.3rem;
}

.book-desc,
.total-meaning {
  font-size: clamp(18px, 1.2vw + 15px, 21px);
  line-height: 1.82;
  color: var(--text);
  margin-bottom: 1.8rem;
}

.book-desc {
  max-width: 560px;
}

.dl-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.book-cover .dl-links {
  margin-top: 16px;
  flex-wrap: nowrap;
}

.book-cover .dl-links .dl-link {
  flex: 1;
  text-align: center;
  padding-left: 0;
  padding-right: 0;
}

.dl-link,
.ref-toggle,
.top-return {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 22px;
  border: 1px solid rgba(168, 159, 148, 0.65);
  border-radius: 2px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--heading);
  box-shadow: inset 0 0 0 1px rgba(221, 213, 200, 0.03);
  transition: border-color 0.18s, color 0.18s, background-color 0.18s, transform 0.15s, box-shadow 0.18s;
  cursor: pointer;
  background: rgba(93, 26, 26, 0.08);
}

.dl-link:hover,
.ref-toggle:hover,
.top-return:hover {
  border-color: var(--heading);
  color: var(--heading);
}

.dl-link:hover {
  background-color: rgba(93, 26, 26, 0.24);
  box-shadow: inset 0 0 0 1px rgba(221, 213, 200, 0.08);
  transform: translateY(-1px);
}

.dl-link:focus-visible,
.ref-toggle:focus-visible {
  outline: 2px solid rgba(221, 213, 200, 0.75);
  outline-offset: 3px;
}


.platform-links {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 2.3;
}

.platform-links a {
  color: var(--text-dim);
}

.platform-links a:hover {
  color: var(--link-hover);
}

.other-links {
  margin-top: 0.75rem;
  color: var(--text-dim);
  position: relative;
}

.other-links summary {
  width: fit-content;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.18s;
  list-style: none;
}

.other-links summary::-webkit-details-marker {
  display: none;
}

.other-links summary::after {
  content: '▾';
  margin-left: 0.55rem;
  font-size: 0.8em;
  color: var(--text-dim);
  transition: transform 0.22s;
}

.other-links[open] summary::after {
  transform: rotate(180deg);
}

.other-links summary:hover {
  color: var(--link-hover);
}

.other-links-title {
  width: fit-content;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.55rem;
}

.other-links-list {
  display: none;
  gap: 0.18rem 1.2rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.55rem;
  font-size: 15px;
  line-height: 1.7;
}

.other-links[open] .other-links-list {
  display: grid;
}

.other-links-static .other-links-list {
  display: grid;
  margin-top: 0;
}

.other-links-list a {
  color: var(--text-dim);
}

.other-links-list a:hover {
  color: var(--link-hover);
}

.other-books-card {
  display: block;
  margin-top: 1.2rem;
  padding: clamp(28px, 5vw, 44px);
  border: 1px solid var(--rule);
  background: linear-gradient(135deg, rgba(93, 26, 26, 0.08) 0%, rgba(93, 26, 26, 0.04) 100%);
  color: var(--heading);
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.other-books-card:hover,
.other-books-card:focus-visible {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(93, 26, 26, 0.15) 0%, rgba(93, 26, 26, 0.08) 100%);
  box-shadow: 0 8px 32px rgba(93, 26, 26, 0.15);
  transform: translateY(-4px);
  color: var(--link-hover);
}

.other-books-card:focus-visible {
  outline: 2px solid rgba(221, 213, 200, 0.75);
  outline-offset: 3px;
}

.other-books-card .other-books-link,
.other-books-card .other-books-label {
  display: inline-block;
}

.other-books-card .other-books-link {
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.22s;
}

.other-books-label {
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
  opacity: 0.7;
  transition: opacity 0.22s;
}

.other-books-card:hover .other-books-label {
  opacity: 1;
}

.gematria-card {
  border-color: rgba(124, 30, 30, 0.45);
  background: linear-gradient(135deg, rgba(93, 26, 26, 0.18) 0%, rgba(10, 10, 10, 0.96) 100%);
}

.gematria-card:hover {
  border-color: #b15b5b;
  background: linear-gradient(135deg, rgba(124, 30, 30, 0.28) 0%, rgba(8, 8, 8, 0.98) 100%);
}

.archive-card {
  border-color: rgba(93, 26, 26, 0.35);
  background: linear-gradient(135deg, rgba(15, 15, 18, 0.95) 0%, rgba(31, 18, 18, 0.95) 100%);
}

.archive-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.archive-card .dl-link {
  border-color: rgba(168, 159, 148, 0.7);
  color: var(--heading);
  background: rgba(93, 26, 26, 0.12);
}

.page-back {
  margin-top: clamp(24px, 4vw, 40px);
  text-align: center;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 38px;
  padding: 7px 18px;
  border: 1px solid rgba(168, 159, 148, 0.5);
  color: var(--text-dim);
  background: rgba(8, 8, 8, 0.5);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color 0.18s, color 0.18s, background-color 0.18s, transform 0.15s;
}

.back-link:hover,
.back-link:focus-visible {
  border-color: var(--accent);
  color: var(--heading);
  background: var(--accent-soft);
}

.back-link:focus-visible {
  outline: 2px solid rgba(221, 213, 200, 0.75);
  outline-offset: 3px;
}

footer {
  border-top: 1px solid var(--rule);
  padding: clamp(40px, 6vw, 72px) 0;
  text-align: center;
}

footer .wrap {
  display: grid;
  gap: 1.25rem;
}

.footer-cards {
  display: grid;
  gap: 1rem;
}

@media (min-width: 860px) {
  .footer-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.footer-email,
.footer-copy {
  display: inline-block;
}

.footer-email {
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--text-dim);
  transition: color 0.18s, letter-spacing 0.18s;
  margin-top: 1.8rem;
  margin-bottom: 0.4rem;
}

.footer-email:hover {
  color: var(--link-hover);
  letter-spacing: 0.16em;
}

.footer-copy {
  margin-top: 1.4rem;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.78;
}

.mode-tabs {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 32px;
}

.mode-tab {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 9px 20px;
  background: rgba(8, 8, 8, 0.72);
  border: 1px solid var(--rule);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background-color 0.18s;
}

.mode-tab:not(:first-child) {
  border-left: none;
}

.mode-tab:hover {
  color: var(--link-hover);
}

.mode-tab.active {
  color: var(--heading);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-tab:focus-visible {
  outline: 2px solid rgba(221, 213, 200, 0.75);
  outline-offset: 3px;
}

.input-section {
  margin-bottom: 40px;
}

.input-wrap textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(22px, 1.3vw + 18px, 28px);
  line-height: 1.55;
  padding: 20px 24px;
  resize: vertical;
  min-height: 96px;
  outline: none;
  transition: border-color 0.22s, background-color 0.22s;
}

.input-wrap textarea:focus {
  border-color: var(--accent);
  background: rgba(12, 12, 12, 0.92);
}

.input-wrap textarea::placeholder {
  color: var(--text-dim);
  font-style: italic;
  opacity: 0.6;
}

.input-hint {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 8px;
  font-style: italic;
}

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.calc-action {
  min-height: 34px;
  padding: 6px 16px;
  border: 1px solid rgba(168, 159, 148, 0.5);
  background: rgba(8, 8, 8, 0.72);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color 0.18s, color 0.18s, background-color 0.18s, transform 0.15s;
}

.calc-action:hover,
.calc-action:focus-visible {
  border-color: var(--accent);
  color: var(--heading);
  background: var(--accent-soft);
}

.calc-action:focus-visible {
  outline: 2px solid rgba(221, 213, 200, 0.75);
  outline-offset: 3px;
}

.results {
  display: none;
}

.results.visible {
  display: block;
}

.total-section,
.word-card,
.cleaned-display,
.ref-table,
.letter-chip,
.ref-table-wrap {
  transition: border-color 0.18s, background-color 0.18s, transform 0.18s;
}

.total-section {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: clamp(28px, 5vw, 44px);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.total-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}

.total-label {
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.total-value {
  font-size: clamp(44px, 7vw, 68px);
  font-weight: 300;
  color: var(--heading);
  line-height: 1;
}

.total-meaning {
  margin-top: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--accent);
}

.total-meaning.kala-match {
  border-left-color: var(--kala);
}

.cleaned-display {
  background: var(--surface-soft);
  border: 1px solid var(--rule);
  padding: 12px 18px;
  margin-bottom: 24px;
  font-size: 16px;
  color: var(--text-dim);
}

.cleaned-display strong {
  color: var(--sumerian);
  font-weight: 400;
}

.cleaned-label,
.words-section h3,
.letters-section h3,
.ref-table th {
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.cleaned-label {
  margin-bottom: 4px;
}

.word-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 18px 22px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.word-card:hover {
  border-color: var(--accent);
  background: rgba(93, 26, 26, 0.08);
  transform: translateX(4px);
}

.word-card.has-meaning {
  border-left: 3px solid var(--accent);
}

.word-card.has-kala {
  border-left: 3px solid var(--kala);
}

.word-text {
  font-size: clamp(20px, 1.1vw + 16px, 24px);
  flex-shrink: 0;
  font-style: italic;
}

.word-cleaned {
  font-size: 0.8rem;
  color: var(--sumerian);
  margin-top: 2px;
}

.word-info {
  flex: 1;
  text-align: right;
}

.word-value {
  font-size: 30px;
  font-weight: 300;
  color: var(--heading);
}

.word-meaning {
  font-size: 16px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 2px;
}

.word-meaning.kala {
  color: var(--kala);
}

.letters-section {
  margin-bottom: 32px;
}

.letter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.letter-chip {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 6px 10px;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
}

.letter-chip:hover {
  border-color: var(--accent);
  background: rgba(93, 26, 26, 0.08);
  transform: translateY(-1px);
}

.letter-char {
  font-size: 1.1rem;
  color: var(--text);
}

.letter-val {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.letter-chip.space-chip,
.letter-chip.separator-chip {
  background: transparent;
  border-color: transparent;
  justify-content: center;
}

.letter-chip.space-chip {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.letter-chip.separator-chip {
  color: var(--accent);
  font-size: 0.9rem;
  min-width: 20px;
}

.ref-toggle {
  background: none;
  border: 1px solid var(--text-dim);
  padding: 8px 20px;
  margin: 8px 4px 0;
}

.ref-toggle:hover {
  background-color: var(--accent-soft);
  transform: scale(1.03);
}

.ref-buttons {
  text-align: center;
  margin-top: 40px;
}

.ref-table-wrap {
  display: none;
  margin-top: 16px;
  overflow-x: auto;
}

.ref-table-wrap.visible {
  display: block;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ref-table th,
.ref-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
}

.ref-table th {
  text-align: left;
}

.ref-table td {
  color: var(--text);
}

.ref-table td:first-child {
  font-size: 1.1rem;
}

.ref-table td:nth-child(3) {
  color: var(--text-dim);
}

.ref-table tr:hover td {
  background: rgba(93, 26, 26, 0.06);
}

.music-section {
  padding: clamp(44px, 7vw, 88px) 0 clamp(40px, 6vw, 72px);
}

.music-line {
  max-width: 760px;
  margin: 0 auto clamp(52px, 8vw, 88px);
  padding-bottom: clamp(32px, 5vw, 52px);
  border-bottom: 1px solid var(--rule);
}

.music-line-title {
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 300;
  font-style: italic;
  color: var(--heading);
  line-height: 1.18;
  margin-bottom: clamp(18px, 3vw, 28px);
}

.music-line p {
  color: var(--text);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.75;
  margin-bottom: 1.15em;
}

.music-line p:last-child {
  margin-bottom: 0;
}

.music-artist {
  margin-bottom: clamp(52px, 8vw, 88px);
}

.music-artist:last-child {
  margin-bottom: 0;
}

.music-artist-name {
  font-size: clamp(26px, 3.5vw, 42px);
  font-weight: 300;
  font-style: italic;
  color: var(--heading);
  letter-spacing: 0.03em;
  line-height: 1.15;
  margin-bottom: clamp(24px, 4vw, 40px);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.music-track {
  margin-bottom: clamp(28px, 4vw, 44px);
}

.music-track:last-child {
  margin-bottom: 0;
}

.music-track-title {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.music-feat {
  color: var(--text-dim);
  opacity: 0.6;
  font-size: 11px;
  letter-spacing: 0.1em;
}

.yt-thumb {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: #080808;
}

.yt-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.72) contrast(1.05);
  transition: filter 0.28s;
}

.yt-thumb:hover img {
  filter: brightness(0.88) contrast(1.08);
}

.yt-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border: 1px solid rgba(221, 213, 200, 0.55);
  border-radius: 50%;
  background: rgba(8, 8, 8, 0.55);
  transition: border-color 0.28s, background 0.28s, transform 0.22s;
}

.yt-play::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 11px 0 11px 19px;
  border-color: transparent transparent transparent rgba(221, 213, 200, 0.85);
}

.yt-thumb:hover .yt-play {
  border-color: rgba(221, 213, 200, 0.9);
  background: rgba(93, 26, 26, 0.45);
  transform: translate(-50%, -50%) scale(1.08);
}

@media (max-width: 600px) {
  .book:hover {
    transform: none;
    opacity: 1;
  }

  .book {
    grid-template-columns: 1fr;
  }

  .book-cover {
    max-width: 140px;
  }

  .book-cover img {
    width: 100%;
  }

  .other-links-list {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 20px 64px;
  }

  .word-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .word-info {
    text-align: left;
  }

  .mode-tab {
    flex: 1 1 50%;
    border: 1px solid var(--rule);
    padding: 8px 12px;
    font-size: 12px;
    text-align: center;
  }

  .mode-tab:not(:first-child) {
    border-left: 1px solid var(--rule);
  }
}
