/* =============================================
   Base
============================================= */
:root {
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;

  --bg: #050b18;
  --bg-deep: #071527;
  --surface: rgba(15, 35, 65, 0.55);
  --surface-strong: rgba(18, 43, 78, 0.78);
  --border: rgba(80, 160, 255, 0.25);
  --border-strong: rgba(96, 165, 250, 0.48);

  --text: #eaf2ff;
  --muted: #8fa7c7;
  --faint: rgba(143, 167, 199, 0.68);
  --accent: #38bdf8;
  --accent-2: #60a5fa;
  --accent-3: #6366f1;

  --radius-sm: 6px;
  --radius-md: 8px;
  --nav-h: 64px;
  --max-w: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 50% 22%, rgba(56, 189, 248, 0.18), transparent 30rem),
    radial-gradient(circle at 78% 18%, rgba(99, 102, 241, 0.16), transparent 22rem),
    linear-gradient(180deg, #050b18 0%, #071527 58%, #050b18 100%);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(96, 165, 250, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 165, 250, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to left, rgba(0, 0, 0, 0.52), transparent 72%);
}

body::after {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  z-index: -1;
  height: 32%;
  background: repeating-linear-gradient(
    to bottom,
    rgba(56, 189, 248, 0.03) 0,
    rgba(56, 189, 248, 0.03) 1px,
    transparent 1px,
    transparent 12px
  );
  pointer-events: none;
}

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

img {
  display: block;
  max-width: 100%;
}

.container {
  width: min(100% - 2rem, var(--max-w));
  margin: 0 auto;
}

/* =============================================
   Navigation
============================================= */
#nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 1px solid var(--border);
  background: rgba(5, 11, 24, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.nav-logo {
  font-size: 1rem;
  font-weight: 720;
  color: var(--text);
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.65rem;
  list-style: none;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
  font-size: 13px;
  transition: color 0.16s, text-shadow 0.16s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.42);
}

/* =============================================
   Home
============================================= */
.home-page {
  overflow-x: hidden;
}

.home-hero {
  position: relative;
  min-height: calc(100vh - var(--nav-h) - 64px);
  display: grid;
  place-items: center;
  padding: 5rem 0;
  border-bottom: 1px solid var(--border);
  isolation: isolate;
}

.home-hero::before {
  content: "";
  position: absolute;
  width: min(52vw, 620px);
  aspect-ratio: 1;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(56, 189, 248, 0.18), transparent 62%),
    radial-gradient(circle, rgba(99, 102, 241, 0.12), transparent 72%);
  filter: blur(8px);
  z-index: -1;
}

.hero-grid {
  position: absolute;
  inset: 0 0 0 48%;
  z-index: -1;
  background-image:
    linear-gradient(rgba(96, 165, 250, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 165, 250, 0.11) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to left, rgba(0, 0, 0, 0.72), transparent 86%);
}

.hero-scan {
  position: absolute;
  inset: auto 0 0 0;
  height: 30%;
  z-index: -1;
  background: linear-gradient(to top, rgba(56, 189, 248, 0.08), transparent);
  opacity: 0.72;
}

.home-hero-inner {
  text-align: center;
}

.hero-kicker,
.page-kicker {
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 1rem;
}

.home-hero h1 {
  font-size: clamp(3.4rem, 9vw, 7.4rem);
  line-height: 0.96;
  font-weight: 760;
  letter-spacing: 0;
  text-shadow: 0 0 46px rgba(56, 189, 248, 0.34);
}

.hero-subtitle {
  margin-top: 1.25rem;
  color: var(--accent-2);
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.hero-desc {
  max-width: 660px;
  margin: 1.15rem auto 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 2vw, 1.12rem);
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 2.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 128px;
  min-height: 42px;
  padding: 0.72rem 1.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 650;
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  color: #04111f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.32);
}

.btn-primary:hover {
  box-shadow: 0 0 36px rgba(56, 189, 248, 0.48);
}

.btn-ghost {
  color: var(--text);
  background: rgba(15, 35, 65, 0.36);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  box-shadow: 0 0 28px rgba(96, 165, 250, 0.14);
}

/* =============================================
   Pages
============================================= */
.page-hero {
  padding: 6.5rem 0 3.2rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  max-width: 780px;
  font-size: clamp(2.4rem, 5vw, 4.25rem);
  line-height: 1.08;
  font-weight: 760;
  letter-spacing: 0;
}

