﻿/* ==========================================================
   UI Refresh - calm learning workspace
   Loaded after the legacy styles and acts as the single visual layer.
   ========================================================== */

:root {
  --bg: #f3f5f1;
  --bg-grad-1: rgba(23, 111, 97, .10);
  --bg-grad-2: rgba(196, 157, 81, .08);
  --bg-grad-3: rgba(23, 111, 97, .05);

  --surface: #fffefa;
  --surface-2: #f7f8f4;
  --surface-3: #edf2ec;
  --border: #dce4dc;
  --border-2: #c8d4cc;

  --text: #17221e;
  --text-2: #53645b;
  --text-3: #6f7d75;

  --brand: #176f61;
  --brand-2: #2a8b78;
  --brand-soft: #e2f1eb;
  --accent: #176f61;
  --accent-2: #3e9885;
  --accent-soft: #e8f3ef;
  --warn: #ad741f;
  --danger: #c6545f;
  --danger-soft: #f8e9eb;

  --radius-s: 10px;
  --radius: 16px;
  --radius-l: 24px;
  --shadow-xs: 0 1px 2px rgba(23, 34, 30, .035);
  --shadow-sm: 0 2px 8px rgba(23, 34, 30, .045), 0 12px 30px -22px rgba(23, 34, 30, .22);
  --shadow-md: 0 10px 30px -18px rgba(23, 34, 30, .28), 0 2px 8px rgba(23, 34, 30, .04);
  --shadow-lg: 0 28px 70px -34px rgba(23, 34, 30, .42);

  --header-h: 68px;
  --page-max: 1320px;
  --page-wide: 1540px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "HarmonyOS Sans SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  --bg: #0d1412;
  --bg-grad-1: rgba(73, 183, 158, .09);
  --bg-grad-2: rgba(184, 147, 74, .06);
  --bg-grad-3: rgba(73, 183, 158, .045);

  --surface: #141d1a;
  --surface-2: #19231f;
  --surface-3: #202c28;
  --border: #27352f;
  --border-2: #35463f;

  --text: #edf3ef;
  --text-2: #adbbb4;
  --text-3: #8fa39a;

  --brand: #5bc1a7;
  --brand-2: #76d0b8;
  --brand-soft: #15352e;
  --accent: #5bc1a7;
  --accent-2: #76d0b8;
  --accent-soft: #17342e;
  --danger-soft: #382126;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .24);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .24), 0 12px 30px -22px rgba(0, 0, 0, .65);
  --shadow-md: 0 10px 30px -18px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .28);
  --shadow-lg: 0 28px 70px -34px rgba(0, 0, 0, .9);
}

body {
  background: var(--bg);
  font-size: 15px;
  line-height: 1.68;
}

body::before {
  opacity: .72;
  background:
    radial-gradient(56vw 48vw at 8% -8%, var(--bg-grad-1), transparent 66%),
    radial-gradient(42vw 36vw at 98% 6%, var(--bg-grad-2), transparent 62%),
    linear-gradient(180deg, transparent 0 58%, var(--bg-grad-3) 100%);
}

.page {
  max-width: min(var(--page-max), calc(var(--app-vw) - 48px));
  padding: 30px 24px 96px;
}

.page.wide {
  max-width: min(var(--page-wide), calc(var(--app-vw) - 48px));
}

/* ---------- Top navigation ---------- */
.topbar {
  height: var(--header-h);
  gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  border-bottom-color: color-mix(in srgb, var(--border) 80%, transparent);
}

.brand {
  gap: 11px;
  letter-spacing: -.15px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--brand);
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--brand) 85%, transparent);
}

.brand-text b {
  font-size: 14.5px;
  letter-spacing: -.15px;
}

.brand-text span {
  color: var(--text-3);
  font-size: 10px;
  letter-spacing: .9px;
}

.nav {
  gap: 1px;
  margin-left: 6px;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 999px;
  background: var(--surface-2);
}

.nav a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.nav a:hover {
  background: color-mix(in srgb, var(--surface-3) 80%, transparent);
}

