:root {
  color-scheme: dark;
  --bg: #24273a;
  --surface: rgba(30, 32, 48, 0.78);
  --surface-strong: rgba(36, 39, 58, 0.9);
  --text: #cad3f5;
  --muted: #a5adcb;
  --placeholder: rgba(202, 211, 245, 0.28);
  --accent: #c6a0f6;
  --accent-soft: rgba(198, 160, 246, 0.12);
  --line: rgba(202, 211, 245, 0.12);
  --shadow: rgba(17, 17, 27, 0.14);
  --ui-font: "Nunito", sans-serif;
  --typing-size: clamp(1.45rem, 3vw, 2.8rem);
  --typing-line-height: 1.52;
  --visible-rows: 6;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
  overflow: hidden;
}

button,
textarea,
kbd {
  font: inherit;
}

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

.app-shell {
  width: min(1100px, calc(100% - 1.5rem));
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0 0.65rem;
}

.theme-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 48px var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.05rem 0;
  animation: reveal 0.45s ease both;
}

.topbar-label,
.panel-heading,
.typing-hint {
  color: var(--muted);
}

.topbar-label,
.panel-heading {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
}

.brand {
  display: inline-block;
  margin-top: 0.24rem;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  gap: 0.4rem;
}

.ghost-button,
.theme-button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.ghost-button {
  padding: 0.45rem 0.2rem;
  border-radius: 8px;
}

.ghost-button:hover,
.theme-button:hover,
.ghost-button:focus-visible,
.theme-button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  color: var(--accent);
}

.typing-panel {
  position: relative;
  margin-top: 0.3rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  padding: 1.15rem 0 0.9rem;
  animation: reveal 0.58s ease 0.05s both;
}

.typing-stage {
  position: relative;
  padding: 0.95rem 0.9rem 0.8rem;
  border-radius: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.typing-output,
.typing-placeholder {
  position: relative;
  z-index: 1;
}

.typing-output {
  height: calc(var(--visible-rows) * 1em * var(--typing-line-height));
  padding: 0.05rem 0.9rem 0.12rem 0;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  font-size: var(--typing-size);
  line-height: var(--typing-line-height);
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: normal;
  scrollbar-width: none;
}

.typing-placeholder {
  position: absolute;
  inset: 1rem 0.9rem auto 1.45rem;
  margin: 0;
  display: flex;
  align-items: flex-start;
  color: var(--placeholder);
  font-size: var(--typing-size);
  line-height: var(--typing-line-height);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}

.typing-placeholder.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
}

.char {
  display: inline-block;
  vertical-align: bottom;
}

.word {
  display: inline-block;
  white-space: nowrap;
}

.char--typed {
  opacity: 1;
  color: var(--text);
}

.char--space {
  min-width: 0.35em;
}

.char--break {
  color: var(--accent);
  opacity: 0.72;
  margin-right: 0.15em;
}

.char--fresh {
  animation: key-pop 0.16s ease;
}

.cursor {
  display: inline-block;
  width: 0.1em;
  height: 0.92em;
  margin-left: 0.05em;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  vertical-align: -0.03em;
  animation: blink 1s steps(1) infinite;
}

.typing-hint {
  margin: 0.08rem 0 0.32rem;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

kbd {
  padding: 0.14rem 0.38rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.typing-input {
  position: absolute;
  width: 1px;
  height: 1px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

.theme-panel {
  margin-top: 0;
  padding: 0.45rem 0.7rem;
  border-radius: 14px;
  animation: reveal 0.65s ease 0.08s both;
}

.panel-heading {
  display: block;
}

.theme-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.35rem;
  margin-top: 0.22rem;
}

.theme-button {
  padding: 0.42rem 0.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-transform: lowercase;
}

.typing-output::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.scroll-rail {
  position: absolute;
  top: 0.95rem;
  right: 0.3rem;
  bottom: 0.8rem;
  width: 6px;
  border-radius: 999px;
  opacity: 0;
  background: rgba(255, 255, 255, 0.06);
  transition: opacity 0.18s ease;
}

.scroll-rail.is-visible {
  opacity: 1;
}

.scroll-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 18px;
  border-radius: 999px;
  background: var(--accent);
}

.theme-button.is-active {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.045);
  color: var(--accent);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes key-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes blink {
  0%,
  52% {
    opacity: 1;
  }

  52.01%,
  100% {
    opacity: 0.18;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 1rem, 100%);
  }

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

  .topbar-actions {
    width: 100%;
  }

  .ghost-button {
    flex: 1;
  }

  .typing-panel {
    padding: 0;
  }

  .typing-stage {
    padding: 0.8rem 0.55rem 0.65rem;
    border-radius: 0;
  }

  .typing-output {
    --typing-size: clamp(1.3rem, 5.5vw, 2.15rem);
    padding-right: 0.85rem;
  }

  .typing-placeholder {
    --typing-size: clamp(1.3rem, 5.5vw, 2.15rem);
    inset: 0.85rem 0.55rem auto 1rem;
  }

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

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