:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f3;
  --ink: #17201f;
  --muted: #657270;
  --line: #dce4e2;
  --green: #1c7c54;
  --green-dark: #105b3b;
  --blue: #1769aa;
  --amber: #c9791c;
  --red: #bf3f42;
  --shadow: 0 18px 45px rgba(21, 45, 42, 0.08);
  --radius: 8px;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(28, 124, 84, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(201, 121, 28, 0.08), transparent 28%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(220, 228, 226, 0.86);
  background: rgba(245, 247, 248, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--green);
  color: white;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linejoin: round;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 4px;
}

.topnav a {
  min-width: 56px;
  padding: 9px 12px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
}

.topnav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.lang-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.lang-switch a {
  min-width: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.lang-switch a.active,
.lang-switch a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 260px;
  gap: 20px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px);
}

.sidebar,
.right-rail {
  position: sticky;
  top: 86px;
  align-self: start;
}

.sidebar {
  display: grid;
  gap: 10px;
}

.tool-tab {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.tool-tab:hover,
.tool-tab.active {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 32, 31, 0.05);
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--green-dark);
  background: #dcefe6;
  font-weight: 800;
  font-size: 13px;
}

.market-card,
.note-card,
.ad-slot {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.market-card {
  margin-top: 10px;
  padding: 16px;
}

.market-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.mini-map {
  position: relative;
  height: 116px;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(23, 105, 170, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(23, 105, 170, 0.08) 1px, transparent 1px),
    #f2f7f6;
  background-size: 18px 18px;
}

.node,
.line {
  position: absolute;
  display: block;
}

.node {
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 5px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(23, 32, 31, 0.16);
}

.node-one {
  top: 20px;
  left: 24px;
  background: var(--green);
}

.node-two {
  top: 58px;
  left: 90px;
  background: var(--amber);
}

.node-three {
  top: 30px;
  right: 28px;
  background: var(--blue);
}

.line {
  height: 3px;
  background: #9fb7b3;
  transform-origin: left center;
}

.line-one {
  top: 42px;
  left: 44px;
  width: 70px;
  transform: rotate(29deg);
}

.line-two {
  top: 63px;
  left: 108px;
  width: 78px;
  transform: rotate(-22deg);
}

.tool-shell {
  min-width: 0;
}

.tool-panel {
  display: none;
  min-height: calc(100vh - 150px);
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.tool-panel.active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
}

h2 {
  font-size: 16px;
}

.ghost-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

.ghost-button:hover {
  border-color: #b7c6c2;
  background: var(--surface-2);
}

.grid {
  display: grid;
  gap: 22px;
}

.two-col {
  grid-template-columns: minmax(280px, 0.92fr) minmax(300px, 1.08fr);
}

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

.input-grid.tall {
  align-content: start;
}

label {
  display: grid;
  gap: 7px;
}

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

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  color: var(--ink);
  outline: 0;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 138px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(28, 124, 84, 0.14);
}

.result-stack {
  display: grid;
  align-content: start;
  gap: 14px;
}

.score-card,
.bar-card,
.output-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.score-card {
  display: grid;
  gap: 7px;
  min-height: 108px;
  padding: 16px;
}

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

.score-card strong {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}

.score-card small {
  color: rgba(255, 255, 255, 0.82);
}

.score-card.primary {
  min-height: 148px;
  color: white;
  background: linear-gradient(135deg, var(--green), #27936a);
  border: 0;
}

.score-card.primary.ocean {
  background: linear-gradient(135deg, var(--blue), #2b8799);
}

.score-card.primary span {
  color: rgba(255, 255, 255, 0.84);
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.bar-card {
  padding: 16px;
}

.bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bar-label span {
  color: var(--muted);
}

.stacked-bar {
  display: flex;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ecea;
}

.stacked-bar span {
  min-width: 2px;
}

.bar-cost {
  background: var(--amber);
}

.bar-fee {
  background: var(--blue);
}

.bar-ad {
  background: var(--red);
}

.bar-profit {
  background: var(--green);
}

.insight {
  margin: 0;
  padding: 14px 16px;
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  color: var(--muted);
  background: #f1f7f4;
  line-height: 1.65;
}

.output-card {
  min-height: 520px;
  overflow: hidden;
}

.output-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #f7faf9;
  font-size: 13px;
}

pre {
  min-height: 450px;
  max-height: 62vh;
  margin: 0;
  overflow: auto;
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1f2d2b;
  line-height: 1.62;
}

.right-rail {
  display: grid;
  gap: 14px;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background:
    repeating-linear-gradient(45deg, #f8fbfa 0 12px, #edf3f1 12px 24px);
}

.ad-slot span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 28px;
  margin-bottom: 8px;
  border: 1px solid #bdc9c6;
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ad-slot p,
.note-card p,
.note-card ol {
  margin: 0;
}

.note-card {
  padding: 16px;
}

.note-card h2 {
  margin-bottom: 12px;
}

.note-card ol {
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.note-card p {
  color: var(--muted);
  line-height: 1.65;
}

.note-card.accent {
  border-color: #e8d0ae;
  background: #fffaf2;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 32px) 30px;
  color: var(--muted);
  font-size: 13px;
}

footer a {
  color: var(--green-dark);
  text-decoration: none;
}

.legal-page {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 54px) clamp(16px, 4vw, 32px);
}

.legal-card {
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.legal-card h1 {
  margin-bottom: 22px;
}

.legal-card h2 {
  margin: 28px 0 10px;
}

.legal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.article-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.article-list a {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  background: #fbfcfc;
  text-decoration: none;
}

.article-list a:hover {
  border-color: #b7c6c2;
  background: var(--surface-2);
}

.article-list strong {
  font-size: 17px;
}

.article-list span {
  color: var(--muted);
  line-height: 1.6;
}

.tool-article a {
  color: var(--green-dark);
  font-weight: 700;
  text-decoration: none;
}

.tool-article a:hover {
  text-decoration: underline;
}

.seo-tool-page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px) 34px;
}

.seo-tool-page .tool-panel {
  display: block;
  min-height: auto;
}

.tool-article {
  margin-top: 22px;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-article h2 {
  margin: 26px 0 10px;
  font-size: 22px;
}

.tool-article h2:first-child {
  margin-top: 0;
}

.tool-article h3 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.tool-article p,
.tool-article li {
  color: var(--muted);
  line-height: 1.8;
}

.tool-article p {
  margin: 0 0 12px;
}

.tool-article ul,
.tool-article ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.page-links a {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--green-dark);
  background: var(--surface);
  text-decoration: none;
}

.page-links a:hover {
  background: var(--surface-2);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .right-rail {
    position: static;
    grid-column: 1 / -1;
    grid-template-columns: minmax(180px, 0.8fr) 1fr 1fr;
  }

  .ad-slot {
    min-height: 160px;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav {
    overflow-x: auto;
  }

  .workspace {
    display: block;
    padding-top: 14px;
  }

  .sidebar {
    position: static;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
  }

  .tool-tab {
    flex: 0 0 170px;
  }

  .market-card {
    display: none;
  }

  .two-col,
  .input-grid,
  .right-rail {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    min-height: auto;
  }

  .right-rail {
    margin-top: 16px;
  }
}

@media (max-width: 560px) {
  .panel-heading,
  .metric-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  .ghost-button {
    width: 100%;
  }

  .tool-tab {
    flex-basis: 154px;
  }
}
