:root {
  --page: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #1f2328;
  --ink-2: #57606a;
  --muted: #8b949e;
  --line: #e4e6ea;
  --blue: #1a73e8;
  --blue-ink: #1558b0;
  --blue-wash: #e8f0fe;
  --red: #d93025;
  --green: #188038;
  --green-wash: #e6f4ea;
  --amber-wash: #fef7e0;
  --amber: #8a5a00;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; position: sticky; top: 0; z-index: 20; }
.app-title { font-size: 20px; font-weight: 700; color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 22px; }
.topbar nav a { color: var(--ink-2); font-weight: 500; }
.topbar nav a.active { color: var(--ink); }
.who { color: var(--muted); font-size: 13px; }
.linklike { border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 0; }
.container { max-width: 1280px; margin: 0 auto; padding: 28px 24px 120px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #d0d4da; background: var(--surface); padding: 7px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; color: var(--ink); font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-ink); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-outline { color: var(--red); border-color: var(--red); background: #fff; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.grey { background: #eceef1; border-color: #eceef1; }
.btn.dark { background: #5f6368; border-color: #5f6368; color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 11px 26px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  padding: 8px 11px; border: 1px solid #cfd3d9; border-radius: 6px; background: var(--surface); outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
textarea { resize: vertical; width: 100%; }
textarea.code { font: 13px/1.5 var(--mono); min-height: 260px; }
input[type=radio], input[type=checkbox] { accent-color: var(--blue); width: 16px; height: 16px; margin: 0; }
.w-full { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: 13px; }
.field .hint, .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.checks { display: flex; gap: 22px; flex-wrap: wrap; }
.checks label, .radios label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.radios { display: inline-flex; gap: 16px; align-items: center; }
.radios.vertical { flex-direction: column; align-items: flex-start; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.error { color: var(--red); font-size: 13px; }
.ok { color: var(--green); font-size: 13px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 30px; }
.card + .card { margin-top: 22px; }
.card > h2 { font-size: 20px; padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 20px; }
.note { background: var(--blue-wash); color: #174ea6; border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.note.warn { background: var(--amber-wash); color: var(--amber); }

/* ---------- survey list ---------- */
.list-card { padding: 0; overflow: hidden; }
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 28px 40px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.list-head h1 { font-size: 28px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 15px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.survey-title { font-size: 16px; font-weight: 600; color: var(--ink); display: block; margin-bottom: 6px; }
.byline { font-size: 12px; color: var(--muted); line-height: 1.6; }
.date { font-size: 15px; }
.time { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .03em; background: #eceef1; color: var(--ink-2); }
.pill.published { background: var(--green-wash); color: var(--green); }
.pill.stopped { background: #fce8e6; color: var(--red); }
.count { display: inline-block; min-width: 34px; text-align: center; padding: 4px 9px; border-radius: 999px; background: #eceef1; font-weight: 600; font-size: 13px; }
.actions { display: grid; grid-template-columns: repeat(3, max-content); gap: 6px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- editor ---------- */
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.editor-head h1 { font-size: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; padding: 0 24px; overflow-x: auto; scrollbar-width: none; border-radius: var(--radius) var(--radius) 0 0; }
.tab { border: 0; background: none; padding: 18px 16px 16px; font-size: 15px; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab-body { background: #f7f8fa; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); padding: 30px 40px; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.05); z-index: 15; }
.savebar .inner { max-width: 1280px; margin: 0 auto; padding: 14px 64px; display: flex; justify-content: flex-end; gap: 16px; align-items: center; }
.savebar .status { margin-right: auto; color: var(--muted); font-size: 13px; }

.img-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.img-pick img { max-height: 90px; max-width: 320px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.color-pick { display: inline-flex; align-items: center; gap: 8px; }
.color-pick input[type=color] { width: 40px; height: 32px; padding: 0; border: 1px solid #cfd3d9; border-radius: 6px; background: none; }

/* question cards */
.qcard { border: 1px solid #dcdfe4; border-radius: var(--radius); background: var(--surface); margin-top: 22px; }
.qcard.section { border-left: 4px solid var(--blue); }
.qhead { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; gap: 10px; flex-wrap: wrap; }
.qhead h3 { font-size: 17px; }
.qhead .row { gap: 8px; }
.qbody { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.qline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.qline > .lbl { font-weight: 600; font-size: 15px; min-width: 110px; }
.qline input[type=text] { flex: 1; min-width: 200px; }
.qimg { max-height: 70px; border-radius: 6px; border: 1px solid var(--line); }
.divider { border-top: 1px solid var(--line); margin: 2px 0; }
.format { background: #fafbfc; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.format h4 { margin: 0; font-size: 16px; }
.format .qline > .lbl { min-width: 140px; }
.format input[type=number] { width: 90px; }
.opt-row { display: grid; grid-template-columns: 90px 36px minmax(0, 1fr) 40px 28px; gap: 10px; align-items: center; }
.opt-row .olabel { font-weight: 600; }
.opt-thumb { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 4px; background: #fff center/cover no-repeat; }
.icon-btn { width: 40px; height: 34px; border: 1px solid #d0d4da; background: #fff; border-radius: 6px; cursor: pointer; font-size: 15px; }
.x-btn { width: 26px; height: 26px; border: 0; background: var(--red); color: #fff; border-radius: 4px; cursor: pointer; font-weight: 700; }
.add-row { display: flex; gap: 10px; }

/* results */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: minmax(140px, 320px) 1fr 90px; gap: 12px; align-items: center; font-size: 13px; }
.bar .track { height: 14px; background: #eceef1; border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--blue); border-radius: 4px; }
.bar .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.result { padding: 18px 0; border-top: 1px solid var(--line); }
.result:first-of-type { border-top: 0; }
.gridtable td, .gridtable th { padding: 6px 10px; font-size: 13px; }
.gridtable td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* login */
.auth { max-width: 400px; margin: 60px auto; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #202124; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.bad { background: var(--red); }

@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .topbar nav { gap: 12px; }
  .who { display: none; }
  .container { padding: 16px 12px 120px; }
  .list-head { padding: 18px; }
  .list-head h1 { font-size: 22px; }
  .tab-body { padding: 16px; }
  .card { padding: 18px; }
  .qbody, .qhead { padding: 14px; }
  .opt-row { grid-template-columns: 32px minmax(0, 1fr) 40px 28px; }
  .opt-row .olabel { display: none; }
  .savebar .inner { padding: 10px 12px; gap: 8px; }
  .savebar .status { display: none; }
  .bar { grid-template-columns: 1fr 70px; }
  .bar .track { grid-column: 1 / -1; grid-row: 2; }
}

/* panel / redirects */
.pill.panel { background: #e8f0fe; color: var(--blue-ink); }
.pause-box { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 14px 18px; border-radius: 8px; background: var(--green-wash); }
.pause-box.paused { background: #fce8e6; }
input.entry { font-family: var(--mono); font-size: 13px; background: var(--surface-2); }
