:root {
  --bg0: #e8f0ea;
  --bg1: #f5f8f5;
  --ink: #1a2a1e;
  --muted: #5a6e5f;
  --accent: #9a7420;
  --accent-hot: #b8891a;
  --accent2: #3f6f52;
  --danger: #c04538;
  --line: rgba(154, 116, 32, 0.28);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --shadow-soft: 0 16px 40px rgba(45, 75, 55, 0.12);
  --radius: 4px;
  --font-display: "Cinzel", "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --font-ar: "Noto Naskh Arabic", "Source Sans 3", sans-serif;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body { margin: 0; min-height: 100%; min-height: 100dvh; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 95% 60% at 50% -8%, rgba(232, 196, 90, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 20%, rgba(130, 185, 150, 0.28), transparent 55%),
    radial-gradient(ellipse 55% 45% at 0% 75%, rgba(150, 200, 170, 0.22), transparent 50%),
    linear-gradient(168deg, #f7faf7 0%, #eaf2ec 48%, #e3ece6 100%);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom, 0);
  line-height: 1.5;
}
@supports (-webkit-touch-callout: none) {
  body { background-attachment: scroll; }
}
html[dir="rtl"] body { font-family: var(--font-ar); }
html[dir="rtl"] .msg { border-inline-start: 3px solid var(--accent2); }
html[dir="rtl"] .nav,
html[dir="rtl"] .cta-row,
html[dir="rtl"] .chat-form,
html[dir="rtl"] .langs { direction: rtl; }
html[dir="rtl"] .form label { text-align: right; }

/* Atmosphere layers */
.map-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(60, 90, 70, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 90, 70, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, black 18%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 40%, black 18%, transparent 72%);
  animation: drift 36s linear infinite;
  opacity: 0.55;
}
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at center, transparent 50%, rgba(180, 200, 185, 0.35) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, transparent 28%, transparent 70%, rgba(200, 220, 205, 0.4) 100%);
  opacity: 0.9;
}
.horizon {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(38vh, 320px);
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(180deg, transparent 0%, rgba(232, 196, 90, 0.12) 40%, rgba(170, 200, 175, 0.35) 100%);
  opacity: 0.85;
}
@keyframes drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 56px 56px, 56px 56px; }
}

.top, main, .foot {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.35rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1.35rem;
  padding-top: max(0.95rem, env(safe-area-inset-top, 0px));
  padding-left: max(1.35rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.35rem, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  backdrop-filter: blur(12px) saturate(1.15);
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.78);
  animation: soft-in 0.7s ease-out both;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8), 0 8px 24px rgba(45, 75, 55, 0.06);
}
.brand-mark, .brand-hero {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  color: var(--accent);
  text-decoration: none;
}
.brand-mark {
  font-size: 1.4rem;
  font-weight: 700;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
.brand:hover .brand-mark {
  color: var(--accent-hot);
  text-shadow: 0 0 18px rgba(184, 146, 31, 0.35);
}
.brand { text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 0.95rem; align-items: center; }
.nav a {
  color: var(--ink);
  text-decoration: none;
  opacity: 0.78;
  font-size: 0.95rem;
  position: relative;
  transition: color 0.18s ease, opacity 0.18s ease;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.28rem;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
  opacity: 0.7;
}
html[dir="rtl"] .nav a::after { transform-origin: right; }
.nav a.on, .nav a:hover { color: var(--accent-hot); opacity: 1; }
.nav a.on::after, .nav a:hover::after { transform: scaleX(1); }
.cta-link { color: var(--accent) !important; font-weight: 600; opacity: 1 !important; }
.who { color: var(--muted); font-size: 0.9rem; }
.inline { display: inline; margin: 0; }
.inline button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  border-radius: var(--radius);
  font: inherit;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.inline button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212, 180, 90, 0.08);
  transform: translateY(-1px);
}
.inline button:active { transform: translateY(0) scale(0.96); }
.langs a {
  color: var(--muted);
  text-decoration: none;
  margin-inline: 0.18rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.2rem;
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.langs a.on { color: var(--accent); font-weight: 700; }
.langs a:hover { color: var(--accent-hot); transform: translateY(-2px) scale(1.08); }
.langs a:active { transform: scale(0.95); }

main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 1.35rem;
  padding-left: max(1.35rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.35rem, env(safe-area-inset-right, 0px));
}