.nav a.active {
  color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.topbar-right {
  gap: 7px;
}

.searchbox {
  width: 224px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
}

.searchbox:focus-within {
  width: 286px;
  background: var(--surface);
  border-color: color-mix(in srgb, var(--brand) 48%, var(--border));
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.avatar-btn {
  padding: 3px 11px 3px 3px;
  border-radius: 999px;
  background: var(--surface-2);
}

.avatar {
  width: 30px;
  height: 30px;
  background: var(--brand);
}

/* ---------- Shared surfaces ---------- */
.card,
.doc-card,
.quick,
.stat,
.community-card,
.forum-card,
.community-discovery,
.forum-login-note,
.profile-mini,
.profile-hero,
.role-card,
.auth-card,
.side,
.reader-main,
.forum-post-detail,
.forum-comment,
.note-panel {
  border-color: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.card.pad {
  padding: 20px;
}

.section-head {
  align-items: baseline;
  margin: 38px 0 16px;
}

.section-head h2 {
  color: var(--text);
  font-size: 21px;
  letter-spacing: -.45px;
}

.section-head p {
  color: var(--text-3);
}

.btn {
  min-height: 38px;
  padding: 8px 15px;
  border-radius: 11px;
  font-weight: 700;
  transition: transform .16s var(--ease), background .16s var(--ease),
    border-color .16s var(--ease), box-shadow .16s var(--ease);
}

.btn.primary {
  color: #f7fffc;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--brand) 88%, #000);
  border-color: color-mix(in srgb, var(--brand) 88%, #000);
  box-shadow: 0 12px 24px -16px color-mix(in srgb, var(--brand) 80%, transparent);
}

.btn.accent {
  color: #f7fffc;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.ghost {
  color: var(--text-2);
}

.chip {
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  color: var(--text-2);
  background: var(--surface-2);
}

.chip.brand,
.chip.accent {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 16%, var(--border));
}

.input,
.textarea,
.select {
  border-color: var(--border);
  background: var(--surface-2);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: color-mix(in srgb, var(--brand) 52%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent);
}

.progress-fill,
.community-progress i {
  background: var(--brand);
}

/* ---------- Home ---------- */
.hero {
  padding: 42px 44px;
  border-radius: var(--radius-l);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--brand-soft) 82%, var(--surface)) 0%, var(--surface) 58%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.hero::after {
  right: -90px;
  top: -155px;
  width: 390px;
  height: 390px;
  border: 54px solid color-mix(in srgb, var(--brand) 6%, transparent);
  background: transparent;
}

.hero-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr);
  gap: 42px;
}

.hero h1 {
  max-width: 760px;
  font-size: clamp(30px, 3.1vw, 40px);
  font-weight: 780;
  line-height: 1.24;
  letter-spacing: -1.15px;
}

.hero h1 .grad {
  color: var(--brand);
  background: none;
  -webkit-text-fill-color: currentColor;
}

.hero p.lead {
  max-width: 640px;
  font-size: 15px;
  line-height: 1.8;
}

.hero-actions {
  gap: 9px;
}

.profile-mini {
  border-radius: 20px;
  background: var(--surface);
}

.profile-mini .pm-avatar {
  border-radius: 16px;
  background: var(--brand);
  box-shadow: none;
}

.stat-grid {
  grid-template-columns: 1.25fr repeat(3, minmax(0, .75fr));
  gap: 10px;
}

.stat {
  padding: 17px 18px;
  border-radius: 15px;
  background: var(--surface-2);
  box-shadow: none;
}

.stat:first-child {
  color: #f7fffc;
  background: var(--brand);
  border-color: var(--brand);
}

.stat:first-child .k,
.stat:first-child .v small {
  color: rgba(255, 255, 255, .74);
}

.stat .v.grad {
  color: inherit;
  background: none;
  -webkit-text-fill-color: currentColor;
}

.quick-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 11px;
}

.quick {
  padding: 16px;
  border-radius: 14px;
}

.quick:hover,
.doc-card:hover,
.community-card:hover,
.forum-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.quick .qi {
  border-radius: 12px;
  background: var(--brand-soft);
}

.doc-card {
  padding: 19px;
  border-radius: 15px;
}

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

.home-video-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}

.home-video-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.home-video-cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  color: rgba(255, 255, 255, .86);
  background: #172520;
}

.home-video-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-video-cover > b {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  background: rgba(8, 19, 16, .58);
  backdrop-filter: blur(6px);
}

