:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #171b19;
  --surface-2: #202620;
  --text: #f5f1e8;
  --muted: #aaa89e;
  --line: #30362f;
  --green: #68c36b;
  --lime: #c7e86f;
  --gold: #f5bd55;
  --red: #ef746f;
  --blue: #72aee6;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

:root.light {
  color-scheme: light;
  --bg: #f6f5ef;
  --surface: #ffffff;
  --surface-2: #ecefe7;
  --text: #171b19;
  --muted: #62685f;
  --line: #d9ded2;
  --shadow: 0 18px 46px rgba(48, 55, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #000000;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.18rem;
  font-weight: 800;
}

.brand img {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.nav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.nav a,
.nav-button,
.icon-button,
.admin-entry,
.email-entry,
.settings-entry {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
}

.nav a,
.nav-button {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
}

.nav a:hover,
.nav-button:hover,
.icon-button:hover,
.admin-entry:hover,
.email-entry:hover,
.settings-entry:hover {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-2);
}

.nav-button {
  cursor: pointer;
  background: transparent;
}

.icon-button {
  width: 42px;
  cursor: pointer;
  background: var(--surface);
}

.admin-entry {
  padding: 0 14px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(104, 195, 107, 0.18), rgba(245, 189, 85, 0.1));
  font-weight: 800;
}

.email-entry {
  padding: 0 14px;
  cursor: pointer;
  background: var(--surface);
  font-weight: 800;
}

.settings-entry {
  padding: 0 14px;
  cursor: pointer;
  background: color-mix(in srgb, var(--surface) 86%, var(--blue));
  font-weight: 800;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.user-chip span {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--rank-color, var(--green));
  box-shadow: 0 0 18px var(--rank-color, var(--green));
}

.user-chip strong {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.user-chip button {
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.category-home {
  margin-bottom: 24px;
}

.category-sidebar {
  position: fixed;
  inset: 0;
  z-index: 26;
}

.category-peek {
  position: fixed;
  left: 0;
  top: 42%;
  z-index: 9;
  width: 48px;
  height: 88px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--lime));
  border-left: 0;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--lime), var(--gold));
  color: #101312;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.category-peek:hover {
  transform: translateX(4px);
}

.category-sidebar-panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(430px, calc(100% - 28px));
  height: calc(100vh - 28px);
  margin: 14px auto 14px 14px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, var(--lime));
  border-radius: 8px;
  overflow: auto;
  background: var(--bg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
}

.category-sidebar-panel .section-heading {
  align-items: start;
}

.forum-home {
  scroll-margin-top: 96px;
}

.home-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.home-column {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 420px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.column-heading {
  display: grid;
  gap: 4px;
}

.column-heading h3 {
  margin-bottom: 0;
  font-size: 1.02rem;
}

.column-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.compact-thread-list .thread-item {
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
}

.compact-thread-list .vote {
  width: 8px;
  min-height: 100%;
}

.compact-thread-list .thread-item p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  margin-bottom: 10px;
}

.compact-thread-list .meta-row {
  font-size: 0.76rem;
}

.chat-shell {
  position: fixed;
  inset: 0;
  z-index: 31;
}

.chat-peek {
  position: fixed;
  right: 0;
  top: 42%;
  z-index: 9;
  width: 48px;
  height: 88px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--gold));
  border-right: 0;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gold), var(--lime));
  color: #101312;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.chat-peek:hover {
  transform: translateX(-4px);
}

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  gap: 14px;
  width: min(460px, calc(100% - 28px));
  height: calc(100vh - 28px);
  margin: 14px 14px 14px auto;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--gold));
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.chat-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.chat-header h2 {
  margin-bottom: 6px;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
}

.chat-header p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
}

.chat-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 260px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.chat-message {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.chat-message div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-message strong {
  font-size: 0.92rem;
}

.chat-message span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.chat-message p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.45;
}

.chat-form {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chat-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.chat-form textarea {
  width: 100%;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.category-detail {
  margin-bottom: 24px;
  scroll-margin-top: 96px;
}

.thread-detail {
  margin-bottom: 24px;
  scroll-margin-top: 96px;
}

.category-detail-hero {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin: 12px 0 18px;
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--detail-accent) 20%, transparent), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow);
}

