:root {
  --bg: #17172a;
  --panel: #24233d;
  --panel-2: #292846;
  --panel-3: #1f1e35;
  --border: #3c3b5c;
  --border-strong: #57547f;
  --text: #ffffff;
  --muted: #9d9bc7;
  --accent: #ff6638;
  --red: #af2a02;
  --accent-2: #ff7a45;
  --danger: #ff5167;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
  --radius: 14px;
  --header-h: 78px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Roboto', sans-serif;
  color: var(--text);
  background: var(--bg);
}

button {
  cursor: pointer;
}

.app-header {
  height: var(--header-h);
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: #1b1a2f;
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1460px;
  margin: 0 auto;
}

.app-title {
  margin: 0;
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 600;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-tab {
  min-width: 124px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 18px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
  transition: 0.18s ease;
}

.mode-tab:hover {
  border-color: var(--accent-2);
  color: var(--text);
}

.mode-tab.active {
  color: var(--text);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(255, 102, 56, 0.23);
}

.mode-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1fr);
  gap: 20px;
  padding: 20px 22px 28px;
  max-width: 1500px;
  margin: 0 auto;
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-body {
  padding: 22px;
}

.panel-title {
  margin: 0 0 16px;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.category-track-wrap {
  position: relative;
}

.category-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 160px;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 0 18px 2px;
  scrollbar-color: var(--accent) #34324f;
  scrollbar-width: thin;
}

.category-track::-webkit-scrollbar {
  height: 9px;
}

.category-track::-webkit-scrollbar-track {
  background: #34324f;
  border-radius: 999px;
}

.category-track::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}

.category-card {
  min-height: 82px;
  padding: 16px;
  display: flex;
  align-items: center;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  scroll-snap-align: start;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.category-card:hover,
.category-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  outline: none;
}

.category-card.selected {
  border-color: var(--accent);
  background: #2e2947;
  box-shadow: 0 0 0 2px rgba(255, 102, 56, 0.12);
}

.category-name {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  font-weight: bold;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.speech-panel {
  display: none;
}

.speech-panel.visible {
  display: block;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.speech-textarea,
.result-textarea,
.language-select {
  width: 100%;
  color: var(--text);
  background: #2d2b4a;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.speech-textarea,
.result-textarea {
  resize: vertical;
  line-height: 1.55;
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
}

.speech-textarea {
  min-height: 120px;
  padding: 14px 15px;
}

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

.language-select {
  height: 42px;
  padding: 0 14px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 18px, calc(100% - 17px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.speech-textarea:focus,
.result-textarea:focus,
.language-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 102, 56, 0.13);
}

.result-panel {
  min-height: calc(100vh - var(--header-h) - 48px);
  display: flex;
  flex-direction: column;
}

.result-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.result-title {
  margin: 0;
  font-size: 15px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.recreate-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: rgba(255, 102, 56, 0.08);
  font-size: 12px;
  font-weight: bold;
  user-select: none;
  cursor: pointer;
}

.recreate-label input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.action-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  font-weight: bold;
  transition: 0.18s ease;
}

.action-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.action-btn.success {
  color: var(--text);
  border-color: #39ca86;
}

.action-btn svg {
  width: 14px;
  height: 14px;
}

.result-body {
  flex: 1;
  padding: 22px;
  background: var(--panel);
}

.result-textarea {
  min-height: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #e7e5ff;
}

.result-textarea:focus {
  border: 0;
  box-shadow: none;
}

.result-textarea[readonly] {
  cursor: default;
}

.empty-state {
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .app-header {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .mode-tabs {
    width: 100%;
    justify-content: flex-start;
  }

  .mode-tab {
    flex: 1 1 140px;
  }

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

  .result-panel {
    min-height: 460px;
  }
}

@media (max-width: 560px) {

  .layout,
  .app-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel-body,
  .result-body,
  .result-header {
    padding: 16px;
  }

  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  .action-btn,
  .recreate-label {
    flex: 1 1 auto;
  }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 420px);
}

.login-card {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-input {
  width: 100%;
  height: 44px;
  margin: 0 0 16px;
  padding: 0 14px;
  color: var(--text);
  background: #2d2b4a;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 102, 56, 0.13);
}

.login-button,
.logout-btn {
  border: 0;
  color: var(--text);
  background: var(--accent);
  transition: 0.18s ease;
  font-weight: bold;
  font-size: 14px;
}

.login-button {
  width: 100%;
  min-height: 44px;
  border-radius: 9px;
}

.login-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.logout-btn {
  margin-left: auto;
  padding: 11px 18px;
  border-radius: 8px;
  background: var(--red);
}

.login-message {
  min-height: 20px;
  margin-top: 14px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}