.home-video-copy {
  display: grid;
  gap: 4px;
  padding: 12px 13px 14px;
}

.home-video-copy strong {
  font-size: 14px;
  line-height: 1.45;
}

.home-video-copy small {
  color: var(--text-3);
  font-size: 11.5px;
}

/* ---------- Community and forum framing ---------- */
.forum-page,
.community-page {
  max-width: 1240px;
}

.forum-hero,
.community-hero {
  align-items: center;
  gap: 28px;
  padding: 32px 34px;
  border-radius: 22px;
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--brand-soft) 78%, var(--surface)), var(--surface) 62%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.forum-hero::after {
  right: -56px;
  bottom: -128px;
  width: 250px;
  height: 250px;
  border: 42px solid color-mix(in srgb, var(--brand) 6%, transparent);
  background: transparent;
}

.forum-kicker {
  display: none;
}

.forum-hero h1,
.community-hero h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 3.2vw, 37px);
  font-weight: 780;
  letter-spacing: -1px;
}

.forum-hero p,
.community-hero p {
  max-width: 720px;
  line-height: 1.75;
}

.forum-stat-grid {
  min-width: 360px;
  gap: 0;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}

.forum-stat {
  padding: 10px 12px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
}

.forum-stat:nth-child(4) {
  border-right: 0;
}

.forum-stat b {
  font-size: 20px;
  letter-spacing: -.5px;
}

.forum-stat span {
  color: var(--text-3);
}

.forum-live {
  margin-top: 6px;
  padding: 6px 10px;
  color: var(--brand);
  background: var(--brand-soft);
}

.community-discovery {
  margin-top: 14px;
  padding: 15px;
  border-radius: 17px;
  box-shadow: none;
}

.community-discovery-head {
  align-items: center;
  margin-bottom: 10px;
}

.community-discovery-head h2 {
  font-size: 16px;
}

.community-discovery-head p {
  margin-left: auto;
}

.community-discovery-grid {
  gap: 7px;
}

.community-discovery-grid a {
  padding: 11px 7px;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: none;
}

.community-discovery-grid a:hover {
  transform: translateY(-1px);
  background: var(--brand-soft);
}

.discover-icon,
.discover-icon.text,
.discover-icon.photo,
.discover-icon.search,
.discover-icon.user {
  color: var(--brand);
  background: var(--brand-soft);
}

.forum-login-note {
  margin-top: 14px;
  padding: 15px 17px;
  border-style: solid;
  border-radius: 15px;
  background: var(--surface-2);
}

.forum-login-note > div:first-child {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}

.forum-board {
  margin-top: 22px;
}

.forum-toolbar {
  position: sticky;
  top: calc(var(--header-h) + 10px);
  z-index: 12;
  margin-bottom: 15px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}

.seg {
  background: var(--surface-3);
}

.seg button.active {
  color: var(--brand);
  background: var(--surface);
}

/* ---------- Content cards ---------- */
.community-feed {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.community-card {
  grid-column: span 6;
  border-radius: 17px;
  background: var(--surface);
}

.community-card.kind-video {
  grid-column: span 7;
}

.community-card.kind-text {
  grid-column: span 5;
}

.community-card-body {
  padding: 17px 18px 15px;
}

.community-card-head {
  margin-bottom: 10px;
}

.community-title {
  min-height: 0;
  font-size: 18px;
  line-height: 1.42;
  letter-spacing: -.4px;
}

.community-excerpt {
  margin: 8px 0 14px;
  font-size: 13.5px;
  line-height: 1.72;
}

.community-actions {
  border-top-style: solid;
  border-top-color: color-mix(in srgb, var(--border) 75%, transparent);
}

.community-video-cover {
  aspect-ratio: 16 / 9;
  background: #14241f;
}

.community-play {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(8, 22, 18, .66);
}

.community-kind {
  border-radius: 8px;
  background: rgba(8, 22, 18, .76);
}

.community-gallery {
  gap: 4px;
  background: var(--surface-3);
}

.forum-avatar,
.avatar {
  background: var(--brand);
}

.forum-card {
  border-radius: 16px;
}

.forum-card-main {
  padding: 19px 20px;
}

.forum-card.pinned::before {
  background: var(--brand);
}

.forum-title {
  font-size: 18px;
  letter-spacing: -.35px;
}

.forum-action {
  min-height: 30px;
}

.forum-action:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.forum-action.liked {
  color: var(--danger);
  background: var(--danger-soft);
}

.forum-pager button.active,
.forum-pager button:hover:not(:disabled) {
  color: #f7fffc;
  border-color: var(--brand);
  background: var(--brand);
}

/* ---------- Feed, reading and profile ---------- */
.feed-head h1 {
  font-size: 27px;
  letter-spacing: -.7px;
}

.feed-scroll {
  border: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
  border-radius: 20px;
}

.feed-action,
.feed-actions .forum-action {
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(8, 20, 16, .62);
}

.side,
.reader-main {
  border-radius: 16px;
}

.reader-body {
  max-width: 920px;
}

.profile-hero {
  border-radius: 20px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--brand-soft) 72%, var(--surface)), var(--surface) 64%),
    var(--surface);
}