.category-detail-hero .category-icon {
  width: 68px;
  height: 68px;
}

.category-detail-hero h2 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.96;
}

.category-detail-hero p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.back-button {
  width: fit-content;
  padding: 0 14px;
}

.follow-thread-button {
  margin-top: 12px;
}

.follow-thread-button.active {
  border-color: var(--lime);
  color: #101312;
  background: linear-gradient(135deg, var(--lime), var(--gold));
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 24px;
  align-items: end;
  min-height: 310px;
  padding: clamp(26px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(0, 0, 0, 0.84), rgba(0, 0, 0, 0.38)),
    url("assets/mari.png") center / cover no-repeat,
    var(--surface);
  box-shadow: var(--shadow);
}

:root.light .intro {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.28)),
    url("assets/mari.png") center / cover no-repeat,
    var(--surface);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--lime);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(3.25rem, 8vw, 6.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.intro-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.primary-action,
.secondary-action,
.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action,
.submit-button {
  border: 0;
  background: var(--green);
  color: #071008;
}

.secondary-action {
  border: 1px solid var(--line);
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.button-link {
  cursor: pointer;
  color: var(--text);
}

.primary-action {
  padding: 0 18px;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.stats-panel div {
  min-height: 94px;
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.stats-panel strong,
.stats-panel span {
  display: block;
}

.stats-panel strong {
  font-size: 1.65rem;
}

.stats-panel span {
  color: var(--muted);
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin: 24px 0;
}

.search {
  display: grid;
  gap: 8px;
  width: min(460px, 100%);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.search input,
.composer input,
.composer select,
.composer textarea,
.login-card input,
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.search input {
  min-height: 46px;
  padding: 0 14px;
}

.search input:focus,
.composer input:focus,
.composer select:focus,
.composer textarea:focus,
.login-card input:focus,
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(104, 195, 107, 0.18);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: 280px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  background: var(--surface-2);
  color: var(--text);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.section-block + .section-block,
.rules {
  margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2,
.composer h2,
.rules h2 {
  margin-bottom: 0;
  font-size: 1.22rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.9rem;
}

.category-list,
.thread-list {
  display: grid;
  gap: 10px;
}

.category-card,
.thread-item,
.composer,
.rules,
.rank-lock,
.rank-card,
.rank-progress {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.category-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.category-card:hover,
.category-card:focus-visible {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 52%),
    color-mix(in srgb, var(--surface) 94%, transparent);
  outline: 0;
  transform: translateY(-2px);
}

.category-icon {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: inset 0 -16px 28px rgba(0, 0, 0, 0.14);
}

.category-card h3,
.thread-item h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.thread-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.thread-title-line h2,
.thread-title-line h3 {
  margin-bottom: 6px;
}

.thread-title-line > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.thread-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 8px 2px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.thread-author img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
}

.thread-author:hover {
  color: var(--text);
  border-color: var(--accent);
}

.category-card p,
.thread-item p {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.meta-row span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-2);
}

.thread-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.thread-item:hover,
.thread-item:focus-visible {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 52%),
    color-mix(in srgb, var(--surface) 94%, transparent);
  outline: 0;
  transform: translateY(-2px);
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.thread-detail-card,
.comment-form,
.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.thread-detail-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 16px;
  margin: 12px 0 18px;
  padding: clamp(18px, 4vw, 28px);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--thread-accent) 18%, transparent), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow);
}

.thread-detail-card h2 {
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 5vw, 3.8rem);
  line-height: 1;
}

.thread-detail-card .thread-title-line span {
  font-size: 0.96rem;
}

.thread-detail-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.thread-owner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.author-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 76%, transparent);
}

.author-profile-card strong,
.author-profile-card span {
  display: block;
}

.author-profile-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.thread-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.thread-media-grid:empty {
  display: none;
}

.thread-media-grid img,
.thread-media-grid video {
  width: 100%;
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #000000;
}

.comment-list {
  display: grid;
  gap: 10px;
}

.comment-item {
  padding: 14px;
}

.comment-item header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.comment-item strong {
  font-size: 0.94rem;
}

.comment-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.comment-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.comment-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 16px;
}