.hero {
  min-height: calc(100vh - 8rem);
  min-height: calc(100dvh - 8rem);
  display: grid;
  align-items: end;
  padding: 2.25rem 0 3.25rem;
  position: relative;
}
.hero-copy {
  max-width: 36rem;
  animation: rise 0.95s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero-ornament {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--accent2);
}
.hero-ornament::before,
.hero-ornament::after {
  content: "";
  height: 1px;
  width: 2.5rem;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.55;
  animation: ornament-breathe 4.5s ease-in-out infinite;
}
.hero-ornament::after { animation-delay: 0.35s; }
.hero-ornament span {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent2);
  font-size: 0.78rem;
  margin: 0 0 0.65rem;
}
.brand-hero {
  font-size: clamp(3.1rem, 12vw, 5.8rem);
  margin: 0;
  line-height: 0.92;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55), 0 12px 36px rgba(154, 116, 32, 0.22);
  animation: glowpulse 5.5s ease-in-out infinite;
}
@keyframes glowpulse {
  0%, 100% { text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5), 0 8px 24px rgba(154, 116, 32, 0.16); }
  50% { text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65), 0 14px 40px rgba(184, 146, 31, 0.3); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}
@keyframes soft-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheen {
  0% { transform: translateX(-120%) skewX(-18deg); opacity: 0; }
  30% { opacity: 0.55; }
  100% { transform: translateX(220%) skewX(-18deg); opacity: 0; }
}
@keyframes btn-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(184, 146, 31, 0.28); }
  50% { box-shadow: 0 10px 32px rgba(212, 180, 90, 0.42); }
}
@keyframes tap-pop {
  0% { transform: scale(1); }
  40% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(208, 106, 88, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(208, 106, 88, 0); }
}
@keyframes ornament-breathe {
  0%, 100% { opacity: 0.45; width: 2.5rem; }
  50% { opacity: 0.85; width: 3.1rem; }
}
@keyframes chip-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.lede {
  font-size: 1.28rem;
  max-width: 28rem;
  color: var(--ink);
  margin: 1rem 0 0.55rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}
.note, .hint, .honesty {
  color: var(--muted);
  max-width: 34rem;
  line-height: 1.55;
  margin: 0.4rem 0 0;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.75rem;
  animation: rise 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}
.cta-row .btn:nth-child(1) { animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both; }
.cta-row .btn:nth-child(2) { animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.32s both; }

