:root {
  --bg: #0b0f17;
  --panel: #121826;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --accent: #4f8cff;
  --success: #2ea043;
  --error: #da3633;
  --warning: #d29922;
  --border: #30363d;
  --input-bg: #161b22;
  --hover: #1c2128;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

header {
  background: var(--panel);
  border-bottom: 1px solid #1f2937;
}

header h1 {
  margin: 0 0 12px 0;
  font-size: 22px;
}

nav a {
  color: var(--muted);
  margin-right: 12px;
  text-decoration: none;
}

nav a:hover {
  color: var(--accent);
}

main p {
  margin: 0 0 12px 0;
}

/* Секции */
.user-section,
.admin-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.user-section h2,
.admin-section h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  color: var(--text);
}

.admin-section {
  border-left: 3px solid var(--warning);
}

/* Формы */
.form {
  margin-top: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, background-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--hover);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* Кнопки */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  font-family: inherit;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #5a9aff;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #3fb950;
}

/* Блоки результатов */
.result-box {
  margin-top: 16px;
  min-height: 20px;
}

.result-box .success,
.result-box .error,
.result-box .loading {
  padding: 16px;
  border-radius: 6px;
  border-left: 4px solid;
}

.result-box .success {
  background: rgba(46, 160, 67, 0.1);
  border-left-color: var(--success);
  color: var(--text);
}

.result-box .error {
  background: rgba(218, 54, 51, 0.1);
  border-left-color: var(--error);
  color: var(--text);
}

.result-box .loading {
  background: rgba(79, 140, 255, 0.1);
  border-left-color: var(--accent);
  color: var(--muted);
}

.result-box h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--text);
}

.result-box p {
  margin: 0 0 8px 0;
}

.result-box p:last-child {
  margin-bottom: 0;
}

.text-content {
  font-size: 15px;
  line-height: 1.6;
  padding: 12px;
  background: var(--input-bg);
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.text-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

/* ============================================ */
/* Voice Recording Section */
/* ============================================ */

.voice-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  border-left: 3px solid var(--accent);
}

.voice-section h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  color: var(--text);
}

.voice-recorder {
  margin-top: 16px;
}

.recording-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.recording-controls .btn {
  flex: 1;
  min-width: 140px;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #e74a47;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
}

/* Recording Status */
.recording-status {
  min-height: 40px;
  margin-bottom: 16px;
}

.recording-active {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(218, 54, 51, 0.1);
  border-radius: 6px;
  border-left: 4px solid var(--error);
}

.recording-indicator {
  font-size: 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

.recording-timer {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* Transcription Result */
.transcription-text {
  font-size: 16px;
  line-height: 1.7;
  padding: 16px;
  background: var(--input-bg);
  border-radius: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
  margin-top: 12px;
}

/* Diff styles */
.diff-container {
  margin-top: 12px;
  padding: 12px;
  background: var(--input-bg);
  border-radius: 6px;
}

.diff-line {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.diff-label {
  width: 110px;
  color: var(--muted);
  flex-shrink: 0;
}

.diff-content {
  flex: 1;
}

.diff-token {
  display: inline-block;
  padding: 2px 4px;
  margin: 1px 2px;
  border-radius: 4px;
}

.diff-token.equal {
  background: rgba(46, 160, 67, 0.18);
}

.diff-token.added {
  background: rgba(79, 140, 255, 0.18);
}

.diff-token.removed {
  background: rgba(218, 54, 51, 0.18);
  text-decoration: line-through;
}

/* ============================================ */
/* Grammar Check Section */
/* ============================================ */

.grammar-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  border-left: 3px solid var(--accent);
}

.grammar-section h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  color: var(--text);
}

.grammar-stats {
  margin-top: 12px;
  min-height: 20px;
}

.grammar-text-result {
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Error highlighting */
.grammar-error {
  background: rgba(218, 54, 51, 0.15);
  border-bottom: 2px wavy var(--error);
  cursor: pointer;
  padding: 2px 0;
  transition: background-color 0.2s;
  position: relative;
}

.grammar-error:hover {
  background: rgba(218, 54, 51, 0.25);
}

/* Tooltip */
.grammar-tooltip {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: tooltipFadeIn 0.2s ease-out;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-message {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.tooltip-replacements {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tooltip-replacement-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  font-family: inherit;
}

.tooltip-replacement-btn:hover {
  background: #5a9aff;
  transform: translateY(-1px);
}

.tooltip-replacement-btn:active {
  transform: translateY(0);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .container {
    padding: 16px;
  }

  .user-section,
  .admin-section,
  .voice-section {
    padding: 16px;
  }

  .recording-controls {
    flex-direction: column;
  }

  .recording-controls .btn {
    width: 100%;
    min-width: unset;
  }

  .recording-active {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }

  .transcription-text {
    font-size: 15px;
    padding: 12px;
  }

  header h1 {
    font-size: 18px;
  }

  .voice-section h2,
  .user-section h2,
  .admin-section h2,
  .grammar-section h2 {
    font-size: 18px;
  }

  .grammar-section {
    padding: 16px;
  }

  .grammar-tooltip {
    max-width: calc(100vw - 32px);
    left: 16px !important;
    right: 16px !important;
  }
}