.comment-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.comment-form textarea {
  min-height: 118px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.comment-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(104, 195, 107, 0.18);
}

.vote {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, var(--accent), transparent),
    var(--surface-2);
}

.side-column {
  position: sticky;
  top: 96px;
}

.composer,
.rules {
  padding: 18px;
}

.composer p {
  margin: 12px 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.composer form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.composer label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.composer input,
.composer select {
  min-height: 42px;
  padding: 0 12px;
}

.composer textarea {
  min-height: 132px;
  resize: vertical;
  padding: 12px;
}

.submit-button {
  width: 100%;
  cursor: pointer;
}

.rules ul {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.45;
}

.ranks-section,
.medals-section {
  scroll-margin-top: 96px;
}

.rank-lock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(114, 174, 230, 0.12), rgba(245, 189, 85, 0.08)),
    color-mix(in srgb, var(--surface) 94%, transparent);
}

.rank-lock h3 {
  margin-bottom: 6px;
}

.rank-lock p {
  margin-bottom: 0;
  color: var(--muted);
}

.rank-lock .submit-button {
  width: auto;
  padding: 0 16px;
  white-space: nowrap;
}

.rank-area {
  display: grid;
  gap: 12px;
}

.rank-progress {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.rank-progress div {
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.rank-progress span,
.rank-progress strong {
  display: block;
}

.rank-progress span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.rank-progress strong {
  margin-top: 6px;
  font-size: 1.25rem;
}

.rank-list,
.medal-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rank-card,
.medal-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.rank-card.current {
  border-color: var(--rank-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rank-color) 20%, transparent);
}

.rank-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rank-badge {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.55), transparent 18px),
    linear-gradient(135deg, var(--rank-color), color-mix(in srgb, var(--rank-color) 50%, #101312));
}

.rank-image,
.medal-image {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.rank-card h3 {
  margin-bottom: 4px;
}

.rank-threshold,
.rank-description {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.42;
}

.rank-card ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.medal-card {
  position: relative;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: start;
}

.medal-art {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.55), transparent 20px),
    linear-gradient(135deg, var(--medal-color), color-mix(in srgb, var(--medal-color) 45%, #101312));
  box-shadow: inset 0 -14px 28px rgba(0, 0, 0, 0.16);
}

.medal-card .medal-image {
  grid-column: 1;
  grid-row: 1;
  width: 56px;
  height: 56px;
}

.medal-card h3 {
  margin-bottom: 6px;
}

.medal-description,
.medal-requirement {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.42;
}

.medal-vote {
  grid-column: 1 / -1;
  width: fit-content;
  padding: 0 14px;
}

.medal-vote.active {
  border-color: var(--medal-color);
  color: #101312;
  background: linear-gradient(135deg, var(--medal-color), var(--gold));
}

.email-shell {
  position: fixed;
  inset: 0;
  z-index: 28;
}

.settings-shell {
  position: fixed;
  inset: 0;
  z-index: 29;
}

.profile-shell {
  position: fixed;
  inset: 0;
  z-index: 29;
}

.profile-panel {
  width: min(700px, calc(100% - 28px));
}

.settings-panel {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(760px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  margin: 14px auto;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--blue));
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.settings-banner {
  position: relative;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.32)),
    var(--settings-banner, url("assets/terphub-logo.png")) center / cover no-repeat,
    var(--surface);
}

.settings-banner .icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
}

.settings-banner h2 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.95;
}

.settings-banner p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
}

.settings-avatar {
  width: 88px;
  height: 88px;
  border: 2px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.settings-grid input[type="text"],
.settings-grid input[type="email"],
.settings-grid input[type="color"],
.settings-grid textarea {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.settings-grid input[type="text"],
.settings-grid input[type="email"],
.settings-grid textarea {
  padding: 0 12px;
}

.settings-grid textarea {
  min-height: 108px;
  padding-top: 12px;
  resize: vertical;
  line-height: 1.45;
}

.wide-field {
  grid-column: 1 / -1;
}

.profile-bio {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
}

.profile-medals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-badges span,
.profile-medals span {
  min-width: 42px;
  min-height: 34px;
  padding: 8px 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--medal-color) 70%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--medal-color) 18%, var(--surface));
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
}

