:root {
  --tk-bg: #010204;
  --tk-panel: rgba(10, 12, 14, 0.82);
  --tk-line: rgba(255, 255, 255, 0.12);
  --tk-ice: #fff4e3;
  --tk-muted: #b9aa91;
  --tk-gold: #d7a945;
  --tk-copper: #ff6b35;
  --tk-cyan: #39f5d4;
  --tk-green: #39d98a;
  --tk-purple: #c47beb;
}

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

html,
body {
  overflow-x: hidden;
}

body.eb-tempokey-page {
  font-family: "DM Sans", Inter, system-ui, sans-serif;
  color: var(--tk-ice);
  background:
    radial-gradient(ellipse 70% 42% at 18% -8%, rgba(57, 245, 212, 0.11), transparent 62%),
    radial-gradient(ellipse 62% 38% at 88% 4%, rgba(255, 107, 53, 0.10), transparent 64%),
    radial-gradient(ellipse 52% 36% at 52% 20%, rgba(215, 169, 69, 0.08), transparent 70%),
    linear-gradient(180deg, #010204 0%, #06080c 48%, #010204 100%) !important;
}

body.eb-tempokey-page .app-shell {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 42px) 58px;
}

body.eb-tempokey-page .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  margin: 0 calc(clamp(16px, 3vw, 42px) * -1);
  padding: 0 clamp(18px, 4vw, 54px);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.site-brand img {
  width: auto;
  height: 32px;
  display: block;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.12));
}

.nav-center {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(57, 245, 212, 0.28);
  border-radius: 999px;
  color: var(--tk-cyan);
  background: rgba(57, 245, 212, 0.08);
  font-family: "DM Mono", monospace;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-title {
  color: var(--tk-ice);
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(0.92rem, 2vw, 1.08rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nav-title span {
  color: var(--tk-cyan);
}

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(57, 245, 212, 0.28);
  border-radius: 999px;
  color: var(--tk-cyan);
  background: linear-gradient(135deg, rgba(57, 245, 212, 0.10), rgba(255, 107, 53, 0.06));
  font-family: "DM Mono", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--tk-cyan);
  box-shadow: 0 0 18px rgba(57, 245, 212, 0.64);
}

.service-state.is-ok .state-dot {
  background: var(--tk-green);
}

.service-state.is-error {
  border-color: rgba(255, 107, 53, 0.48);
  color: var(--tk-copper);
}

.service-state.is-error .state-dot {
  background: var(--tk-copper);
  box-shadow: 0 0 18px rgba(255, 107, 53, 0.58);
}

.how-link,
.hero-link {
  flex: 0 0 auto;
  color: var(--tk-copper);
  border: 1px solid rgba(255, 107, 53, 0.34);
  border-radius: 4px;
  background: rgba(255, 107, 53, 0.08);
  font-family: "DM Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.58fr);
  gap: clamp(22px, 4vw, 54px);
  align-items: end;
  padding: clamp(42px, 7vw, 86px) 0 28px;
}

.eyebrow,
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--tk-cyan);
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.tool-hero h1 {
  margin: 0;
  color: #fff4e3;
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(4.3rem, 10vw, 10rem);
  line-height: 0.92;
  font-weight: 600;
  letter-spacing: 0.035em;
  text-transform: none;
  text-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

.tool-hero h1 span {
  color: var(--tk-cyan);
  text-shadow: 0 0 32px rgba(57, 245, 212, 0.2);
}

.tool-hero p {
  margin: 0;
  color: rgba(247, 239, 225, 0.72);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.65;
}

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

.tool-back,
.hero-cta,
.hero-secondary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 999px;
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.tool-back,
.hero-secondary {
  color: rgba(247, 239, 225, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(1, 2, 4, 0.36);
}

.hero-cta {
  color: #03100d;
  border: 1px solid rgba(57, 245, 212, 0.68);
  background: linear-gradient(135deg, #39f5d4, #d7a945);
  box-shadow: 0 0 40px rgba(57, 245, 212, 0.12), inset 0 1px rgba(255, 255, 255, 0.22);
}

.signal-hero-card,
.workspace,
.result-card,
.panel,
.drop-zone {
  border: 1px solid var(--tk-line);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.024) 44%, rgba(255, 255, 255, 0.052)),
    radial-gradient(circle at 12% 0%, rgba(215, 169, 69, 0.10), transparent 38%),
    var(--tk-panel);
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.36), inset 0 1px rgba(255, 255, 255, 0.07);
}

.signal-hero-card {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 0.58fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
  padding: clamp(20px, 3vw, 30px);
}

.signal-copy h2 {
  margin: 0 0 10px;
  color: #fff4e3;
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.9rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.025em;
}

.signal-copy p {
  margin: 0;
  color: rgba(247, 239, 225, 0.70);
  line-height: 1.65;
}

.meter-console {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  align-items: end;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(1, 2, 4, 0.48);
  background-size: 100% 25%, 12.5% 100%, auto;
}

.meter-console span {
  height: var(--h);
  min-height: 20px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--tk-cyan), rgba(57, 245, 212, 0.16));
  box-shadow: 0 0 28px rgba(57, 245, 212, 0.18);
  animation: meterFloat 2.6s ease-in-out infinite alternate;
}

