:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #657386;
  --line: #d8e0ea;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.shell { width: min(1180px, calc(100% - 32px)); margin: 24px auto 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.topActions { display: flex; align-items: center; gap: 12px; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 32px; }
h2 { font-size: 18px; }
p { margin: 6px 0 0; color: var(--muted); }
.stat { min-width: 132px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 14px; text-align: right; }
.stat span { display: block; font-size: 28px; font-weight: 750; }
.stat small { color: var(--muted); }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); padding: 12px 14px; cursor: pointer; font-weight: 700; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.panel.active { display: block; }
.grid { display: grid; grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr); gap: 20px; }
.stack { display: grid; gap: 12px; align-content: start; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}
textarea { min-height: 82px; resize: vertical; }
button { border: 0; background: var(--accent); color: white; border-radius: 6px; padding: 10px 14px; cursor: pointer; font-weight: 750; }
button:hover { background: var(--accent-dark); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.inlineGroup { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.output { min-height: 120px; margin: 16px 0 0; border: 1px solid var(--line); border-radius: 6px; padding: 14px; overflow: auto; background: #fbfcfd; white-space: pre-wrap; }
.rulesBox { margin-top: 14px; border: 1px solid var(--line); border-radius: 6px; padding: 14px; background: #fbfcfd; white-space: pre-wrap; color: var(--ink); }
.matches, .library { display: grid; gap: 10px; }
.match, .libraryItem { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfd; }
.match strong, .libraryItem strong { display: block; margin-bottom: 4px; }
.match p, .libraryItem p { font-size: 14px; }
.editor { margin-top: 20px; }
.editorHead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
#draft, #review { min-height: 420px; line-height: 1.55; }
.loginShell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.loginPanel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}
.loginPanel h1 { font-size: 28px; }
.errorText { min-height: 20px; color: #b42318; font-weight: 650; }
@media (max-width: 820px) {
  .topbar, .topActions, .editorHead { align-items: stretch; flex-direction: column; }
  .stat { text-align: left; }
  .grid { grid-template-columns: 1fr; }
  .inlineGroup { grid-template-columns: 1fr; }
}
