/* ---------- BASE ---------- */
* { box-sizing: border-box; margin: 0; }

:root {
  --ink: #1e2430;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --bad: #b42318;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

body {
  min-height: 100vh;
  background: #f6f7fb;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top { max-width: 1120px; margin: 0 auto; padding: 28px 16px 8px; }
.top h1 { font-size: clamp(24px, 4vw, 34px); letter-spacing: -.5px; }
.top p { color: var(--muted); margin-top: 6px; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.examples, .pattern-panel, .replace-panel { grid-column: 1 / -1; }
.panel { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.panel h2 { margin-bottom: 10px; font-size: 16px; }
.panel h2 small { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 4px; }
/* ---------- END BASE ---------- */

/* ---------- EXAMPLES ---------- */
.example-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
}
.chip-btn:hover { border-color: #a5b4fc; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.note { min-height: 46px; margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: #eef2ff; color: #3730a3; font-size: 14.5px; line-height: 1.5; }
/* ---------- END EXAMPLES ---------- */

/* ---------- PATTERN ---------- */
.pattern-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.slash { color: var(--muted); font: 700 20px var(--mono); }
#pattern {
  flex: 1 1 260px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: 16px var(--mono);
}
#pattern:focus, #text:focus, #replace:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
#pattern.bad { border-color: var(--bad); }
.flags { display: flex; gap: 4px; }
.flag {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: 700 14px var(--mono);
  cursor: pointer;
}
.flag[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.flag:focus-visible, .chip-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.status { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 13.5px; }
.status.bad { color: var(--bad); }
/* ---------- END PATTERN ---------- */

/* ---------- TEXT AND RESULT ---------- */
#text, #replace {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: 14px/1.65 var(--mono);
  resize: vertical;
}
.highlight, .replaced {
  min-height: 60px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcfd;
  font: 14px/1.65 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.highlight { min-height: 168px; }
mark { padding: 1px 0; border-radius: 3px; background: #c7d2fe; color: inherit; }
mark.alt { background: #a7f3d0; }
mark.zero { display: inline-block; width: 2px; height: 1.1em; padding: 0; background: var(--accent); vertical-align: text-bottom; }
/* ---------- END TEXT AND RESULT ---------- */

/* ---------- EXPLANATION ---------- */
.explain { display: flex; flex-direction: column; gap: 5px; padding: 0; list-style: none; }
.explain li { display: flex; gap: 10px; align-items: baseline; font-size: 14px; line-height: 1.45; }
.explain code { flex: none; max-width: 45%; padding: 2px 7px; border-radius: 6px; background: #eef2ff; color: #3730a3; font: 700 13px var(--mono); overflow-wrap: anywhere; }

.scroll { overflow-x: auto; }
.details { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.details th { padding: 0 8px 7px; border-bottom: 1px solid var(--line); color: var(--muted); font: 600 12px var(--mono); text-align: left; }
.details td { padding: 6px 8px; border-bottom: 1px solid #f2f4f7; font-family: var(--mono); overflow-wrap: anywhere; }
.none { color: var(--muted); font-family: system-ui, sans-serif; }
/* ---------- END EXPLANATION ---------- */

/* ---------- REPLACE ---------- */
.replace-label { display: block; margin-bottom: 8px; font-size: 16px; font-weight: 700; }
.replaced { margin-top: 10px; min-height: 44px; }
.snippet { margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: #111827; color: #e5e7eb; font: 13.5px/1.6 var(--mono); overflow-x: auto; }
/* ---------- END REPLACE ---------- */

/* ---------- SMALL SCREENS ---------- */
@media (max-width: 860px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .note { min-height: 72px; }
  .highlight { min-height: 90px; }
}
/* ---------- END SMALL SCREENS ---------- */
