:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.14);
  --border: #e2e5ea;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 22px 28px 14px;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 640px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
  background: #eef0f3;
}

.btn-primary {
  background: #b45309;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #92400e;
}

.editor {
  position: relative;
  flex: 1;
  overflow: auto;
  margin: 18px 28px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  min-height: 320px;
}

.mirror {
  width: 100%;
  padding: 20px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--ink);
}

.input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: #0f172a;
}

.input::selection {
  background: rgba(37, 99, 235, 0.28);
}

.input::placeholder {
  color: transparent;
}

.mirror mark {
  background: var(--accent-soft);
  text-decoration: underline wavy var(--accent);
  text-underline-offset: 3px;
  border-radius: 3px;
}

.boxes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.suggest-box {
  position: absolute;
  pointer-events: auto;
  background: #fffdf7;
  border: 1px solid #e7dcc4;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  font-size: 13px;
  overflow: hidden;
  z-index: 6;
  display: none;
}

.suggest-box.visible {
  display: block;
}

.suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: #fdf0d5;
  border-bottom: 1px solid #efe0bd;
  font-size: 12px;
}

.suggest-phrase {
  font-style: italic;
  color: #7c5a12;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-dismiss {
  border: none;
  background: transparent;
  color: #a16207;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 4px;
}

.suggest-dismiss:hover {
  color: #713f12;
}

.suggest-list {
  max-height: 96px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.suggest-opt {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.suggest-opt:hover {
  background: #fdeed3;
}

.suggest-opt-remove {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

.suggest-opt-remove:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(12px);
  background: #1f2430;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 28px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--accent);
}