.btn {
  display: inline-block;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  padding: 0.72rem 1.25rem;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  border-radius: var(--radius);
  transition:
    transform 0.22s cubic-bezier(0.34, 1.3, 0.64, 1),
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    color 0.22s ease,
    filter 0.22s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  will-change: transform;
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -40%;
  width: 40%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.28),
    transparent
  );
  transform: translateX(-120%) skewX(-18deg);
  pointer-events: none;
  z-index: 1;
}
.btn:hover::before {
  animation: sheen 0.75s ease-out;
}
.btn:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(212, 180, 90, 0.55);
}
.btn:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 0.08s;
}
@media (hover: none) {
  .btn:hover { transform: none; }
  .btn:active { transform: scale(0.97); }
  .btn:hover::before { animation: none; }
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary {
  background: linear-gradient(145deg, #e0c36a 0%, #b8921f 48%, #8f6e14 100%);
  border-color: #e4c878;
  color: #14110a;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(184, 146, 31, 0.28);
}
.btn.primary:hover {
  box-shadow: 0 14px 34px rgba(184, 146, 31, 0.45);
  filter: brightness(1.06);
  animation: btn-glow 1.8s ease-in-out infinite;
}
.btn.primary:active {
  filter: brightness(0.96);
  box-shadow: 0 4px 12px rgba(184, 146, 31, 0.25);
  animation: none;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(45, 75, 55, 0.08);
}
.btn.ghost:hover {
  background: #ffffff;
  color: var(--accent-hot);
  box-shadow: 0 10px 26px rgba(45, 75, 55, 0.14);
}

.tts-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin: 0.75rem 0 0.35rem;
}
.tts-voice { max-width: 14rem; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.panel {
  border-top: 1px solid transparent;
  padding: 1.65rem 0 2.25rem;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  background:
    linear-gradient(90deg, transparent, var(--line), transparent) top / 100% 1px no-repeat;
}
.panel > h1 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: clamp(1.55rem, 3.2vw, 2rem);
  letter-spacing: 0.06em;
  margin: 0 0 0.75rem;
  font-weight: 700;
}
.guide-list {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 0;
  display: grid;
  gap: 0.12rem;
}
.guide-list li {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.guide-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.65rem;
  padding: 0.5rem 0.75rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius);
}
.guide-list a::after {
  content: "→";
  color: var(--accent);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.25s ease, transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
  font-family: var(--font-body);
}
html[dir="rtl"] .guide-list a::after {
  content: "←";
  transform: translateX(6px);
}
.guide-list li:hover {
  background: rgba(212, 180, 90, 0.07);
  border-color: rgba(212, 180, 90, 0.22);
  transform: translateX(4px);
}
html[dir="rtl"] .guide-list li:hover { transform: translateX(-4px); }
.guide-list li:hover a { color: var(--accent-hot); }
.guide-list li:hover a::after {
  opacity: 0.95;
  transform: translateX(0);
}
.guide-list li {
  animation: chip-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.guide-list li:nth-child(1) { animation-delay: 0.04s; }
.guide-list li:nth-child(2) { animation-delay: 0.08s; }
.guide-list li:nth-child(3) { animation-delay: 0.12s; }
.guide-list li:nth-child(4) { animation-delay: 0.16s; }
.guide-list li:nth-child(5) { animation-delay: 0.2s; }
.guide-list li:nth-child(6) { animation-delay: 0.24s; }
.guide-list li:nth-child(7) { animation-delay: 0.28s; }
.guide-list li:nth-child(8) { animation-delay: 0.32s; }

.md { line-height: 1.7; max-width: 42rem; }
.md h1 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: clamp(1.5rem, 3vw, 1.95rem);
  margin: 0 0 0.9rem;
  letter-spacing: 0.04em;
}
.md h2 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.08rem;
  margin: 1.75rem 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(212, 180, 90, 0.22);
  letter-spacing: 0.03em;
}
.md h3 {
  font-family: var(--font-display);
  color: var(--accent2);
  margin: 1.3rem 0 0.45rem;
}
.md p { margin: 0.6rem 0; color: var(--ink); }
.md ul, .md ol { margin: 0.45rem 0 0.75rem; padding-inline-start: 1.25rem; }
.md li { margin: 0.3rem 0; }
.md strong { color: #6e5214; font-weight: 700; }
.md img {
  display: block;
  max-width: min(100%, 720px);
  width: 100%;
  height: auto;
  margin: 0.85rem 0 1.15rem;
  border-radius: var(--radius);
  border: 1px solid rgba(154, 116, 32, 0.22);
  box-shadow: var(--shadow-soft);
  background: #0b1220;
}
.md blockquote {
  margin: 1rem 0 1.15rem;
  padding: 0.85rem 1.1rem;
  border-inline-start: 3px solid var(--accent);
  background: linear-gradient(90deg, rgba(184, 146, 31, 0.14), transparent 88%);
  color: var(--ink);
  font-size: 1.03rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.md blockquote p { margin: 0; }
.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0 1.2rem;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(154, 116, 32, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
}
.md th, .md td {
  text-align: start;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid rgba(60, 90, 70, 0.1);
}
.md th {
  font-family: var(--font-display);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(236, 244, 238, 0.95);
}
.md tr:nth-child(even) td { background: rgba(232, 240, 234, 0.55); }
.md td:first-child {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  width: 4.5rem;
}
.article h1 { margin-bottom: 0.35rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

.form { display: grid; gap: 0.9rem; max-width: 24rem; }
.form label { display: grid; gap: 0.4rem; color: var(--muted); }
.form input, .form select, .chat-form input, .tts-voice {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.7rem 0.8rem;
  font: inherit;
  border-radius: var(--radius);
  font-size: 16px;
  max-width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form input:focus, .form select:focus, .chat-form input:focus, .tts-voice:focus {
  outline: none;
  border-color: rgba(154, 116, 32, 0.55);
  box-shadow: 0 0 0 3px rgba(184, 146, 31, 0.18);
}
.form input, .form select, .chat-form input {
  -webkit-appearance: none;
  appearance: none;
}
.auth {
  max-width: 28rem;
}
.auth .honesty { margin-bottom: 1rem; }
.err { color: var(--danger); }
.switch { margin-top: 1rem; }
.switch a { color: var(--accent); text-decoration: none; }
.switch a:hover { color: var(--accent-hot); }

.chat-log {
  min-height: 280px;
  max-height: min(55vh, 55dvh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(242, 248, 244, 0.88));
  padding: 0.95rem;
  display: grid;
  gap: 0.75rem;
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--shadow-soft);
}
.msg {
  border-inline-start: 3px solid var(--accent2);
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.88);
  overflow-wrap: anywhere;
  word-break: break-word;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background 0.2s ease, transform 0.2s ease;
  animation: chip-in 0.35s ease-out both;
  box-shadow: 0 2px 8px rgba(45, 75, 55, 0.06);
}
.msg:hover {
  background: #ffffff;
  transform: translateX(2px);
}
.msg-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.4rem;
}
.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid rgba(154, 116, 32, 0.28);
  background: #dde8e0;
}
.msg-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #3f6f52, #2f5540);
}
.msg-head-text { min-width: 0; flex: 1; }
.msg-nick-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.msg-nick {
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-tts {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 1.55rem;
  height: 1.55rem;
  min-width: 1.55rem;
  min-height: 1.55rem;
  padding: 0;
  margin: 0;
  border: 1.5px solid rgba(63, 111, 82, 0.35);
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(160deg, #f4f8f5, #e4eee7);
  color: #2f5540;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(45, 75, 55, 0.12);
  opacity: 0.9;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.msg-tts-ico {
  width: 0.78rem;
  height: 0.78rem;
  display: block;
  pointer-events: none;
}
.msg-tts:hover,
.msg-tts:focus-visible {
  opacity: 1;
  background: #fff;
  outline: none;
  transform: scale(1.08);
  box-shadow: 0 2px 6px rgba(45, 75, 55, 0.18);
}
.msg .meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 0; }
.msg-body { display: grid; gap: 0.35rem; }
.msg .orig { opacity: 0.75; font-size: 0.92rem; }
.msg .tr { margin-top: 0.1rem; }

.who-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--muted);
}
.who-link:hover { color: var(--accent); }
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(154, 116, 32, 0.28);
}
.nav-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #3f6f52, #2f5540);
}