.profile-badges span {
  border-color: color-mix(in srgb, var(--rank-color) 70%, var(--line));
  background: color-mix(in srgb, var(--rank-color) 20%, var(--surface));
}

.profile-instagram {
  width: fit-content;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  font-weight: 900;
  text-decoration: none;
  background: var(--surface-2);
}

.profile-instagram:hover {
  border-color: var(--gold);
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 58px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toggle-row input {
  width: 22px;
  height: 22px;
}

.topic-shell {
  position: fixed;
  inset: 0;
  z-index: 29;
  overflow: auto;
  padding: 18px;
  background: #000000;
}

.topic-panel {
  display: grid;
  gap: 18px;
  width: min(1180px, 100%);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--green));
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(104, 195, 107, 0.08), transparent 34%),
    var(--bg);
}

.topic-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(110deg, rgba(23, 27, 25, 0.86), rgba(23, 27, 25, 0.58)),
    url("assets/terphub-logo.png") right 24px center / 120px no-repeat,
    var(--surface);
}

.topic-panel-header h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

.topic-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  padding: 0 clamp(18px, 3vw, 28px) clamp(18px, 3vw, 28px);
}

.topic-editor-main,
.topic-editor-side {
  display: grid;
  gap: 14px;
}

.topic-editor-main label,
.topic-editor-side label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.topic-editor-main input,
.topic-editor-main textarea,
.topic-editor-side select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.topic-editor-main input,
.topic-editor-side select {
  min-height: 48px;
  padding: 0 14px;
}

.topic-editor-main textarea {
  min-height: min(54vh, 520px);
  padding: 16px;
  resize: vertical;
  line-height: 1.55;
}

.topic-editor-main input:focus,
.topic-editor-main textarea:focus,
.topic-editor-side select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(104, 195, 107, 0.18);
}

.topic-editor-side {
  position: sticky;
  top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.media-drop {
  min-height: 138px;
  align-content: center;
  padding: 14px;
  border: 1px dashed color-mix(in srgb, var(--line) 70%, var(--green));
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  cursor: pointer;
}

.media-drop input {
  width: 100%;
}

.media-drop span {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.media-preview-list {
  display: grid;
  gap: 10px;
}

.media-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.media-preview img,
.media-preview video {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  background: #000000;
}

.media-preview span {
  display: block;
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.email-panel {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(480px, calc(100% - 28px));
  margin: min(9vh, 80px) auto;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--gold));
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(245, 189, 85, 0.12), transparent 42%),
    var(--bg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.email-art {
  min-height: 174px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(23, 27, 25, 0.84), rgba(23, 27, 25, 0.45)),
    url("assets/terphub-badge.svg") right -24px center / 190px no-repeat,
    var(--surface);
}

:root.light .email-art {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.9), rgba(236, 239, 231, 0.58)),
    url("assets/terphub-badge.svg") right -24px center / 190px no-repeat,
    var(--surface);
}

.email-art h2 {
  margin-bottom: 8px;
  font-size: 2.15rem;
  line-height: 0.98;
}

.email-art p:not(.eyebrow) {
  max-width: 280px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.email-step {
  display: grid;
  gap: 14px;
}

.auth-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.auth-mode button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.auth-mode button.active {
  background: var(--surface-2);
  color: var(--text);
}

.email-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.email-panel input,
.email-panel select {
  min-height: 42px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.email-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.verify-notice {
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--gold));
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}

.verify-notice strong,
.verify-notice p {
  display: block;
  margin: 0;
}

.verify-notice p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.hidden {
  display: none;
}

.admin-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.admin-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(104, 195, 107, 0.2), transparent 34%),
    rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
}

.admin-panel {
  position: relative;
  display: grid;
  gap: 18px;
  width: min(1120px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  margin: 14px auto;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--green));
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(104, 195, 107, 0.12), transparent 38%),
    var(--bg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.admin-hero {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(20px, 4vw, 34px);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(110deg, rgba(23, 27, 25, 0.94), rgba(32, 38, 32, 0.7)),
    url("assets/terphub-badge.svg") right 28px center / 160px no-repeat;
}

:root.light .admin-hero {
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.94), rgba(236, 239, 231, 0.74)),
    url("assets/terphub-badge.svg") right 28px center / 160px no-repeat;
}

