:root {
  --bg: #0b1020;
  --panel: #121a32;
  --panel2: #0f1730;
  --text: #e8ecff;
  --muted: #a9b2d3;
  --border: rgba(255, 255, 255, 0.09);
  --accent: #6ea8fe;
  --accent2: #7ee787;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 10% 10%, #16224a 0%, var(--bg) 40%)
    fixed;
  color: var(--text);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 26, 50, 0.85);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: clamp(12px, 2vw, 20px);
  padding: clamp(12px, 2vw, 24px);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
}

.editor {
  border: 1px solid var(--border);
  background: rgba(18, 26, 50, 0.6);
  border-radius: 12px;
  overflow: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-height: 0;
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.editable {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 48, 0.85);
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
}

.editable:focus {
  border-color: rgba(110, 168, 254, 0.6);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.14);
}

.editable:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.suggestion {
  background: rgba(255, 107, 107, 0.15);
  border-bottom: 2px solid var(--danger);
  cursor: pointer;
  transition: background 0.15s;
}

.suggestion:hover,
.suggestion.highlight {
  background: rgba(255, 107, 107, 0.3);
}

.popup {
  position: absolute;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: 320px;
  animation: popupIn 0.15s ease-out;
}

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

.popupMsg {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.popupBody {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popupReplacement {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent2);
  flex: 1;
}

.popupBtn {
  border: none;
  background: var(--accent2);
  color: #0b1020;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: opacity 0.15s;
}

.popupBtn:hover {
  opacity: 0.85;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hintSep {
  opacity: 0.5;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(15, 23, 48, 0.9);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.btn.primary {
  border-color: rgba(110, 168, 254, 0.45);
  background: rgba(110, 168, 254, 0.16);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.sidebar {
  border: 1px solid var(--border);
  background: rgba(18, 26, 50, 0.6);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebarHeader {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 48, 0.65);
}

.sidebarTitle {
  font-weight: 600;
  font-size: 14px;
}

.suggestions {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.card {
  border: 1px solid var(--border);
  background: rgba(15, 23, 48, 0.7);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.card:hover {
  border-color: rgba(110, 168, 254, 0.4);
  background: rgba(15, 23, 48, 0.9);
}

.cardMsg {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.cardOriginal {
  font-size: 13px;
  color: var(--danger);
  text-decoration: line-through;
  opacity: 0.8;
}

.cardArrow {
  color: var(--muted);
  margin: 0 6px;
  font-size: 12px;
}

.cardReplacement {
  font-size: 13px;
  color: var(--accent2);
  font-weight: 600;
}

.cardBody {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.cardAccept {
  margin-top: 8px;
  border: none;
  background: var(--accent2);
  color: #0b1020;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  transition: opacity 0.15s;
}

.cardAccept:hover {
  opacity: 0.85;
}

.noSuggestions {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 20px 10px;
}

/* Settings Button */
.settingsBtn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s, border-color 0.15s;
}

.settingsBtn:hover {
  background: rgba(110, 168, 254, 0.1);
  border-color: rgba(110, 168, 254, 0.4);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modalContent {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  margin: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modalTitle {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modalClose {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.modalClose:hover {
  color: var(--text);
}

.modalBody {
  padding: 18px;
}

.modalFooter {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.formGroup {
  margin-bottom: 16px;
}

.formGroup:last-child {
  margin-bottom: 0;
}

.formLabel {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.formInput {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.formInput:focus {
  border-color: rgba(110, 168, 254, 0.6);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.14);
}

.formInput::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.formHint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 800px) {
  .main {
    grid-template-columns: 1fr;
    max-width: 720px;
  }
  .editable {
    min-height: clamp(260px, 45vh, 520px);
  }
}

@media (min-width: 1800px) {
  .main {
    max-width: 1840px;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  }
}

@media (max-width: 520px) {
  .main {
    padding: 12px;
    gap: 12px;
  }
  .editor {
    padding: 12px;
  }
  .sidebarHeader {
    padding: 10px 12px;
  }
}