.profile-avatar-card {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0 1.25rem;
}
.profile-avatar-preview {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(154, 116, 32, 0.35);
  box-shadow: var(--shadow-soft);
  background: #dde8e0;
}
.profile-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #3f6f52, #2f5540);
}
.profile-nick {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  letter-spacing: 0.04em;
}
.profile-ok { color: var(--accent2); font-weight: 600; }
.profile-form { margin-top: 0.5rem; }
.chat-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.95rem;
  align-items: stretch;
}
.chat-form input { flex: 1 1 12rem; min-width: 0; }
.chat-form .btn.primary { flex: 0 0 auto; }
.chat-tool {
  flex: 0 0 auto;
  align-self: center;
  box-sizing: border-box;
  width: 2.35rem;
  height: 2.35rem;
  min-width: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
  margin: 0;
  border: 1.5px solid rgba(63, 111, 82, 0.35);
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(160deg, #f4f8f5, #e4eee7);
  color: #2f5540;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(45, 75, 55, 0.12);
  opacity: 0.95;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chat-tool-ico {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  pointer-events: none;
}
.chat-tool:hover,
.chat-tool:focus-visible {
  opacity: 1;
  background: #fff;
  outline: none;
  transform: scale(1.08);
  box-shadow: 0 2px 6px rgba(45, 75, 55, 0.18);
}
.chat-tool.recording {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(208, 106, 88, 0.18);
  box-shadow: 0 0 0 0 rgba(208, 106, 88, 0.45);
  animation: rec-pulse 1.2s ease-out infinite;
}
.chat-rec-status {
  margin: 0.45rem 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}
.chat-image {
  display: block;
  max-width: min(100%, 320px);
  width: 100%;
  height: auto;
  max-height: 280px;
  border-radius: var(--radius);
  margin: 0.35rem 0;
  object-fit: contain;
  background: #e8f0ea;
}
.chat-audio {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0.35rem 0;
}
.chat-caption { opacity: 0.9; font-size: 0.92rem; }

.commanders-page h1 {
  font-family: var(--font-display);
  color: var(--accent);
  margin: 0 0 0.45rem;
  letter-spacing: 0.05em;
}
.cmd-lead { color: var(--muted); margin: 0 0 0.35rem; max-width: 40rem; }
.cmd-filter-hint { color: var(--muted); margin: 0 0 0.45rem; font-size: 0.9rem; max-width: 42rem; }
.cmd-tier-note { color: var(--muted); margin: 0 0 1rem; font-size: 0.9rem; max-width: 42rem; }
.cmd-filters { display: grid; gap: 0.9rem; margin-bottom: 0.95rem; }
.cmd-filter-label {
  display: block;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.cmd-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cmd-chip {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.45rem 0.8rem;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: var(--radius);
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 0.2s ease;
  animation: chip-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  box-shadow: 0 2px 8px rgba(45, 75, 55, 0.06);
}
.cmd-chips .cmd-chip:nth-child(1) { animation-delay: 0.02s; }
.cmd-chips .cmd-chip:nth-child(2) { animation-delay: 0.05s; }
.cmd-chips .cmd-chip:nth-child(3) { animation-delay: 0.08s; }
.cmd-chips .cmd-chip:nth-child(4) { animation-delay: 0.11s; }
.cmd-chips .cmd-chip:nth-child(5) { animation-delay: 0.14s; }
.cmd-chips .cmd-chip:nth-child(6) { animation-delay: 0.17s; }
.cmd-chips .cmd-chip:nth-child(7) { animation-delay: 0.2s; }
.cmd-chips .cmd-chip:nth-child(8) { animation-delay: 0.23s; }
.cmd-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.cmd-chip:active { transform: translateY(0) scale(0.96); }
.cmd-chip.on {
  background: rgba(184, 146, 31, 0.16);
  border-color: var(--accent);
  color: var(--accent-hot);
  box-shadow: 0 0 0 1px rgba(154, 116, 32, 0.18);
}
.cmd-chip.rarity-legendary.on { color: #9a7420; }
.cmd-chip.rarity-epic.on { color: #6d4bb8; }
.cmd-chip.rarity-elite.on { color: #2a6fad; }
.cmd-chip.rarity-advanced.on { color: #2f7a45; }
.cmd-count { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.85rem; }
.cmd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 0.95rem;
}
.cmd-card {
  display: block;
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #f3f8f4 100%);
  border: 1px solid rgba(60, 90, 70, 0.12);
  border-top: 2px solid var(--accent2);
  overflow: hidden;
  border-radius: var(--radius);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  color: inherit;
}
.cmd-card:hover {
  transform: translateY(-5px) scale(1.015);
  border-color: rgba(154, 116, 32, 0.35);
  box-shadow: 0 22px 40px rgba(45, 75, 55, 0.16);
}
.cmd-card:hover .cmd-avatar {
  transform: scale(1.03);
}
.cmd-avatar {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: center top;
  background: #dde8e0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.cmd-tier-badge {
  position: absolute;
  top: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.5rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 2px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(45, 75, 55, 0.1);
}
.cmd-chip.tier-ss.on, .cmd-tier-badge.tier-ss { color: #b8860b; border-color: rgba(184, 134, 11, 0.45); }
.cmd-chip.tier-splus.on, .cmd-tier-badge.tier-splus { color: #a67c12; border-color: rgba(166, 124, 18, 0.45); }
.cmd-chip.tier-s.on, .cmd-tier-badge.tier-s { color: #9a7420; border-color: rgba(154, 116, 32, 0.4); }
.cmd-chip.tier-a.on, .cmd-tier-badge.tier-a { color: #2a6fad; border-color: rgba(42, 111, 173, 0.4); }
.cmd-chip.tier-b.on, .cmd-tier-badge.tier-b { color: #5a6e5a; border-color: rgba(90, 110, 90, 0.4); }
.cmd-chip.tier-c.on, .cmd-tier-badge.tier-c { color: #6b6b6b; border-color: rgba(107, 107, 107, 0.4); }
.cmd-card.tier-ss { border-top-color: #ffd700; }
.cmd-card.tier-splus { border-top-color: #f0b429; }
.cmd-card.tier-s { border-top-color: #e8c76a; }
.cmd-card.tier-a { border-top-color: #60a5fa; }
.cmd-card.tier-b { border-top-color: #8a9a7a; }
.cmd-card.tier-c { border-top-color: #6b6b6b; }
.cmd-card.rarity-legendary { border-top-color: #e8c76a; }
.cmd-card.rarity-epic { border-top-color: #a78bfa; }
.cmd-card.rarity-elite { border-top-color: #60a5fa; }
.cmd-card.rarity-advanced { border-top-color: #4ade80; }
.cmd-meta { padding: 0.6rem 0.7rem 0.8rem; }
.cmd-rarity {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.cmd-card.rarity-legendary .cmd-rarity { color: #9a7420; }
.cmd-card.rarity-epic .cmd-rarity { color: #6d4bb8; }
.cmd-card.rarity-elite .cmd-rarity { color: #2a6fad; }
.cmd-card.rarity-advanced .cmd-rarity { color: #2f7a45; }
.cmd-name {
  font-family: var(--font-display);
  font-size: 0.98rem;
  margin: 0.22rem 0 0.15rem;
  color: var(--ink);
  line-height: 1.25;
}
.cmd-title {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}
.cmd-talents {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.cmd-talents li {
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid rgba(154, 116, 32, 0.28);
  color: #6e5214;
  background: rgba(184, 146, 31, 0.1);
  border-radius: 2px;
}
.cmd-build-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.cmd-build-link {
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cmd-build-link:hover {
  color: var(--accent-hot);
}
.cmd-empty { color: var(--muted); }

.commander-page .cmd-detail-head {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 1.25rem;
  align-items: start;
  margin: 0.75rem 0 1.4rem;
}
.cmd-detail-portrait-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(154, 116, 32, 0.25);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-soft);
}
.cmd-detail-portrait {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}
.cmd-detail-name {
  margin: 0.2rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--ink);
}
.cmd-detail-meta .cmd-title {
  margin-bottom: 0.75rem;
}
.cmd-detail-media {
  display: grid;
  gap: 1.25rem;
  margin: 0 0 1.5rem;
}
.cmd-detail-figure {
  margin: 0;
}
.cmd-detail-figure figcaption {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.cmd-detail-figure img {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid rgba(154, 116, 32, 0.22);
  background: rgba(255, 255, 255, 0.75);
}
.cmd-detail-back {
  margin: 0;
}
.cmd-detail-back a {
  color: var(--accent);
}

.gem-scale {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.85rem 0 1.25rem;
}
.gem-h2 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  margin: 1.6rem 0 0.55rem;
}
.gem-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(154, 116, 32, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}
.gem-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.gem-table th,
.gem-table td {
  text-align: start;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(60, 90, 70, 0.1);
  vertical-align: top;
}
.gem-table th {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(236, 244, 238, 0.95);
}
.gem-table tr:nth-child(even) td { background: rgba(232, 240, 234, 0.45); }
.gem-table .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #2f5540;
  font-weight: 600;
}
.gem-table .is-hidden { display: none; }
.gem-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.gem-tier {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(154, 116, 32, 0.2);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  box-shadow: var(--shadow-soft);
}
.gem-tier h3 {
  font-family: var(--font-display);
  color: var(--accent);
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
}
.gem-tier ul {
  margin: 0;
  padding-inline-start: 1.1rem;
  color: var(--ink);
}
.gem-tier li { margin: 0.28rem 0; }
.gem-tier-qty {
  color: var(--accent2);
  font-weight: 700;
}

.foot {
  border-top: 1px solid var(--line);
  padding: 1.35rem 1.25rem 1.75rem;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
  letter-spacing: 0.04em;
}
.foot-mark {
  font-family: var(--font-display);
  color: rgba(154, 116, 32, 0.7);
  margin: 0 0 0.25rem;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  .top { align-items: flex-start; gap: 0.55rem 0.85rem; }
  .nav { gap: 0.7rem; font-size: 0.92rem; }
  .nav a::after { display: none; }
  .hero {
    min-height: calc(100vh - 11rem);
    min-height: calc(100dvh - 11rem);
    padding: 1.35rem 0 2.25rem;
  }
  .brand-hero { font-size: clamp(2.7rem, 16vw, 4.3rem); }
  .lede { font-size: 1.12rem; }
  .cmd-grid { grid-template-columns: repeat(auto-fill, minmax(142px, 1fr)); gap: 0.7rem; }
  .commander-page .cmd-detail-head { grid-template-columns: 1fr; }
  .chat-log { max-height: min(50vh, 50dvh); min-height: 220px; }
  .chat-form .btn.primary { width: 100%; }
  .tts-bar { flex-direction: column; align-items: stretch; }
  .tts-voice { max-width: none; width: 100%; }
  main { padding-top: 1rem; padding-bottom: 1.5rem; }
  .guide-list li:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .map-glow,
  .brand-hero,
  .btn.primary:hover,
  .chat-tool.recording,
  .hero-ornament::before,
  .hero-ornament::after { animation: none !important; }
  .btn:hover::before { animation: none !important; }
  .btn:hover,
  .cmd-chip:hover,
  .cmd-card:hover { transform: none; }
}
