/* Oids frontend — lightweight, dark-mode-friendly, mobile-first */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #1b1b18;
  --muted: #6d6d66;
  --border: #e2e2da;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0ff;
  --danger: #c2410c;
  --danger-soft: #fff3ea;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --maxw: 640px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --surface: #18181e;
    --surface-2: #202027;
    --text: #eceae4;
    --muted: #a3a39a;
    --border: #2b2b33;
    --accent: #9a97ff;
    --accent-strong: #b3b1ff;
    --accent-soft: #23233f;
    --danger: #fb923c;
    --danger-soft: #3a2417;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.logo {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.logo:hover { text-decoration: none; }
.logo-dot {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  display: inline-block;
}
.site-nav { display: flex; gap: 0.9rem; font-size: 0.95rem; }
.site-nav a { color: var(--muted); }
.site-nav a.active, .site-nav a:hover { color: var(--text); }
.header-spacer { flex: 1; }
.auth-area { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.auth-user { font-weight: 600; color: var(--text); }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
@media (prefers-color-scheme: dark) { .btn-primary { color: #101014; } }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

/* ---------- layout ---------- */
#view { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1rem 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
}

/* ---------- hero / landing ---------- */
.hero { text-align: left; }
.hero h1 { margin: 0.2rem 0 0.5rem; font-size: 1.7rem; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin: 0.4rem 0; }
.hero .tagline { font-size: 1.05rem; color: var(--text); }
.hero-cta { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }
.quickstart {
  margin-top: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* ---------- composer ---------- */
.composer textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.composer textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
}
.char-count { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.char-count.over { color: var(--danger); font-weight: 700; }

/* ---------- posts ---------- */
.post { padding: 0.95rem 1.1rem; }
.post-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.45rem; }
.avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.post-meta { display: flex; flex-direction: column; line-height: 1.3; }
.post-user { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.post-user:hover { text-decoration: underline; }
.post-time { font-size: 0.8rem; color: var(--muted); }
.post-time:hover { text-decoration: underline; }
.post-content { margin: 0.35rem 0 0.6rem; overflow-wrap: break-word; white-space: pre-wrap; }
.post-foot { display: flex; align-items: center; gap: 1rem; }
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
}
.like-btn:hover { color: var(--danger); background: var(--danger-soft); }
.like-btn.liked { color: var(--danger); }
.permalink { font-size: 0.8rem; color: var(--muted); }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 1rem; align-items: center; }
.profile-head .avatar { width: 3.4rem; height: 3.4rem; font-size: 1.6rem; }
.profile-name { font-size: 1.4rem; font-weight: 800; margin: 0; }
.profile-stats { display: flex; gap: 1.2rem; margin-top: 0.7rem; font-size: 0.9rem; color: var(--muted); }
.profile-stats strong { color: var(--text); font-size: 1.05rem; margin-right: 0.25rem; }
.rss-link { font-size: 0.85rem; }

/* ---------- tag ---------- */
.tag-title { font-size: 1.5rem; font-weight: 800; margin: 0.2rem 0 0.8rem; }

/* ---------- docs ---------- */
.docs h2 { margin-top: 1.6rem; font-size: 1.15rem; }
.docs h3 { margin-top: 1.1rem; font-size: 1rem; }
.docs table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin: 0.6rem 0; }
.docs th, .docs td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.docs th { color: var(--muted); font-weight: 600; }
.docs code, .inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.docs pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  overflow-x: auto;
  font-size: 0.82rem;
}

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 400px;
  padding: 1.4rem;
}
.modal h2 { margin: 0 0 0.8rem; font-size: 1.25rem; }
.modal-tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.modal-tabs .btn { flex: 1; }
.field { margin-bottom: 0.8rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.field input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field .hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  margin-bottom: 0.8rem;
}
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; }

/* ---------- toast ---------- */
#toast-root {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  width: min(92vw, 480px);
}
.toast {
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.2s ease-out;
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- misc ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
}
.empty p { margin: 0.4rem 0; }
.spinner {
  text-align: center;
  color: var(--muted);
  padding: 1.6rem;
  font-size: 0.95rem;
}
.sentinel { height: 1px; }
.load-more-wrap { text-align: center; margin: 0.5rem 0 2rem; }

.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  justify-content: center;
  border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
  .site-nav { display: none; }
  .hero h1 { font-size: 1.4rem; }
  #view { padding: 0.75rem 0.75rem 4rem; }
}
