:root {
  --bg1: #eef2ff; --bg2: #fdf2f8; --ink: #1f2340; --muted: #6b7194;
  --brand: #6366f1; --brand-dark: #4f46e5; --card: #fff; --line: #e3e6f5; --danger: #dc2626;
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg1), var(--bg2)) fixed;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.screen { max-width: 880px; margin: 0 auto; padding: 20px 16px 40px; }
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
h1 { margin: 0; font-size: 1.4rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 18px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(79, 70, 229, .10); border: 1px solid var(--line);
}
.card.narrow { width: 100%; max-width: 380px; text-align: center; }
.card.narrow h1 { margin-bottom: 4px; }
.logo { font-size: 3rem; }
.muted { color: var(--muted); }
.small-text { font-size: .85rem; }
footer { text-align: center; margin-top: 8px; }

input[type=password], textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: inherit;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fafbff; resize: vertical;
}
input:focus, textarea:focus, .drop:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(99,102,241,.18); }
.field-label { display: block; margin: 18px 0 6px; font-weight: 600; }

.drop {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: 200px;
  border: 2.5px dashed #c7cbf5; border-radius: var(--radius); background: #f7f8ff; cursor: pointer;
  text-align: center; padding: 14px; transition: background .15s, border-color .15s;
}
.drop:hover, .drop.over { background: #eef0ff; border-color: var(--brand); }
.drop-icon { font-size: 2.6rem; }
.drop p { margin: 4px 0; }
.drop img { max-width: 100%; max-height: 340px; border-radius: 12px; display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-weight: 600; padding: 12px 22px; border-radius: 12px; border: 0; cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.ghost { background: #eef0ff; color: var(--brand-dark); }
.btn.small { padding: 6px 14px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
#login-btn { width: 100%; margin-top: 12px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.error { color: var(--danger); background: #fef2f2; border: 1px solid #fecaca; padding: 10px 14px; border-radius: 10px; margin: 14px 0 0; text-align: left; }
.note { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; padding: 8px 12px; border-radius: 10px; margin: 12px 0 0; font-size: .9rem; }
.loading-msg { color: var(--muted); margin: 12px 0 0; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare figure { margin: 0; text-align: center; }
.compare figcaption { font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.compare img { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #f3f4fb; }
@media (max-width: 640px) {
  .compare { grid-template-columns: 1fr; }
  .btn { flex: 1; }
}

/* Prompt box: roomy, resizable, monospace so pasted JSON prompts read well */
#prompt {
  min-height: 160px; max-height: 70vh; resize: vertical; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .9rem; line-height: 1.45; white-space: pre-wrap; tab-size: 2;
}
.counter { text-align: right; margin: 4px 2px 0; }
.counter.warn { color: var(--danger); font-weight: 600; }
