:root {
  --bg: #0a0a0a;
  --fg: #c0c0c0;
  --accent: #ffffff;
  --border: #1a1a1a;
  --surface: #1a1a1a;
  --muted: #666;
  --dim: #444;
  --green: #4ade80;
  --purple: #a78bfa;
}

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

html {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

body {
  max-width: 720px;
  margin: 0 auto;
  padding: 4em 2em;
}

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

header {
  margin-bottom: 4em;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.lang-switcher {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75em;
  padding: 0.3em 0.5ch;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.lang-switcher:hover {
  border-color: var(--muted);
  color: var(--fg);
}

.lang-switcher:focus {
  outline: none;
  border-color: var(--accent);
}

header h1 {
  color: var(--accent);
  font-weight: normal;
  font-size: 2em;
  margin-bottom: 0.5em;
}

.definitions {
  margin-top: 2em;
}

.definition {
  margin-bottom: 1.5em;
  padding-left: 1.5em;
  border-left: 2px solid var(--border);
}

.def-label {
  color: var(--accent);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.95em;
}

.def-pos {
  color: var(--dim);
  font-style: italic;
  font-size: 0.85em;
  margin-left: 0.5ch;
}

.def-text {
  color: var(--fg);
  font-size: 0.95em;
  margin-top: 0.25em;
  max-width: 55ch;
}

section {
  margin-bottom: 4em;
}

h2 {
  color: var(--accent);
  font-weight: normal;
  font-size: 1.2em;
  margin-bottom: 1.5em;
}

/* stats */
.stats {
  color: var(--muted);
  font-size: 0.9em;
  margin-bottom: 2em;
  display: flex;
  gap: 3ch;
}

/* demo feed */
.demo-feed {
  border: 1px solid var(--border);
  padding: 0;
}

.feed-item {
  padding: 1.5em;
  border-bottom: 1px solid var(--border);
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-header {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-bottom: 0.5em;
}

.feed-author {
  color: var(--accent);
  font-size: 0.85em;
}

.feed-time {
  color: var(--dim);
  font-size: 0.8em;
  margin-left: auto;
}

.feed-text {
  color: var(--fg);
  font-size: 0.9em;
  max-height: 4.8em;
  overflow: hidden;
  transition: max-height 0.3s ease;
  cursor: pointer;
}

.feed-text.expanded {
  max-height: none;
}

.feed-item h3 {
  cursor: pointer;
}

.feed-item h3 {
  color: var(--accent);
  font-weight: normal;
  font-size: 1em;
  margin-bottom: 0.5em;
}

/* visual distinction between feed item types */
.feed-project {
  border-left: 2px solid var(--green);
  padding-left: 1.5em;
}

.feed-activity {
  color: var(--muted);
  font-size: 0.85em;
  padding: 0.75em 1.5em;
  border-left: 2px solid var(--border);
  background: none;
}

.accent { color: var(--accent); }
.green { color: var(--green); }

.project-badge {
  color: var(--muted);
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15em 0.5em;
  border: 1px solid var(--border);
}

/* tiers */
.tiers {
  margin: 0.75em 0;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.tier {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  color: var(--fg);
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border);
}

.tier-label {
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--dim);
  margin-right: 1ch;
}

.tier-detail {
  color: var(--dim);
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.5em;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
}

.progress-text {
  color: var(--dim);
  font-size: 0.8em;
}

/* layers */
.layer {
  padding: 0.75em 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
  color: var(--fg);
}

.layer-name {
  color: var(--accent);
  margin-right: 1.5ch;
}

/* how it works */
.steps {
  margin-bottom: 1em;
}

.step {
  padding: 0.5em 0;
  font-size: 0.9em;
  color: var(--fg);
}

.step-num {
  color: var(--dim);
  margin-right: 1.5ch;
}

.note {
  color: var(--dim);
  font-size: 0.85em;
  margin-top: 1em;
}

/* templates */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
}

.template-card {
  border: 1px solid var(--border);
  padding: 1.5em;
  cursor: pointer;
  transition: border-color 0.15s;
}

.template-card:hover {
  border-color: var(--muted);
}

.template-name {
  color: var(--accent);
  font-family: 'SF Mono', monospace;
  font-size: 0.9em;
  margin-bottom: 0.5em;
}

.template-desc {
  color: var(--fg);
  font-size: 0.85em;
  margin-bottom: 0;
}

.template-preview-frame {
  width: 100%;
  overflow: hidden;
  margin-top: 0.75em;
  border: 1px solid var(--border);
  background: #0a0a0a;
}

.template-expanded {
  margin-top: 1.5em;
  border: 1px solid var(--muted);
  padding: 1.5em;
}

.template-expanded-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1em;
  color: var(--accent);
  font-family: 'SF Mono', monospace;
}

@media (max-width: 600px) {
  .template-grid { grid-template-columns: 1fr; }
}

.join-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 1em;
  padding: 0.5em 1ch;
}

.join-input:focus {
  outline: none;
  border-color: var(--muted);
}

.domain-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}

/* join */
.join-form {
  border: 1px solid var(--border);
  padding: 2em;
  margin: 1.5em 0;
  text-align: center;
}

/* contracts */
.contract-list {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  margin-bottom: 1em;
}

.contract-list a {
  color: var(--fg);
  font-size: 0.9em;
}

.github {
  color: var(--muted);
  font-size: 0.9em;
}

footer {
  margin-top: 4em;
  padding-top: 2em;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 0.85em;
}

/* faq */
.faq details {
  border-bottom: 1px solid var(--border);
  padding: 1em 0;
}

.faq summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9em;
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: '+ '; color: var(--dim); }
.faq details[open] summary::before { content: '- '; }

.faq details p {
  color: var(--fg);
  font-size: 0.85em;
  line-height: 1.6;
  margin-top: 0.75em;
  max-width: 60ch;
}

@media (max-width: 480px) {
  body { padding: 2em 1em; }
  .stats { flex-direction: column; gap: 0.5em; }
}

/* RTL support */
[dir="rtl"] .definition {
  padding-left: 0;
  padding-right: 1.5em;
  border-left: none;
  border-right: 2px solid var(--border);
}

[dir="rtl"] .def-pos {
  margin-left: 0;
  margin-right: 0.5ch;
}

[dir="rtl"] .layer-name {
  margin-right: 0;
  margin-left: 1.5ch;
}

[dir="rtl"] .step-num {
  margin-right: 0;
  margin-left: 1.5ch;
}

[dir="rtl"] .tier-label {
  margin-right: 0;
  margin-left: 1ch;
}

[dir="rtl"] .feed-time {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .feed-project {
  border-left: none;
  border-right: 2px solid var(--green);
  padding-left: 1.5em;
  padding-right: 1.5em;
}

[dir="rtl"] .feed-activity {
  border-left: none;
  border-right: 2px solid var(--border);
}

[dir="rtl"] .faq summary::before { content: ' +'; float: right; }
[dir="rtl"] .faq details[open] summary::before { content: ' -'; }
