:root {
  --bg: #070d14;
  --panel: rgba(10, 20, 34, 0.8);
  --panel-line: rgba(157, 187, 211, 0.25);
  --text: #e6f0fb;
  --muted: #9cb0c7;
  --accent: #26d0ce;
  --accent-2: #ff8a3d;
  --ok: #3fd18a;
  --err: #ff6b6b;
  --term-bg: rgba(38, 208, 206, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.5;
  position: relative;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(20px);
  opacity: 0.45;
  animation: float 16s ease-in-out infinite alternate;
}

.orb-a {
  width: 42vw;
  height: 42vw;
  left: -10vw;
  top: -16vw;
  background: radial-gradient(circle at 30% 30%, rgba(38, 208, 206, 0.45), rgba(38, 208, 206, 0));
}

.orb-b {
  width: 34vw;
  height: 34vw;
  right: -8vw;
  top: 14vh;
  background: radial-gradient(circle at 40% 40%, rgba(255, 138, 61, 0.4), rgba(255, 138, 61, 0));
  animation-duration: 21s;
}

.orb-c {
  width: 48vw;
  height: 48vw;
  left: 26vw;
  bottom: -28vw;
  background: radial-gradient(circle at 50% 50%, rgba(52, 108, 255, 0.28), rgba(52, 108, 255, 0));
  animation-duration: 24s;
}

@keyframes float {
  from {
    transform: translate3d(-2vw, 0, 0);
  }
  to {
    transform: translate3d(2vw, 2vh, 0);
  }
}

.page {
  position: relative;
  z-index: 1;
  width: min(1340px, 100% - 26px);
  margin: 0 auto;
  padding: 24px 0 56px;
}

.hero {
  position: relative;
  border: 1px solid var(--panel-line);
  background: linear-gradient(130deg, rgba(19, 34, 53, 0.86), rgba(16, 25, 38, 0.9));
  border-radius: 24px;
  padding: 28px;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, rgba(38, 208, 206, 0.16), transparent 35%, rgba(255, 138, 61, 0.12));
}

.kicker {
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
  margin: 0;
}

.hero h1 {
  margin: 8px 0 10px;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.08;
  font-weight: 900;
}

.lead {
  margin: 0;
  color: var(--muted);
  max-width: 980px;
}

.lead strong {
  color: #f2f7ff;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(38, 208, 206, 0.45);
  border-radius: 999px;
  padding: 8px 14px;
  transition: 0.2s ease;
}

.home-link:hover {
  transform: translateY(-1px);
  border-color: rgba(38, 208, 206, 0.82);
}

.layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.panel {
  border: 1px solid var(--panel-line);
  background: var(--panel);
  border-radius: 20px;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.panel > p {
  margin: 8px 0 0;
  color: var(--muted);
}

.mode-tabs {
  display: inline-flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 6px;
}

.tab {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  color: #081322;
  background: linear-gradient(90deg, var(--accent), #6ae9e7);
}

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

.controls-grid {
  margin-top: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(7, 14, 24, 0.86);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(38, 208, 206, 0.72);
  box-shadow: 0 0 0 3px rgba(38, 208, 206, 0.18);
}

.key-signature-preview,
.auto-rule-preview {
  margin-top: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.key-signature-preview {
  background: rgba(38, 208, 206, 0.09);
  border: 1px solid rgba(38, 208, 206, 0.35);
}

.auto-rule-preview {
  background: rgba(255, 138, 61, 0.08);
  border: 1px solid rgba(255, 138, 61, 0.35);
}

.input-area {
  margin-top: 14px;
}

.hint-box {
  margin-top: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 12px;
  color: var(--muted);
}

.hint-box strong {
  color: var(--text);
}

.hint-box p {
  margin: 6px 0;
}

code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 1px 6px;
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 0.9em;
}

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

button {
  font: inherit;
}

.primary,
.ghost,
.preset-btn {
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.primary {
  background: linear-gradient(90deg, var(--accent), #68e4e2);
  color: #05111d;
  font-weight: 800;
}

.primary:hover {
  transform: translateY(-1px);
}

.ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.ghost:hover {
  border-color: rgba(255, 255, 255, 0.34);
}

.status-line {
  margin-top: 10px;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  background: rgba(63, 209, 138, 0.1);
  border: 1px solid rgba(63, 209, 138, 0.35);
}

.status-line[data-state='error'] {
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.38);
}

.preset-box {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.preset-btn:hover {
  border-color: rgba(38, 208, 206, 0.8);
  background: rgba(38, 208, 206, 0.14);
}

.score-canvas {
  margin-top: 10px;
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(250, 253, 255, 0.98);
  padding: 10px;
}

.score-canvas svg {
  display: block;
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-end;
}

.result-head p {
  margin: 0;
  color: var(--muted);
}

.legend-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-pill {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  padding: 5px 10px;
  font-size: 12px;
  color: #d7e4f6;
}

.table-wrap {
  overflow: auto;
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 980px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 9px 10px;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: rgba(255, 255, 255, 0.06);
  color: #dce8f7;
  position: sticky;
  top: 0;
}

.details-box {
  margin-top: 10px;
  display: grid;
  gap: 12px;
}

.detail-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px;
  background: rgba(8, 16, 27, 0.82);
}

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

.detail-head h4 {
  margin: 0;
  font-size: 17px;
}

.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.confidence {
  border-radius: 999px;
  border: 1px solid rgba(38, 208, 206, 0.55);
  color: var(--accent);
  padding: 4px 10px;
  white-space: nowrap;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
}

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

.reason-steps li {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
}

.reason-steps strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: #d9ebff;
}

.reason-steps p {
  margin: 4px 0 0;
  color: #c3d6eb;
  font-size: 14px;
}

.inline-terms {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.term-label {
  font-size: 12px;
  color: #9fb3cd;
}

.term-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.term {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(38, 208, 206, 0.35);
  border-radius: 999px;
  background: var(--term-bg);
  color: #d7f6f4;
  padding: 2px 8px;
  font-size: 12px;
  cursor: help;
  position: relative;
}

.term.mono-term {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
}

.term.interval-term {
  border-color: rgba(255, 138, 61, 0.45);
  background: rgba(255, 138, 61, 0.12);
  color: #ffe9db;
}

.term::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  max-width: 420px;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(5, 11, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #eaf2ff;
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: 0.16s ease;
  z-index: 20;
}

.term:hover::after,
.term:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.transitions-box {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.transition-item {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.transition-item h4 {
  margin: 0;
  font-size: 15px;
}

.transition-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.vector-box {
  margin-top: 8px;
  display: grid;
  gap: 7px;
}

.vector-row {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.note-chip {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 12px;
}

.arrow-chip {
  border-radius: 999px;
  border: 1px solid rgba(38, 208, 206, 0.45);
  background: rgba(38, 208, 206, 0.13);
  color: #d8f8f6;
  padding: 2px 8px;
  font-size: 12px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: help;
  position: relative;
}

.arrow-chip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  max-width: 320px;
  border-radius: 10px;
  padding: 7px 8px;
  background: rgba(5, 11, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #eaf2ff;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: 0.16s ease;
  z-index: 22;
}

.arrow-chip:hover::after,
.arrow-chip:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.vector-detail {
  color: #c2d4e8;
  font-size: 13px;
}

.vector-suspension_resolve {
  border-color: rgba(255, 138, 61, 0.46);
  background: rgba(255, 138, 61, 0.12);
}

.vector-tie {
  border-color: rgba(111, 234, 177, 0.4);
  background: rgba(111, 234, 177, 0.1);
}

.placeholder,
.muted {
  color: var(--muted);
}

@media (max-width: 1080px) {
  .controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vector-row {
    grid-template-columns: auto auto auto;
  }

  .vector-detail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .page {
    width: min(1340px, 100% - 14px);
    padding-top: 14px;
  }

  .hero,
  .panel {
    border-radius: 16px;
    padding: 12px;
  }

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

  .result-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .term::after,
  .arrow-chip::after {
    left: -8px;
    right: auto;
  }
}
