/* Write section (grammar and style correction). Everything is scoped under .wr / .wr-pop. */

.wr { display: flex; flex-direction: column; gap: 16px; }

/* ---------- top bar */
.wr-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: 44px; }
.wr-title { margin: 0 6px 0 0; }
.wr-lang-wrap { display: flex; align-items: center; }
.wr-lang { width: auto; min-width: 230px; height: 40px; padding-right: 10px; cursor: pointer; font-weight: 600; }
.wr-lang:disabled { cursor: default; color: var(--text-2); }
.wr-status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); min-height: 24px; }
.wr-status b { color: var(--accent); font-weight: 700; }
.wr-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--pro); font-weight: 600; }
.wr-ok svg { width: 18px; height: 18px; }
.wr-spacer { flex: 1; }
.wr-toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none; }

/* ---------- panels */
.wr-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.wr-panel { display: flex; flex-direction: column; min-height: 440px; position: relative; overflow: hidden; }
.wr-in { transition: border-color .15s, box-shadow .15s; }
.wr-in:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.wr-text {
  flex: 1 0 auto; display: block; width: 100%; min-height: 360px; border: 0; outline: none; resize: none;
  padding: 22px 56px 22px 24px; background: transparent; color: var(--text);
  font-size: 17px; line-height: 1.65; overflow: hidden;
}
.wr-text::placeholder { color: var(--muted); }
.wr-clear { position: absolute; top: 12px; right: 12px; }

.wr-foot {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 14px 10px 24px;
  border-top: 1px solid var(--border); background: var(--surface); flex: none;
}
.wr-foot .btn svg { width: 18px; height: 18px; }
.wr-count { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.wr-count.over { color: var(--danger); font-weight: 700; }

.wr-note {
  margin: 0 16px 14px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--text); font-size: 14px; line-height: 1.45;
}
.wr-note.error { background: var(--danger-soft); color: var(--danger); }
.wr-note a { font-weight: 700; white-space: nowrap; }

/* ---------- result */
.wr-result {
  flex: 1 0 auto; padding: 22px 24px; font-size: 17px; line-height: 1.65; color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere; transition: opacity .2s;
}
.wr-out.is-loading .wr-result { opacity: .55; }
.wr-out.is-loading::before {
  content: ""; position: absolute; top: 0; left: 0; width: 35%; height: 3px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: wr-slide 1.1s ease-in-out infinite;
}
@keyframes wr-slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.wr-s {
  cursor: pointer; border-radius: 4px; transition: background .12s;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.wr-s:hover { background: rgba(53, 89, 240, .07); }
.wr-s.wr-active { background: rgba(53, 89, 240, .13); }
.wr-t.wr-active { background: rgba(53, 89, 240, .2); border-radius: 3px; }

.wr-ins {
  color: var(--accent); background: rgba(53, 89, 240, .08); border-radius: 3px;
  text-decoration: underline; text-decoration-color: var(--accent);
  text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.wr-del {
  color: var(--muted); text-decoration: line-through; text-decoration-color: var(--danger);
  text-decoration-thickness: 1.5px;
}
.wr-plain .wr-ins { color: inherit; background: none; text-decoration: none; }
.wr-plain .wr-delw { display: none; }

.wr-hint { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); }

/* ---------- empty state */
.wr-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 36px 28px; gap: 6px;
}
.wr-empty-ic {
  width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
}
.wr-empty-ic svg { width: 28px; height: 28px; }
.wr-empty h3 { font-size: 18px; margin: 0; color: var(--text); }
.wr-empty p { margin: 0 0 14px; max-width: 360px; font-size: 14.5px; color: var(--text-2); }
.wr-feats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; text-align: left; }
.wr-feats li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.wr-feats svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

/* ---------- popovers */
.wr-pop { width: 400px; max-width: calc(100vw - 16px); padding: 6px; }
.wr-pop-h {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 6px 10px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--text-2);
}
.wr-pop-h span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wr-pop-h .icon-btn { width: 28px; height: 28px; flex: none; }
.wr-pop-h .icon-btn svg { width: 16px; height: 16px; }
.wr-pop-b button { white-space: normal; line-height: 1.45; font-size: 15px; }
.wr-pop-b button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wr-pop-msg { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; font-size: 14px; color: var(--text-2); }
.wr-pop-err { color: var(--danger); }

.wr-pop-word { width: auto; min-width: 240px; max-width: min(380px, calc(100vw - 16px)); }
.wr-pop-word .wr-pop-b { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 8px; }
.wr-pop-word .wr-pop-b button {
  width: auto; padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 18px; font-weight: 500;
}
.wr-pop-word .wr-pop-b button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wr-pop-word .wr-pop-msg { width: 100%; }

.wr-spin {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: wr-rot .7s linear infinite;
}
@keyframes wr-rot { to { transform: rotate(360deg); } }

/* ---------- mobile */
@media (max-width: 860px) {
  .wr { gap: 12px; }
  .wr-bar { gap: 10px; }
  .wr-lang-wrap { flex: 1; min-width: 0; }
  .wr-lang { min-width: 0; width: 100%; }
  .wr-panels { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .wr-panel { min-height: 0; }
  .wr-text { min-height: 200px; padding: 16px 48px 16px 16px; font-size: 16px; }
  .wr-result { padding: 16px; font-size: 16px; }
  .wr-empty { padding: 28px 20px; }
  .wr-foot { padding: 8px 12px 8px 16px; }
  .wr-hint { display: none; }
  .wr-out-foot { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .wr-out.is-loading::before, .wr-spin { animation-duration: 2.4s; }
}
