:root {
  --bg: #f6f1ff;
  --bg-soft: #efe5ff;
  --card: #ffffff;
  --text: #2f2543;
  --muted: #766591;
  --primary: #8b5cf6;
  --primary-soft: #e4d7ff;
  --danger: #cc4466;
  --border: #d7c8f6;
  --portrait-column-width: clamp(360px, 25vw, 520px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #fdfbff 0%, var(--bg) 45%, #efe7ff 100%);
}

.site-body {
  min-height: 100vh;
  position: relative;
  isolation: isolate;
}

.cyber-grid-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.92;
}

.site-layout {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--portrait-column-width);
  padding-inline: 100px;
}

.left-panel,
.right-panel {
  padding: 24px 32px;
}

.panel-card {
  position: relative;
  container-type: inline-size;
  isolation: isolate;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(95, 57, 175, 0.08);
  padding: 24px 28px;
  min-height: calc(100vh - 48px);
}

.site-header {
  margin-bottom: 26px;
}

.site-kicker {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.site-title {
  font-size: 34px;
  margin: 0;
}

.site-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.content-area,
.preview-content-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 24px;
}

.content-area h1,
.content-area h2,
.content-area h3 {
  line-height: 1.25;
}

.content-area h1 {
  font-size: 28px;
  margin: 16px 0 10px;
}

.content-area h2 {
  font-size: 21px;
  margin: 14px 0 8px;
}

.content-area h3 {
  font-size: 17px;
  margin: 10px 0 6px;
}

.body-text {
  margin: 2px 0 6px;
  line-height: 1.9;
  color: #45375f;
  white-space: normal;
}

.full-width-item {
  grid-column: 1 / -1;
}

.column-item {
  min-width: 0;
}

.loading-text {
  color: var(--muted);
  break-inside: avoid;
}

.link-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: block;
  text-decoration: none;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #ffffff 0%, var(--primary-soft) 105%);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
  color: inherit;
  touch-action: manipulation;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.18s ease;
}

.content-area > .link-card,
.preview-content-area > .link-card {
  margin: 0;
}

.link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(115, 75, 190, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

.link-glow {
  --start: 0deg;
  --active: 0;
  --spread: 36deg;
  --glow-border-width: 2px;
  --mouse-x: 50%;
  --mouse-y: 50%;
  border-color: rgba(215, 200, 246, 0.86);
}

.link-glow::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--glow-border-width));
  border-radius: inherit;
  padding: var(--glow-border-width);
  background:
    linear-gradient(#fff, #fff) content-box,
    conic-gradient(
      from calc(var(--start) - var(--spread)) at 50% 50%,
      rgba(255, 255, 255, 0) 0deg,
      rgba(255, 255, 255, 0.98) var(--spread),
      rgba(255, 255, 255, 0) calc(var(--spread) * 2)
    ) border-box;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: var(--active);
  transition: opacity 0.16s ease;
  pointer-events: none;
  z-index: 0;
}

.link-glow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    120px circle at var(--mouse-x) var(--mouse-y),
    rgba(255, 255, 255, 0.52),
    rgba(255, 255, 255, 0.2) 28%,
    rgba(255, 255, 255, 0) 62%
  );
  opacity: calc(var(--active) * 0.75);
  transition: opacity 0.18s ease;
  pointer-events: none;
  z-index: 0;
}

.link-glow > * {
  position: relative;
  z-index: 1;
}