.meter-console span:nth-child(5) {
  background: linear-gradient(180deg, var(--tk-gold), rgba(215, 169, 69, 0.18));
}

.meter-console span:nth-child(9) {
  background: linear-gradient(180deg, var(--tk-copper), rgba(255, 107, 53, 0.16));
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 22px;
}

.input-panel,
.result-panel {
  min-width: 0;
}

.panel-heading h2,
.status-row h2,
.prompt-card h3 {
  margin: 0;
  color: #fff4e3;
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(1.65rem, 2.8vw, 3rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.025em;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 245px;
  margin-top: 18px;
  padding: 26px;
  text-align: center;
  cursor: pointer;
  border-style: dashed;
  border-color: rgba(57, 245, 212, 0.44);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  color: #fff4e3;
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(1.9rem, 3.5vw, 2.9rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.025em;
  text-transform: none;
}

.drop-zone small,
.file-card small,
.metric-card small,
.waveform-head p,
.history-list p {
  color: rgba(247, 239, 225, 0.62);
  line-height: 1.5;
}

.drop-code {
  padding: 6px 9px;
  border: 1px solid rgba(57, 245, 212, 0.22);
  border-radius: 4px;
  color: var(--tk-cyan);
  background: rgba(57, 245, 212, 0.08);
  font-family: "DM Mono", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
}

.drop-zone.is-dragging {
  border-color: var(--tk-cyan);
  box-shadow: 0 0 54px rgba(57, 245, 212, 0.16), inset 0 1px rgba(255, 255, 255, 0.08);
}

.file-card,
.manual-card,
.history-card,
.result-card {
  margin-top: 16px;
  padding: 16px;
}

.file-card span {
  display: block;
  color: var(--tk-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.file-card strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.manual-card {
  display: grid;
  gap: 12px;
}

.manual-card label {
  display: grid;
  gap: 7px;
}

.manual-card label span {
  color: rgba(247, 239, 225, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.manual-card input,
.manual-card select,
.prompt-card textarea {
  width: 100%;
  color: var(--tk-ice);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(1, 2, 4, 0.52);
}

.manual-card input,
.manual-card select {
  min-height: 42px;
  padding: 0 12px;
}

.primary-button,
.ghost-button,
.music-maker-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 0.25s cubic-bezier(.16, 1, .3, 1), border-color 0.25s cubic-bezier(.16, 1, .3, 1), color 0.25s cubic-bezier(.16, 1, .3, 1), background 0.25s cubic-bezier(.16, 1, .3, 1);
}

.primary-button {
  color: #03100d;
  border: 1px solid rgba(57, 245, 212, 0.74);
  background: linear-gradient(135deg, #39f5d4, #d7a945);
}

.ghost-button,
.music-maker-link {
  color: rgba(247, 239, 225, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(1, 2, 4, 0.36);
}

.primary-button:hover,
.ghost-button:hover,
.music-maker-link:hover,
.tool-back:hover,
.hero-secondary:hover,
.how-link:hover {
  transform: translateY(-2px);
}

.ghost-button:hover,
.music-maker-link:hover,
.tool-back:hover,
.hero-secondary:hover {
  color: var(--tk-cyan);
  border-color: rgba(57, 245, 212, 0.42);
}

.status-row,
.prompt-head,
.waveform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid rgba(57, 245, 212, 0.34);
  border-radius: 999px;
  color: var(--tk-cyan);
  font-family: "DM Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.metric-card {
  min-height: 150px;
}

.metric-card-large {
  grid-column: span 2;
}

.metric-card span {
  color: var(--tk-muted);
  font-family: "DM Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 8px 0;
  color: #fff4e3;
  font-family: Inter, "DM Sans", system-ui, sans-serif;
  font-size: clamp(2.35rem, 4.9vw, 4.85rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

#keyValue,
#loudnessValue {
  font-size: clamp(2.1rem, 4.2vw, 4rem);
  line-height: 1.05;
}

#loudnessValue {
  font-size: clamp(1.85rem, 3vw, 3.05rem);
  white-space: nowrap;
}

meter {
  width: 100%;
  height: 10px;
  accent-color: var(--tk-cyan);
}

#waveformCanvas {
  width: 100%;
  height: clamp(210px, 28vw, 320px);
  display: block;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    rgba(1, 2, 4, 0.68);
  background-size: 100% 25%, 8.333% 100%, auto;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip-row span,
.history-item {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(247, 239, 225, 0.78);
  background: rgba(1, 2, 4, 0.42);
  font-family: "DM Mono", monospace;
  font-size: 0.66rem;
}

.prompt-card textarea {
  min-height: 142px;
  margin-top: 14px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}

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

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.history-item {
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  border-radius: 8px;
}

.history-item b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--tk-copper);
  outline-offset: 3px;
}

@keyframes meterFloat {
  from {
    transform: scaleY(0.72);
    opacity: 0.66;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .tool-hero,
  .signal-hero-card,
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  body.eb-tempokey-page .topbar,
  .status-row,
  .prompt-head,
  .waveform-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-center,
  .service-state,
  .how-link {
    width: 100%;
  }

  .how-link,
  .service-state {
    justify-content: center;
  }

  .result-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .metric-card-large {
    grid-column: span 1;
  }

  .workspace {
    padding: 14px;
  }

  .meter-console {
    height: 190px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
