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

html {
  font-size: 13px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1rem;
  color: #1e293b;
  background: #0f172a;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100dvh;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  max-width: 1920px;
  margin: 0 auto;
  background: #f8fafc;
  overflow: hidden;
}

/* Topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 3.4rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.topbar-brand {
  font-size: 1.1rem;
  white-space: nowrap;
}

.topbar-input {
  flex: 1;
  max-width: 36rem;
}

.topbar-input input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  font-size: 1.1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #f1f5f9;
  color: #1e293b;
  font-family: inherit;
  transition: all 0.2s;
}

.topbar-input input:focus {
  outline: none;
  border-color: #818cf8;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.topbar-input input::placeholder {
  color: #94a3b8;
}

/* Main */

.main-content {
  display: flex;
  overflow: hidden;
}

.panel {
  overflow: auto;
  padding: 1rem 1.2rem;
}

.panel-left {
  flex: 1;
  background: #fff;
  border-right: 1px solid #e2e8f0;
}

.panel-right {
  width: 22rem;
  flex-shrink: 0;
  background: #f8fafc;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  color: #0f172a;
}

/* Welcome */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: #64748b;
  height: 100%;
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.welcome h2 {
  font-size: 1.4rem;
  color: #0f172a;
  margin-bottom: 0.4rem;
}

.welcome > p {
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
}

.welcome-examples {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 28rem;
  text-align: left;
}

.welcome-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
}

.welcome-word {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 2rem;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s;
}

.welcome-word:hover {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

.welcome-chain {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  font-size: 1rem;
}

.welcome-chain p {
  margin-top: 0.3rem;
  color: #475569;
}

.welcome-result {
  font-size: 1.15rem;
  font-weight: 600;
  color: #6366f1 !important;
}

/* Chain display */

.chain-display {
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

.chain-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.chain-label {
  font-size: 1rem;
  font-weight: 600;
  color: #64748b;
}

.undo-btn, .reset-btn {
  font-size: 0.9rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.4rem;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  font-family: inherit;
}

.undo-btn:hover, .reset-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.chain-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.chip {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 2rem;
  font-size: 1rem;
  font-weight: 500;
}

.chip-word {
  background: #6366f1;
  color: #fff;
}

.chip-transform {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.chip-arrow {
  color: #94a3b8;
  font-size: 1rem;
}

/* Result */

.result-area {
  text-align: center;
  padding: 1.5rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.result-main {
  font-size: 2.6rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.2rem;
}

.result-sub {
  font-size: 1.4rem;
  color: #64748b;
  margin-bottom: 0.4rem;
}

.result-kind {
  display: inline-block;
  font-size: 0.9rem;
  color: #6366f1;
  background: rgba(99,102,241,0.08);
  padding: 0.15rem 0.7rem;
  border-radius: 2rem;
  font-weight: 500;
}

/* Steps */

.steps-area {
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #0f172a;
}

.step-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.25rem;
  background: #f8fafc;
  border-radius: 0.4rem;
  font-size: 1rem;
  border: 1px solid #f1f5f9;
}

.step-from,
.step-to {
  font-weight: 500;
}

.step-arrow {
  margin: 0 0.4rem;
  color: #6366f1;
  font-weight: 700;
}

.step-label {
  margin-left: auto;
  color: #64748b;
  font-size: 0.9rem;
}

/* Tips */

.tips-area {
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.8rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 0.5rem;
}

.tips-title {
  font-size: 1rem;
  font-weight: 600;
  color: #b45309;
  margin-bottom: 0.3rem;
}

.tips-area p {
  font-size: 1rem;
  color: #78350f;
  line-height: 1.6;
  margin-bottom: 0.3rem;
}

.tips-area p:last-child {
  margin-bottom: 0;
}

/* Example */

.example-area {
  margin-top: 0.8rem;
  padding: 0.8rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
}

.example-jp {
  font-size: 1.1rem;
  color: #0f172a;
  padding: 0.4rem 0.5rem;
  background: #fff;
  border-radius: 0.3rem;
  margin-bottom: 0.3rem;
  line-height: 1.6;
}

.example-jp.loading {
  color: #94a3b8;
  font-style: italic;
}

.example-jp.error {
  color: #dc2626;
}

.example-zh {
  font-size: 1rem;
  color: #475569;
  padding: 0.3rem 0.5rem;
  background: #fff;
  border-radius: 0.3rem;
  border-left: 3px solid #60a5fa;
  line-height: 1.5;
}

/* Transforms grid */

.transforms-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.transform-group-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0.5rem 0 0.25rem;
  margin-top: 0.3rem;
}

.transform-group-header:first-child {
  margin-top: 0;
}

.transform-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.6rem;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.transform-card:hover {
  border-color: #818cf8;
  background: #eef2ff;
}

.transform-label {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.15rem;
}

.transform-desc {
  font-size: 0.95rem;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.transform-preview {
  font-size: 1.05rem;
  color: #6366f1;
  font-weight: 500;
}

.empty-hint {
  color: #94a3b8;
  font-size: 1rem;
  padding: 2rem 0;
  text-align: center;
}

/* Direction hints */

.dir-hint-mobile {
  display: none;
}

.dir-hint-desktop {
  display: inline;
}

/* Responsive */

@media (max-width: 1024px) {
  body {
    overflow: auto;
    height: auto;
  }

  .app {
    height: auto;
    min-height: 100dvh;
  }

  .main-content {
    flex-direction: column;
    overflow: visible;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }

  .panel-right {
    width: auto;
  }

  .transforms-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .transform-card {
    flex: 1;
    min-width: 10rem;
  }

  .dir-hint-desktop {
    display: none;
  }

  .dir-hint-mobile {
    display: inline;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.6rem 0.8rem;
  }

  .topbar-input input {
    font-size: 1rem;
  }

  .result-main {
    font-size: 2rem;
  }

  .result-sub {
    font-size: 1.1rem;
  }

  .transforms-grid {
    flex-direction: column;
  }

  .transform-card {
    min-width: auto;
  }
}