.page-intro {
  max-width: 720px;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 16px;
}

.section {
  padding: 3.5rem 0 4.5rem;
}

.direction-grid,
.project-grid,
.tool-grid,
.about-layout,
.page-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.direction-card,
.project-card,
.tool-card,
.info-card,
.page-card,
.side-panel {
  position: relative;
  overflow: hidden;
  min-height: 148px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface), rgba(7, 21, 39, 0.34));
  box-shadow: inset 0 1px 0 rgba(234, 242, 255, 0.04);
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.direction-card,
.project-card,
.tool-card,
.info-card,
.page-card {
  padding: 1.35rem;
}

.direction-card::before,
.project-card::before,
.tool-card::before,
.info-card::before,
.page-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(56, 189, 248, 0.12), transparent 45%);
  opacity: 0;
  transition: opacity 0.16s;
}

.direction-card:hover,
.project-card:hover,
.tool-card:hover,
.info-card:hover,
.page-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.24), 0 0 30px rgba(56, 189, 248, 0.08);
  background: linear-gradient(145deg, var(--surface-strong), rgba(7, 21, 39, 0.42));
}

.direction-card:hover::before,
.project-card:hover::before,
.tool-card:hover::before,
.info-card:hover::before,
.page-card:hover::before {
  opacity: 1;
}

.direction-card > *,
.project-card > *,
.tool-card > *,
.info-card > *,
.page-card > * {
  position: relative;
}

.card-kicker,
.tool-scene {
  display: inline-flex;
  color: var(--accent);
  font-size: 12px;
  margin-bottom: 0.62rem;
}

.direction-card h2,
.project-card h2,
.tool-card h2,
.info-card h2,
.page-card h3 {
  color: var(--text);
  font-size: 1.12rem;
  line-height: 1.38;
  font-weight: 720;
}

.direction-card p,
.project-card p,
.tool-card p,
.info-card p,
.page-card p {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.direction-code,
.project-stack {
  color: var(--faint);
  font-size: 12px;
}

.content-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
}

.side-panel {
  padding: 1.2rem;
}

.side-panel h2 {
  margin-bottom: 0.8rem;
  font-size: 1rem;
}

.compact-list {
  display: grid;
  gap: 0.55rem;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.compact-list li {
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(80, 160, 255, 0.14);
}

.article-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(15, 35, 65, 0.34);
}

.article-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 96px;
  gap: 1rem;
  align-items: center;
  min-height: 58px;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(80, 160, 255, 0.14);
  transition: background 0.16s, color 0.16s;
}

.article-row:last-child {
  border-bottom: 0;
}

.article-row:hover {
  background: rgba(56, 189, 248, 0.08);
}

.article-date,
.article-category {
  color: var(--faint);
  font-size: 12px;
}

.article-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.project-card {
  min-height: 166px;
}

.back-link {
  display: inline-flex;
  margin-top: 2rem;
  color: var(--muted);
  font-size: 13px;
}

.back-link:hover {
  color: var(--accent);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 1rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

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

.auth-panel {
  min-height: 220px;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface), rgba(7, 21, 39, 0.34));
  box-shadow: inset 0 1px 0 rgba(234, 242, 255, 0.04);
}

.auth-panel h2 {
  margin-bottom: 1rem;
  color: var(--text);
  font-size: 1.12rem;
  line-height: 1.38;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-field {
  display: grid;
  gap: 0.4rem;
}

.auth-field span {
  color: var(--muted);
  font-size: 13px;
}

.auth-field input {
  width: 100%;
  min-height: 42px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(5, 11, 24, 0.42);
  padding: 0.65rem 0.72rem;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.auth-field input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.auth-message {
  min-height: 1.4rem;
  margin-top: 1rem;
  color: var(--accent);
  font-size: 13px;
}

.auth-message.is-error {
  color: #fca5a5;
}

.auth-profile {
  display: grid;
  gap: 1rem;
}

.auth-profile-box {
  min-height: 108px;
}

.auth-user-data {
  display: grid;
  gap: 0.7rem;
}

.auth-user-data div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(80, 160, 255, 0.14);
}

.auth-user-data dt {
  color: var(--muted);
  font-size: 13px;
}

.auth-user-data dd {
  color: var(--text);
  font-weight: 650;
  text-align: right;
}

.chat-page-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.chat-sidebar,
.chat-workbench {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface), rgba(7, 21, 39, 0.34));
  box-shadow: inset 0 1px 0 rgba(234, 242, 255, 0.04);
}

