:root {
  color-scheme: light;
  --bg: #f2f6fb;
  --surface: #ffffff;
  --surface-2: #f6f9fd;
  --line: #dbe4ef;
  --line-strong: #becddd;
  --text: #152235;
  --muted: #617188;
  --accent: #2563eb;
  --accent-strong: #174fc5;
  --success: #16845b;
  --danger: #c33d4d;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(85, 112, 148, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 112, 148, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 18% -10%, rgba(37, 99, 235, 0.09), transparent 34%),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto;
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
  min-height: 72px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(170, 187, 209, 0.62);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 42px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border-radius: 8px 8px 8px 2px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #52637a;
  font-size: 0.875rem;
}

.privacy-badge span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(22, 132, 91, 0.1);
}

.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 54px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
  gap: 30px;
  align-items: start;
}

.editor-panel,
.rules-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 55px rgba(50, 75, 106, 0.09);
}

.editor-panel { padding: clamp(28px, 4vw, 52px); border-radius: var(--radius); }
.rules-panel { padding: 30px; border-radius: var(--radius); position: sticky; top: 24px; background: #f8fbff; }

.intro { max-width: 650px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 0.78rem; font-weight: 780; letter-spacing: 0.14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.02; letter-spacing: -0.045em; }
h2 { margin-bottom: 8px; font-size: 1.35rem; letter-spacing: -0.02em; }
.intro p { margin-bottom: 0; color: var(--muted); font-size: 1rem; line-height: 1.65; }

.drop-zone {
  min-height: 225px;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: #f8fbff;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragging { border-color: var(--accent); background: #f2f7ff; outline: none; }
.drop-zone.is-dragging { transform: scale(1.008); }
.drop-zone strong { display: block; margin-bottom: 4px; font-size: 1.05rem; }
.drop-zone span { color: var(--muted); font-size: 0.9rem; }
.file-icon { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 16px; color: var(--accent); background: rgba(37, 99, 235, 0.09); }
.file-icon svg, .icon-button svg, .local-note svg, .success-icon svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 720;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.22); outline-offset: 2px; }
.button:disabled { opacity: 0.42; cursor: not-allowed; }
.button-primary { color: #ffffff; background: var(--accent); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18); }
.button-primary:hover:not(:disabled) { background: var(--accent-strong); }
.button-secondary { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.button-ghost { color: var(--muted); border-color: var(--line); background: transparent; }

.file-card, .progress-panel, .result-panel, .message { margin-top: 18px; border-radius: 12px; }
.file-card { padding: 15px 16px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); background: #f8fbff; }
.file-meta { min-width: 0; display: flex; align-items: center; gap: 14px; }
.file-meta > div { min-width: 0; }
.file-meta strong, .file-meta span { display: block; }
.file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { margin-top: 3px; color: var(--muted); font-size: 0.82rem; }
.file-type { flex: 0 0 auto; padding: 8px 7px; border-radius: 7px; color: var(--accent); background: rgba(37, 99, 235, 0.09); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--text); background: rgba(37, 99, 235, 0.06); }

.actions { margin-top: 22px; display: flex; gap: 10px; }
.progress-panel { padding: 18px; border: 1px solid var(--line); background: #f8fbff; }
.progress-copy { display: flex; justify-content: space-between; gap: 20px; font-size: 0.9rem; }
.progress-copy span { color: var(--accent); font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; margin: 13px 0 10px; overflow: hidden; border-radius: 99px; background: #dfe7f2; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #3b82f6, var(--accent-strong)); transition: width 180ms ease; }
.progress-panel p { margin-bottom: 0; color: var(--muted); font-size: 0.82rem; }
.message { padding: 14px 16px; line-height: 1.5; }
.error-message { border: 1px solid rgba(195, 61, 77, 0.3); color: #8f2937; background: #fff5f6; }

.result-panel { padding: 22px; border: 1px solid rgba(22, 132, 91, 0.25); background: #f2fbf7; }
.result-heading { display: flex; gap: 13px; align-items: flex-start; }
.result-heading h2 { margin: 0 0 4px; font-size: 1.08rem; }
.result-heading p { margin: 0; color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.success-icon { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--success); background: rgba(22, 132, 91, 0.1); }
.result-grid { margin: 20px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.result-grid div { padding: 14px; background: var(--surface); }
.result-grid dt { min-height: 2.5em; color: var(--muted); font-size: 0.75rem; line-height: 1.25; }
.result-grid dd { margin: 7px 0 0; font-size: 1.25rem; font-weight: 780; font-variant-numeric: tabular-nums; }

.rule-list { margin: 28px 0; padding: 0; list-style: none; }
.rule-list li { display: grid; grid-template-columns: 34px 1fr; gap: 13px; padding: 18px 0; border-top: 1px solid var(--line); }
.rule-list li:last-child { border-bottom: 1px solid var(--line); }
.rule-list > li > span { color: var(--accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; }
.rule-list strong { font-size: 0.94rem; }
.rule-list p { margin: 6px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
code { padding: 0.12em 0.35em; border-radius: 4px; color: #244d8f; background: #eaf1fb; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.86em; }
.local-note { display: grid; grid-template-columns: 22px 1fr; gap: 11px; align-items: start; color: var(--success); }
.local-note p { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.55; }
.local-note strong { color: #176546; }
.browser-note { margin: 18px 0 0; color: #75869b; font-size: 0.76rem; line-height: 1.5; }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 0 0 34px; display: flex; justify-content: flex-end; gap: 20px; color: #718198; font-size: 0.78rem; }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .workspace { margin-top: 30px; grid-template-columns: 1fr; }
  .rules-panel { position: static; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .topbar { min-height: 64px; padding: 0 18px; }
  .privacy-badge { font-size: 0; }
  .workspace { width: min(100% - 24px, 1180px); }
  .editor-panel, .rules-panel { padding: 22px; border-radius: 14px; }
  .drop-zone { min-height: 205px; padding: 24px 18px; }
  .actions { flex-direction: column; }
  .actions .button { width: 100%; }
  footer { width: calc(100% - 24px); flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