.admin-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
}

.admin-hero p:not(.eyebrow) {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-card,
.admin-dashboard {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto 28px;
}

.login-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.login-card h3 {
  margin-bottom: 6px;
}

.login-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.login-card label,
.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.login-card input,
.admin-form input,
.admin-form select {
  min-height: 42px;
  padding: 0 12px;
}

.admin-form textarea {
  min-height: 110px;
  padding: 12px;
  resize: vertical;
}

.form-error {
  grid-column: 1 / -1;
  color: var(--red);
  font-weight: 800;
}

.admin-dashboard {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
}

.admin-tabs {
  display: grid;
  gap: 8px;
  align-self: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
}

.admin-tabs button.active {
  background: var(--surface-2);
  color: var(--text);
}

.admin-view {
  display: grid;
  gap: 16px;
}

.admin-user-controls {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.admin-user-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-user-controls select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.admin-metrics div,
.admin-form,
.admin-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.admin-metrics div {
  min-height: 92px;
  padding: 16px;
}

.admin-metrics strong,
.admin-metrics span {
  display: block;
}

.admin-metrics strong {
  font-size: 1.8rem;
}

.admin-metrics span {
  color: var(--muted);
  font-size: 0.86rem;
}

.admin-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.compact-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-form label:nth-of-type(2),
.compact-form button {
  grid-column: 1 / -1;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.user-admin-list article {
  grid-template-columns: minmax(0, 1fr);
}

.admin-list h3 {
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.admin-list p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.ghost-button,
.danger-button,
.tiny-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.danger-button {
  width: fit-content;
  padding: 0 14px;
  border-color: rgba(239, 116, 111, 0.55);
  color: var(--red);
}

.tiny-button {
  padding: 0 10px;
}

.tiny-button.danger {
  color: var(--red);
}

@media (max-width: 900px) {
  .intro,
  .content-grid,
  .home-columns,
  .topic-editor-grid,
  .admin-dashboard,
  .login-card,
  .rank-list,
  .medal-list {
    grid-template-columns: 1fr;
  }

  .side-column {
    position: static;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
    min-width: 0;
  }

  .admin-tabs {
    grid-template-columns: repeat(6, 1fr);
  }

  .admin-tabs button {
    text-align: center;
    padding: 0 8px;
  }

  .topic-editor-side {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    margin-left: 0;
  }

  .icon-button {
    margin-left: auto;
  }

  .email-entry,
  .admin-entry,
  .settings-entry,
  .nav-button,
  .user-chip {
    order: 2;
  }

  main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .intro {
    min-height: 0;
    padding: 24px;
    background-size: 230px;
    background-position: right -50px top 24px;
  }

  .category-sidebar-panel {
    width: calc(100% - 20px);
    height: calc(100vh - 20px);
    margin: 10px;
  }

  .chat-panel {
    width: calc(100% - 20px);
    height: calc(100vh - 20px);
    margin: 10px;
  }

  .category-peek,
  .chat-peek {
    top: auto;
    bottom: 92px;
    width: 42px;
    height: 72px;
    font-size: 1.7rem;
  }

  .chat-peek {
    bottom: 172px;
  }

  .home-column {
    min-height: 0;
  }

  .stats-panel {
    grid-template-columns: 1fr;
  }

  .rank-lock,
  .rank-progress,
  .settings-grid,
  .settings-banner,
  .author-profile-card,
  .chat-header,
  .email-actions {
    grid-template-columns: 1fr;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .author-profile-card {
    align-items: stretch;
    flex-direction: column;
  }

  .rank-lock {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .category-card,
  .thread-item,
  .medal-card,
  .category-detail-hero,
  .thread-detail-card,
  .thread-media-grid {
    grid-template-columns: 1fr;
  }

  .admin-hero {
    background-size: 110px;
    background-position: right -26px top 16px;
  }

  .admin-metrics,
  .admin-user-controls,
  .compact-form,
  .admin-list article {
    grid-template-columns: 1fr;
  }

  .admin-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}

.hidden {
  display: none !important;
}