.profile-hero .ph-avatar {
  border-radius: 18px;
  background: var(--brand);
}

.role-card {
  box-shadow: none;
}

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

.matrix th,
.matrix td {
  border-color: var(--border);
}

.matrix th {
  color: var(--text-2);
  background: var(--surface-2);
}

/* ---------- Mobile ---------- */
@media (max-width: 980px) {
  .page,
  .page.wide {
    max-width: calc(var(--app-vw) - 28px);
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

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

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

  .community-feed {
    grid-template-columns: 1fr;
  }

  .community-card,
  .community-card.kind-video,
  .community-card.kind-text {
    grid-column: 1 / -1;
  }

  .forum-toolbar {
    position: static;
  }
}

@media (max-width: 820px) {
  :root {
    --header-h: 58px;
  }

  .topbar {
    padding: 0 12px;
    background: color-mix(in srgb, var(--surface) 95%, transparent);
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 11px;
  }

  .brand-text b {
    font-size: 13.8px;
  }

  .page,
  .page.wide {
    max-width: none;
    padding: 15px 12px 104px;
  }

  .hero {
    padding: 24px 18px;
    border-radius: 19px;
  }

  .hero h1 {
    font-size: 26px;
    line-height: 1.3;
    letter-spacing: -.75px;
  }

  .hero::after {
    right: -120px;
    top: -160px;
    width: 290px;
    height: 290px;
  }

  .profile-mini {
    border-radius: 17px;
  }

  .stat-grid {
    gap: 7px;
  }

  .stat {
    padding: 13px;
    border-radius: 14px;
  }

  .stat:first-child {
    grid-column: 1 / -1;
  }

  .quick-grid,
  .doc-grid,
  .home-video-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    margin-top: 28px;
  }

  .forum-hero,
  .community-hero {
    padding: 23px 18px;
    border-radius: 19px;
  }

  .forum-stat-grid {
    min-width: 0;
    width: 100%;
    padding: 5px;
  }

  .forum-stat {
    padding: 9px 4px;
  }

  .community-discovery {
    padding: 12px 10px;
  }

  .community-discovery-head p {
    display: none;
  }

  .community-discovery-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .community-discovery-grid a {
    padding: 8px 2px;
    border-radius: 11px;
  }

  .community-discovery-grid small {
    display: none;
  }

  .community-discovery-grid .discover-icon {
    width: 33px;
    height: 33px;
  }

  .community-card-body,
  .forum-card-main {
    padding: 15px;
  }

  .community-title,
  .forum-title {
    font-size: 17px;
  }

  .mobile-tabs {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top-color: var(--border);
  }

  .mobile-tabs a.active {
    color: var(--brand);
  }
}

@media (max-width: 480px) {
  .brand-text b {
    font-size: 13px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .hero-actions .btn:first-child {
    grid-column: auto;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat:first-child {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
/* Grid and breakpoint corrections */
.community-feed {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
}

.community-card,
.community-card.kind-text,
.community-card.kind-image {
  grid-column: span 1;
}

.community-card.kind-video {
  grid-column: span 2;
}

@media (max-width: 980px) {
  .mobile-only {
    display: grid;
  }
}

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

  .community-card,
  .community-card.kind-video,
  .community-card.kind-text,
  .community-card.kind-image {
    grid-column: 1 / -1;
  }
}
