/* Motion Vector Studio v1 - styles (mobile-first, dark studio theme) */
* { box-sizing: border-box; }
:root {
  --bg: #0f141a;
  --panel: #18202b;
  --panel2: #1f2a38;
  --line: #2b3a4d;
  --text: #e8eef4;
  --muted: #9fb0c3;
  --accent: #10b981;
  --accent-dark: #0b8f66;
  --warn: #f59e0b;
  --err: #f87171;
  --ok: #34d399;
  --radius: 10px;
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
header p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
section.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
section.card h2 { margin: 0 0 4px; font-size: 18px; }
section.card h3 { margin: 14px 0 6px; font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .row { margin-top: 8px; }
label { font-size: 14px; color: var(--muted); }
select, input[type="text"], input[type="number"], textarea {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  min-height: 44px;
}
select, input[type="text"], input[type="number"] { max-width: 100%; }
input[type="number"] { width: 90px; }
button {
  background: var(--accent);
  color: #04150e;
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  min-height: 48px;
  cursor: pointer;
}
button:hover { background: #34d399; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
button.secondary:hover { background: #2a3a4e; }
button.danger { background: #7f1d1d; color: #fff; }

/* Preview */
.preview-wrap {
  background: #000;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-wrap svg { width: 100%; height: 100%; display: block; }
.progress { font-size: 14px; color: var(--muted); min-height: 22px; margin: 8px 0 0; }
.progress.ok { color: var(--ok); }
.progress.err { color: var(--err); }
.error-line {
  color: var(--err);
  background: #2a1518;
  border: 1px solid #5b2326;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.error-line:empty { display: none; }
.support-line { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.support-line.bad { color: var(--warn); }

/* Editor with line numbers */
.editor-wrap {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0b1016;
  margin-top: 8px;
}
.gutter {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 10px 8px 10px 10px;
  text-align: right;
  color: #5b6b7f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
  overflow: hidden;
  user-select: none;
  background: #0d131b;
  border-right: 1px solid var(--line);
}
#editor {
  flex: 1 1 auto;
  min-width: 0;
  height: 320px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d7e3ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  resize: vertical;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
#editor:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Prompt builder */
.field-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.field-grid label { display: block; margin-bottom: 4px; }
.field-grid select, .field-grid input { width: 100%; }
#promptOut {
  width: 100%;
  min-height: 170px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
#csvOut, #batchInfo { font-size: 14px; }
textarea.wide { width: 100%; }
/* Auth bar and plan badge */
.auth-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.auth-bar button { min-height: 40px; padding: 8px 14px; }
.badge { display: inline-block; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.badge.pro { background: var(--accent); color: #04150e; border-color: var(--accent); }

/* Usage meter */
.usage-meter { font-size: 14px; color: var(--muted); margin: 0 0 10px; }

/* Auth modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-start; justify-content: center; padding: 20px 12px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 420px; }
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-card label { display: block; margin: 10px 0 4px; }
.modal-card input { width: 100%; }

/* Saved projects */
.project-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.project-item { display: flex; gap: 8px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.project-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.project-item button { min-height: 40px; padding: 8px 12px; }

footer { color: var(--muted); font-size: 13px; text-align: center; padding: 0 16px 24px; }

/* Wider screens: two columns for editor + preview */
@media (min-width: 860px) {
  main { padding: 16px 20px 48px; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .studio-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; align-items: start; }
  #editor { height: 460px; }
}