.chat-sidebar {
  display: grid;
  align-content: start;
  gap: 1.35rem;
  padding: 1.2rem;
}

.chat-sidebar h2,
.chat-workbench h2 {
  margin-bottom: 0.8rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.38;
}

.model-switcher {
  display: grid;
  gap: 0.55rem;
}

.model-switcher label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 40px;
  padding: 0.58rem 0.7rem;
  border: 1px solid rgba(80, 160, 255, 0.18);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(5, 11, 24, 0.28);
  cursor: pointer;
}

.model-switcher label:has(input:checked) {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(56, 189, 248, 0.1);
}

.model-switcher input {
  accent-color: var(--accent);
}

.chat-account-state {
  display: grid;
  gap: 0.8rem;
}

#chat-account {
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
}

.chat-workbench {
  display: grid;
  grid-template-rows: auto minmax(420px, 58vh) auto;
  overflow: hidden;
}

.chat-workbench-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid rgba(80, 160, 255, 0.2);
}

.chat-workbench-header p {
  color: var(--muted);
  font-size: 13px;
}

.chat-status {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.chat-status.is-error {
  color: #fca5a5;
}

.chat-page-messages {
  display: flex;
  flex-direction: column;
  gap: 0.82rem;
  min-height: 0;
  padding: 1.15rem;
  overflow-y: auto;
}

.chat-page-message {
  max-width: min(76%, 720px);
  padding: 0.78rem 0.9rem;
  border: 1px solid rgba(80, 160, 255, 0.18);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-page-message.is-assistant {
  align-self: flex-start;
  background: rgba(15, 35, 65, 0.58);
}

.chat-page-message.is-user {
  align-self: flex-end;
  color: #04111f;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.chat-page-message.is-error {
  align-self: flex-start;
  color: var(--text);
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.3);
}

.chat-page-message.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 0.15em;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: chat-caret 0.9s steps(2, start) infinite;
}

.chat-page-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.72rem;
  padding: 1rem;
  border-top: 1px solid rgba(80, 160, 255, 0.2);
}

.chat-page-form textarea {
  width: 100%;
  min-height: 54px;
  max-height: 150px;
  resize: vertical;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(5, 11, 24, 0.42);
  padding: 0.75rem 0.82rem;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  outline: none;
}

.chat-page-form textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.chat-page-form textarea:disabled,
.chat-page-form button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

/* =============================================
   Footer
============================================= */
#footer {
  min-height: 64px;
  display: flex;
  align-items: center;
  color: var(--faint);
  border-top: 1px solid rgba(80, 160, 255, 0.14);
  font-size: 12px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#footer a:hover {
  color: var(--accent);
}

/* =============================================
   Responsive
============================================= */
@media (max-width: 760px) {
  :root {
    --nav-h: auto;
  }

  #nav {
    height: auto;
  }

  .nav-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 0.82rem 0;
  }

  .nav-links {
    width: 100%;
    gap: 0.45rem 1rem;
    flex-wrap: wrap;
  }

  .nav-links a {
    min-height: 28px;
    font-size: 12px;
  }

  .home-hero {
    min-height: calc(100vh - 128px);
    padding: 4rem 0;
  }

  .hero-grid {
    inset: 0;
    opacity: 0.45;
  }

  .hero-actions {
    width: 100%;
  }

  .btn {
    flex: 1 1 140px;
  }

  .page-hero {
    padding: 4.25rem 0 2.4rem;
  }

  .direction-grid,
  .project-grid,
  .tool-grid,
  .about-layout,
  .page-list,
  .auth-layout,
  .chat-page-layout,
  .content-layout {
    grid-template-columns: 1fr;
  }

  .chat-workbench {
    grid-template-rows: auto minmax(360px, 58vh) auto;
  }

  .chat-page-message {
    max-width: 90%;
  }

  .chat-page-form {
    grid-template-columns: 1fr;
  }

  .article-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    align-items: start;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 0;
  }
}
