:root {
  --bg: #ffffff;
  --text: #000000;
  --muted: #555555;
  --link: #0000cc;
  --visited: #7b2d8e;
  --border: #cccccc;
  --badge-bg: #ffd54a;
  --badge-text: #4a3800;
}

html[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #e6e6e6;
  --muted: #aaaaaa;
  --link: #7aa7ff;
  --visited: #c99ee0;
  --border: #3a3a3a;
  --badge-bg: #5b4a12;
  --badge-text: #ffe792;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

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

.container {
  max-width: 950px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.site-title {
  text-align: center;
  font-size: 2rem;
  margin: 10px 0 16px;
}
.site-title a { color: var(--text); text-decoration: none; }

.top-links, .post-link, .nav-line {
  text-align: center;
  margin: 8px 0;
}
.post-link { font-size: 1.1rem; }

.inline-form { display: inline; margin: 0; }

.link-button {
  background: none;
  border: none;
  color: var(--link);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
}
.link-button:hover { text-decoration: none; }

.board-list {
  margin: 20px 0;
  padding-left: 20px;
}
.board-list ul {
  padding-left: 22px;
  margin: 2px 0;
}
.board-list li {
  margin: 4px 0;
}

.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

.pagination {
  text-align: center;
  margin-top: 24px;
  color: var(--muted);
}

.empty-state { color: var(--muted); padding: 20px 0; text-align: center; }

.back-link { margin-bottom: 10px; }

.poll-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.poll-option { display: block; margin: 4px 0; cursor: pointer; }
.poll-count { color: var(--muted); font-size: 0.85rem; }
.poll-total { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.poll-results { margin: 6px 0; padding-left: 20px; }

form.post-form, form.auth-form, form.search-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 600px;
}
form.search-form { flex-direction: row; max-width: 500px; }
form.search-form input { flex: 1; }

label { font-weight: bold; margin-top: 8px; font-size: 0.9rem; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: normal; }

input[type="text"], input[type="password"], textarea {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
textarea { resize: vertical; }

.btn {
  margin-top: 12px;
  align-self: flex-start;
  background: #eeeeee;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 3px;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { background: #ddd; }
.btn-small { margin-top: 8px; padding: 4px 12px; font-size: 0.85rem; }

.quoted-parent {
  border-left: 2px solid var(--border);
  padding: 6px 10px;
  margin-bottom: 14px;
}
.quoted-label { color: var(--muted); font-size: 0.85rem; margin: 0 0 2px; }
.quoted-subject { margin: 0; font-weight: bold; }

.error-message {
  color: #c0392b;
  padding: 8px 0;
}

.success-message {
  color: #2e7d32;
  padding: 8px 0;
}

.poll-fields { margin-top: 8px; padding: 8px; border: 1px dashed var(--border); }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px 0;
}

.search-summary { color: var(--muted); margin-bottom: 10px; }

.hint { color: var(--muted); font-size: 0.85rem; }

/* Single message / thread page */
.message-subject { font-size: 1.6rem; margin: 10px 0 4px; }
.posted-line { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }
.message-image img { max-width: 100%; border-radius: 4px; margin: 8px 0; }
.message-body { white-space: pre-wrap; word-break: break-word; margin: 10px 0 16px; }
.message-body ul, .message-body ol, .message-body li { white-space: normal; }
.message-body ul, .message-body ol { margin: 6px 0; padding-left: 24px; }
.message-body img { max-width: 100%; border-radius: 4px; }
.thread-label { font-weight: bold; margin: 18px 0 4px; }

.embed-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  margin: 10px 0;
}
.embed-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.field-hint { font-weight: normal; color: var(--muted); font-size: 0.82rem; }

.reply-form-wrap { margin-top: 24px; max-width: 600px; }
.reply-heading { margin-bottom: 6px; }

.quoted-label { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }

/* Admin / moderation */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 30px;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.admin-actions { display: flex; gap: 10px; }
.link-button.danger { color: #c0392b; }

/* Announcement banner */
.announcement-banner {
  background: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  margin: 10px 0 16px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.admin-inline-actions { font-size: 0.85rem; color: var(--muted); margin: -4px 0 10px; }

.btn-secondary {
  background: #f5f5f5;
}
.btn-secondary:hover { background: #e5e5e5; }

/* Emoji picker */
.emoji-picker-wrap { margin: 4px 0 12px; }
.emoji-toggle-btn { margin-top: 0; }
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
  max-width: 600px;
}
.emoji-btn {
  font-size: 1.15rem;
  line-height: 1;
  padding: 4px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.emoji-btn:hover { background: var(--border); }

/* Announcement style controls in admin */
.announcement-style-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}
.announcement-style-row input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel, var(--bg));
  cursor: pointer;
}
.announcement-style-row input[type="color"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.style-toggle-row {
  display: flex;
  gap: 8px;
  margin: 4px 0;
  flex-wrap: wrap;
}
.style-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
}
.style-toggle:hover { background: var(--border); }

/* Disguise mode */
#disguise-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  overflow: auto;
}

.disguise-toolbar {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  border-bottom: 1px solid #dadce0;
  padding: 6px 12px;
  z-index: 1;
}
.disguise-menu {
  color: #3c4043;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.disguise-formula-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 3px;
  padding: 4px 8px;
  max-width: 400px;
}
.disguise-cell-ref {
  font-weight: bold;
  color: #3c4043;
  font-size: 0.85rem;
  border-right: 1px solid #dadce0;
  padding-right: 8px;
}
.disguise-fx {
  color: #5f6368;
  font-style: italic;
  font-size: 0.85rem;
}

.disguise-grid-wrap { padding: 0; }
.disguise-grid {
  border-collapse: collapse;
  font-size: 0.8rem;
  color: #202124;
}
.disguise-grid th, .disguise-grid td {
  border: 1px solid #e0e0e0;
  padding: 4px 10px;
  min-width: 70px;
  height: 20px;
  text-align: left;
  white-space: nowrap;
}
.disguise-grid th {
  background: #f8f9fa;
  color: #5f6368;
  font-weight: normal;
  text-align: center;
  position: sticky;
  top: 0;
}

/* Formatting toolbar */
.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
.fmt-btn {
  font-size: 0.9rem;
  padding: 4px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}
.fmt-btn:hover { background: var(--border); }

/* Visited-link tracking (per account, not per browser) */
a.visited-link {
  color: var(--visited);
}