.link-glow:hover {
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 12px 28px rgba(115, 75, 190, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 0 16px rgba(255, 255, 255, 0.35);
}

@container (min-width: 760px) {
  .content-area,
  .preview-content-area {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (min-width: 1120px) {
  .content-area,
  .preview-content-area {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container (min-width: 1480px) {
  .content-area,
  .preview-content-area {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.background-glow {
  --glow-angle: 0deg;
  --glow-active: 0;
  --mouse-x: 50%;
  --mouse-y: 50%;
}

.background-glow::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      280px circle at var(--mouse-x) var(--mouse-y),
      rgba(255, 255, 255, 0.62),
      rgba(255, 255, 255, 0.28) 36%,
      rgba(255, 255, 255, 0) 70%
    ),
    conic-gradient(
      from var(--glow-angle) at var(--mouse-x) var(--mouse-y),
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.26),
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.14)
    );
  opacity: calc(var(--glow-active) * 0.92);
  transition: opacity 0.22s ease;
  pointer-events: none;
  z-index: 0;
}

.content-area .link-title,
.preview-content-area .link-title,
.link-title {
  margin: 0;
  font-size: 18px;
}

.link-desc {
  margin: 8px 0;
  color: #5a4a75;
}

.link-url {
  margin: 0;
  color: var(--primary);
  font-size: 14px;
  word-break: break-all;
}

.portrait-frame {
  --portrait-height: calc(100vh - 48px);
  --portrait-offset: calc(var(--portrait-height) / 15);
  width: 100%;
  height: calc(var(--portrait-height) - var(--portrait-offset));
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin: var(--portrait-offset) 0 0;
  overflow: hidden;
}

.hero-portrait {
  position: absolute;
  top: 0;
  left: 50%;
  width: 257%;
  height: auto;
  display: block;
  transform: translateX(-56.4%);
}

.site-footer {
  position: relative;
  z-index: 1;
  padding: 0 32px 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.footer-line {
  display: flex;
  justify-content: center;
  gap: 4ch;
  flex-wrap: wrap;
}

.admin-body {
  min-height: 100vh;
}

.admin-login-wrap,
.error-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.admin-login-card,
.error-card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(95, 57, 175, 0.12);
}

.admin-title {
  margin: 0 0 10px;
}

.admin-hint {
  margin: 0 0 18px;
  color: var(--muted);
}

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

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cdbbf4;
  background: #fbf9ff;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}

input:focus,
textarea:focus {
  outline: 2px solid #cab2ff;
  border-color: #b797ff;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.05);
}

.form-message {
  min-height: 22px;
  margin: 4px 0 0;
  color: #377462;
}

.form-message.error {
  color: #a53753;
}

.editor-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 16px;
  padding: 16px;
}

.editor-panel,
.preview-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  container-type: inline-size;
  padding: 18px;
}

.editor-header {
  display: grid;
  gap: 12px;
}

.editor-header h1 {
  margin: 0;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-panel {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fefcff;
}

.field-label {
  font-weight: 600;
  color: var(--text);
}

.save-button {
  background: #6e44d3;
}

.ghost-button {
  background: #9a86c6;
}

.block-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 10px;
}

.block-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fefcff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.block-item.dragging {
  opacity: 0.5;
}

.block-item.drag-over {
  border-color: var(--primary);
}

.block-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.mini-tip {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.block-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.column-toggle input {
  width: auto;
}

.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.format-button {
  background: #9a86c6;
  padding: 7px 10px;
  font-size: 13px;
}

.danger-button {
  background: var(--danger);
}

.preview-panel h2 {
  margin-top: 0;
}

.preview-area {
  background: #faf7ff;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 14px;
  min-height: 320px;
}

@media (max-width: 960px) {
  .site-layout {
    grid-template-columns: 1fr 1fr;
    padding-inline: 0;
  }

  .left-panel {
    padding: 16px;
  }

  .right-panel {
    padding: 16px;
  }

  .panel-card {
    min-height: calc(100vh - 32px);
    padding: 20px;
  }

  .portrait-frame {
    --portrait-height: calc(100vh - 32px);
  }

  .site-title {
    font-size: 26px;
  }

  .site-footer {
    padding: 0 16px 20px;
  }

  .footer-line {
    gap: 1ch;
  }

  .editor-layout {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .background-glow::before {
    background: radial-gradient(
      200px circle at var(--mouse-x) var(--mouse-y),
      rgba(255, 255, 255, 0.34),
      rgba(255, 255, 255, 0.14) 42%,
      rgba(255, 255, 255, 0) 74%
    ),
    conic-gradient(
      from var(--glow-angle) at var(--mouse-x) var(--mouse-y),
      rgba(255, 255, 255, 0.07),
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0.07)
    );
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
    background:
      radial-gradient(circle at 75% 6%, rgba(255, 255, 255, 0.95) 0 13%, rgba(255, 255, 255, 0) 32%),
      radial-gradient(circle at 18% 28%, rgba(217, 195, 255, 0.5) 0 18%, rgba(217, 195, 255, 0) 38%),
      linear-gradient(180deg, #fbf8ff 0%, var(--bg) 54%, #efe6ff 100%);
  }

  .cyber-grid-canvas {
    opacity: 0.45;
  }

  .site-layout {
    min-height: auto;
    display: flex;
    flex-direction: column;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px
      max(12px, env(safe-area-inset-left));
  }

  .right-panel {
    order: -1;
    padding: 4px 0 0;
  }

  .left-panel {
    padding: 0;
  }

  .portrait-frame {
    --portrait-mobile-size: clamp(300px, 92vw, 430px);
    width: min(100%, 520px);
    height: clamp(205px, 54vw, 270px);
    align-items: flex-start;
    margin: 0 auto 12px;
    border-radius: 28px;
    background:
      radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.9) 0 22%, rgba(255, 255, 255, 0) 48%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.52), rgba(226, 211, 255, 0.3));
    box-shadow: 0 18px 46px rgba(95, 57, 175, 0.12);
  }

  .portrait-frame::before {
    content: "";
    position: absolute;
    inset: auto 12% 0;
    height: 38%;
    border-radius: 999px 999px 0 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(212, 190, 255, 0.16));
  }

  .hero-portrait {
    top: -10px;
    bottom: auto;
    left: 50%;
    width: var(--portrait-mobile-size);
    max-width: none;
    transform: translateX(-50%);
  }

  .panel-card {
    min-height: auto;
    padding: 20px 18px 22px;
    border: 1px solid rgba(215, 200, 246, 0.72);
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 18px 44px rgba(95, 57, 175, 0.11);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  .site-header {
    margin-bottom: 22px;
    text-align: center;
  }

  .site-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 12px;
    border: 1px solid rgba(139, 92, 246, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.58);
    font-size: 12px;
    letter-spacing: 0.08em;
  }

  .site-title {
    font-size: clamp(24px, 7vw, 30px);
    line-height: 1.16;
    letter-spacing: -0.02em;
  }

  .site-subtitle {
    max-width: 24em;
    margin: 12px auto 0;
    font-size: 16px;
    line-height: 1.65;
  }

  .content-area,
  .preview-content-area {
    gap: 12px;
  }

  .content-area h1 {
    margin: 8px 0 2px;
    font-size: clamp(23px, 6.3vw, 28px);
  }

  .content-area h2 {
    margin: 16px 0 2px;
    font-size: 20px;
  }

  .content-area h3 {
    margin: 10px 0 0;
    font-size: 17px;
  }

  .body-text {
    margin: 0;
    color: #45375f;
    font-size: 16px;
    line-height: 1.78;
  }

  .link-card {
    min-height: 88px;
    padding: 17px;
    border-radius: 20px;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(238, 229, 255, 0.92) 100%),
      var(--card);
    box-shadow: 0 10px 28px rgba(115, 75, 190, 0.1);
  }

  .link-card:hover {
    transform: none;
  }

  .link-title {
    font-size: 18px;
    line-height: 1.35;
  }

  .link-desc {
    margin: 7px 0 9px;
    font-size: 15px;
    line-height: 1.6;
  }

  .link-url {
    font-size: 13px;
    line-height: 1.45;
  }

  .site-footer {
    padding: 4px max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .footer-line {
    display: grid;
    gap: 2px;
  }
}

@media (max-width: 420px) {
  .site-layout {
    padding-inline: 10px;
  }

  .portrait-frame {
    height: 204px;
    border-radius: 24px;
  }

  .hero-portrait {
    top: -6px;
    width: 500px;
  }

  .panel-card {
    padding: 18px 15px 20px;
  }

  .site-subtitle,
  .body-text {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .link-card,
  .link-glow::before,
  .link-glow::after,
  .background-glow::before {
    transition: none;
  }
}
