/* "Tạo Google Form bằng AI" (views/designer/component.php, assets/js/form-designer.js) */
.fd { --fd-brand: #673ab7; --fd-brand-2: #7c4dff; --fd-ink: #1f1a29; --fd-muted: #6b6478; --fd-line: #e9e4f2; --fd-soft: #f6f2fc; --fd-bg: #f4f1fa;
  color: var(--fd-ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
.fd *, .fd *::before, .fd *::after { box-sizing: border-box; }
.fd button { font: inherit; cursor: pointer; }
.fd input, .fd textarea, .fd select { font-family: inherit; color: inherit; }
.fd [hidden] { display: none !important; }

/* ---- My designs ---- */
.fd-mine { margin-bottom: 16px; }
.fd-mine h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; margin: 0 0 10px; }
.fd-mine h3 span { background: var(--fd-soft); color: #4c1d95; font-size: 12px; border-radius: 999px; padding: 2px 9px; }
.fd-mine-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fd-mine-card { position: relative; display: grid; gap: 4px; align-content: start; text-align: left; background: #fff; border: 1.5px solid var(--fd-line); border-radius: 16px; padding: 14px 40px 14px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.fd-mine-card:hover, .fd-mine-card:focus-visible { border-color: var(--fd-brand); box-shadow: 0 10px 24px rgba(64, 33, 120, .1); transform: translateY(-1px); outline: 0; }
.fd-mine-card b { font-size: 14.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fd-mine-card span { font-size: 12.5px; color: var(--fd-muted); }
.fd-mine-card em { font-style: normal; font-size: 11.5px; font-weight: 700; width: max-content; border-radius: 999px; padding: 2px 9px; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.fd-mine-pub { background: #e6f4ea; color: #137333; }
.fd-mine-draft { background: #f1edf8; color: #5b3f93; }
.fd-mine-del { position: absolute; top: 8px; right: 6px; }
.fd-mine-new { border-style: dashed; border-color: #cfc2e8; background: var(--fd-soft); color: #4c1d95; padding-right: 16px; place-content: center; justify-items: center; text-align: center; min-height: 96px; }
.fd-mine-new i { font-size: 22px; }
.fd-redo-note { margin-top: 12px; font-size: 13px; color: #9a5b00; background: #fff8eb; border-radius: 12px; padding: 9px 12px; display: flex; gap: 6px; align-items: flex-start; }

/* ---- Brief ---- */
.fd-brief { background: #fff; border: 1px solid var(--fd-line); border-radius: 22px; padding: 22px; box-shadow: 0 18px 50px rgba(64, 33, 120, .08); }
.fd-label { display: block; font-size: 13px; font-weight: 700; color: var(--fd-ink); margin: 0 0 8px; }
.fd-label small { font-weight: 500; color: var(--fd-muted); }
.fd-topic { width: 100%; min-height: 108px; resize: vertical; border: 1.5px solid #ddd3ef; border-radius: 16px; padding: 14px 16px; font-size: 15.5px; line-height: 1.5; background: #fcfbfe; }
.fd-topic:focus, .fd-input:focus, .fd-q textarea:focus, .fd-q input:focus { outline: 0; border-color: var(--fd-brand); box-shadow: 0 0 0 4px rgba(103, 58, 183, .12); background: #fff; }
.fd-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.fd-examples button { border: 1px dashed #cfc2e8; background: #fff; color: #5b3f93; border-radius: 999px; padding: 5px 11px; font-size: 12.5px; }
.fd-examples button:hover { background: var(--fd-soft); }
.fd-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.fd-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.fd-chip { border: 1.5px solid #e2daf0; background: #fff; border-radius: 12px; padding: 8px 12px; font-size: 13.5px; font-weight: 600; color: #3b3446; display: inline-flex; align-items: center; gap: 6px; }
.fd-chip i { font-size: 16px; color: var(--fd-brand); }
.fd-chip.is-on { border-color: var(--fd-brand); background: var(--fd-soft); color: #4c1d95; box-shadow: inset 0 0 0 1px var(--fd-brand); }
.fd-seg { display: inline-flex; background: #f1edf8; border-radius: 12px; padding: 3px; }
.fd-seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--fd-muted); }
.fd-seg button.is-on { background: #fff; color: #4c1d95; box-shadow: 0 1px 4px rgba(40, 20, 80, .12); }
.fd-input { width: 100%; border: 1.5px solid #e2daf0; border-radius: 12px; padding: 10px 12px; font-size: 14px; background: #fcfbfe; }
.fd-go { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.fd-btn { border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.fd-btn-primary { color: #fff; background: linear-gradient(135deg, var(--fd-brand), var(--fd-brand-2)); box-shadow: 0 10px 26px rgba(103, 58, 183, .32); }
.fd-btn-primary:hover { filter: brightness(1.06); }
.fd-btn-primary:disabled { opacity: .7; cursor: wait; }
.fd-btn-ghost { background: #fff; color: #4c1d95; border: 1.5px solid #ddd3ef; }
.fd-btn-ghost:hover { background: var(--fd-soft); }
.fd-left { font-size: 12.5px; color: var(--fd-muted); }
.fd-loading { margin-top: 16px; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--fd-soft); color: #4c1d95; font-weight: 600; font-size: 14px; }
.fd-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #d9cdf0; border-top-color: var(--fd-brand); animation: fd-spin .8s linear infinite; flex: none; }
@keyframes fd-spin { to { transform: rotate(360deg); } }

/* ---- Editor ---- */
#fd-editor { scroll-margin-top: 90px; }
.fd-mtop { display: none; }
.fd-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.fd-canvas { background: var(--fd-bg); border-radius: 22px; padding: 18px; }
.fd-card { background: #fff; border: 1px solid var(--fd-line); border-radius: 16px; padding: 18px 20px; margin-bottom: 12px; position: relative; }
.fd-card-head { border-top: 10px solid var(--fd-brand); }
.fd-title-input { width: 100%; resize: none; line-height: 1.25; border: 0; border-bottom: 1.5px solid transparent; font-size: 26px; font-weight: 800; padding: 4px 0; background: transparent; }
.fd-desc-input { width: 100%; border: 0; border-bottom: 1.5px solid transparent; font-size: 14px; color: var(--fd-muted); padding: 6px 0; resize: none; background: transparent; line-height: 1.5; }
.fd-title-input:hover, .fd-desc-input:hover { border-bottom-color: #e6dff3; }
.fd-title-input:focus, .fd-desc-input:focus { outline: 0; border-bottom-color: var(--fd-brand); }
.fd-section-bar { display: flex; align-items: center; gap: 10px; margin: 22px 0 8px; }
.fd-section-tag { background: var(--fd-brand); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 9px 9px 0 0; }
.fd-section-bar .fd-icon-btn { margin-left: auto; }
.fd-card-section { border-top-left-radius: 0; border-left: 5px solid var(--fd-brand); }
.fd-section-title { width: 100%; border: 0; font-size: 18px; font-weight: 800; padding: 2px 0; background: transparent; }
.fd-section-title:focus { outline: 0; }

.fd-q { border-left: 5px solid transparent; transition: border-color .15s, box-shadow .15s; }
.fd-q:focus-within { border-left-color: #4285f4; box-shadow: 0 6px 20px rgba(60, 40, 110, .08); }
.fd-q-top { display: flex; gap: 10px; align-items: flex-start; }
.fd-q-title { flex: 1; min-width: 0; border: 0; border-bottom: 1.5px solid #ece6f6; background: #faf9fc; border-radius: 8px 8px 0 0; padding: 10px 12px; font-size: 15px; font-weight: 600; resize: none; line-height: 1.4; }
.fd-q-type { border: 1.5px solid #e2daf0; border-radius: 10px; padding: 9px 8px; font-size: 13px; background: #fff; max-width: 190px; }
.fd-q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fd-badge { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 9px; background: #f1edf8; color: #5b3f93; }
.fd-badge.code { background: #e8f0fe; color: #1a56c4; font-family: ui-monospace, Consolas, monospace; }
.fd-badge.warn { background: #fff4e5; color: #9a5b00; }
.fd-badge.screen { background: #fde8ee; color: #b4234d; }
.fd-opts { margin-top: 12px; display: grid; gap: 6px; }
.fd-opt { display: flex; align-items: center; gap: 8px; }
.fd-opt-mark { width: 18px; height: 18px; border: 2px solid #b7aecb; border-radius: 50%; flex: none; }
.fd-opt-mark.sq { border-radius: 4px; }
.fd-opt-mark.num { border: 0; width: auto; font-size: 13px; color: var(--fd-muted); min-width: 18px; }
.fd-opt input[type=text] { flex: 1; min-width: 0; border: 0; border-bottom: 1px solid transparent; padding: 6px 2px; font-size: 14px; background: transparent; }
.fd-opt input[type=text]:hover { border-bottom-color: #e6dff3; }
.fd-opt select { border: 1px solid #e2daf0; border-radius: 8px; font-size: 12px; padding: 5px 6px; color: #4c1d95; background: #faf8fd; max-width: 150px; }
.fd-opt-add { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13.5px; }
.fd-link { border: 0; background: none; color: #1a73e8; font-weight: 600; padding: 4px 0; }
.fd-link.muted { color: var(--fd-muted); }
.fd-scale { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; font-size: 13.5px; }
.fd-scale select, .fd-scale input { border: 1.5px solid #e2daf0; border-radius: 9px; padding: 7px 9px; font-size: 13.5px; background: #fff; }
.fd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.fd-opt select.fd-go-sel { border-color: color-mix(in srgb, var(--go) 35%, #fff); color: var(--go); font-weight: 600; }
.fd-opt select.fd-go-sel.is-set { background: color-mix(in srgb, var(--go) 10%, #fff); border-color: var(--go); }
.fd-flash { animation: fd-flash 1.6s ease; }
@keyframes fd-flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(124, 58, 237, .35); } 100% { box-shadow: none; } }

/* ---- Branch map ---- */
.fd-map-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; background: #fff; border: 1px solid var(--fd-line); border-radius: 16px; padding: 14px 18px; margin-bottom: 14px; }
.fd-map-top > div { display: grid; }
.fd-map-top b { font-size: 22px; font-weight: 800; color: #4c1d95; line-height: 1.1; }
.fd-map-top span { font-size: 12px; color: var(--fd-muted); }
.fd-map-top p { flex: 1 1 260px; margin: 0; font-size: 13px; color: var(--fd-muted); line-height: 1.5; }
.fd-map { position: relative; padding: 4px 92px 4px 0; }
.fd-map-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 2; }
.fd-map-lines path { fill: none; stroke-width: 2.5; stroke-linecap: round; opacity: .9; }
.fd-map-lines path.head { stroke: none; opacity: 1; }
.fd-map-start, .fd-map-end { display: flex; align-items: center; justify-content: center; gap: 8px; width: max-content; margin: 0 auto; padding: 9px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.fd-map-start { background: #f1edf8; color: #4c1d95; }
.fd-map-end { background: #e11d48; color: #fff; box-shadow: 0 8px 22px rgba(225, 29, 72, .28); }
.fd-map-down { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--c); font-size: 12px; font-weight: 600; padding: 6px 0; }
.fd-map-down i { font-size: 18px; }
.fd-map-sec { position: relative; background: #fff; border: 1.5px solid color-mix(in srgb, var(--c) 30%, #fff); border-left: 6px solid var(--c); border-radius: 16px; padding: 12px 14px; box-shadow: 0 6px 18px rgba(40, 20, 80, .05); }
.fd-map-sec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fd-map-num { background: var(--c); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.fd-map-sec-head b { font-size: 15px; flex: 1; min-width: 0; }
.fd-map-sec-head small { color: var(--fd-muted); font-size: 12px; }
.fd-map-q { margin-top: 10px; border: 1px solid #efeaf7; border-radius: 12px; padding: 8px 10px; background: #fcfbfe; }
.fd-map-q-title { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 2px 0 6px; font-size: 13.5px; font-weight: 600; color: var(--fd-ink); }
.fd-map-q-title span { display: inline-block; font-size: 11px; color: var(--fd-muted); font-weight: 700; margin-right: 6px; }
.fd-map-q-title:hover { color: #4c1d95; text-decoration: underline; }
.fd-map-opt { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; }
.fd-map-dot { width: 10px; height: 10px; border-radius: 50%; background: #d4cce3; flex: none; }
.fd-map-opt.jumps .fd-map-dot { background: var(--go); box-shadow: 0 0 0 3px color-mix(in srgb, var(--go) 20%, #fff); }
.fd-map-opt-text { flex: 1; min-width: 0; }
.fd-map-go, .fd-map-go-fixed { border: 1.5px solid #e2daf0; border-radius: 999px; font-size: 12px; font-weight: 600; padding: 4px 8px; color: var(--fd-muted); background: #fff; max-width: 170px; }
.fd-map-opt.jumps .fd-map-go { border-color: var(--go); color: var(--go); background: color-mix(in srgb, var(--go) 9%, #fff); }
.fd-map-plain { margin-top: 8px; font-size: 13px; color: var(--fd-muted); display: flex; align-items: center; gap: 6px; }
.fd-map-add { margin-top: 10px; display: flex; align-items: center; gap: 6px; color: #4c1d95; font-size: 13px; }
.fd-map-add select { flex: 1; min-width: 0; max-width: 360px; border: 1.5px dashed #cfc2e8; border-radius: 10px; padding: 6px 8px; font-size: 13px; color: #4c1d95; background: #fff; }
.fd-code-style { display: grid; gap: 6px; }
.fd-code-style button { text-align: left; border: 1.5px solid #e2daf0; background: #fff; border-radius: 10px; padding: 7px 10px; font-size: 13px; font-family: ui-monospace, Consolas, monospace; color: #3b3446; }
.fd-code-style button.is-on { border-color: var(--fd-brand); background: var(--fd-soft); color: #4c1d95; box-shadow: inset 0 0 0 1px var(--fd-brand); }
@media (max-width: 640px) {
  .fd-map { padding-right: 54px; }
  .fd-map-opt { flex-wrap: wrap; }
  .fd-map-go { max-width: 100%; }
}
.fd-grid h5 { margin: 0 0 6px; font-size: 12.5px; color: var(--fd-muted); text-transform: uppercase; letter-spacing: .04em; }
.fd-answer-line { margin-top: 14px; border-bottom: 1px dotted #c7bedb; width: 60%; padding-bottom: 6px; color: #9a92ab; font-size: 13px; }
.fd-hint { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fd-muted); }
.fd-hint input { flex: 1; border: 1px dashed #d8cdea; border-radius: 9px; padding: 6px 9px; font-size: 12.5px; background: #fffdf7; }
.fd-q-foot { display: flex; align-items: center; gap: 4px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #f0ebf7; }
.fd-q-foot .fd-code { width: 76px; border: 1px solid #e2daf0; border-radius: 8px; padding: 5px 7px; font-size: 12px; font-family: ui-monospace, Consolas, monospace; margin-right: auto; }
.fd-icon-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 50%; color: #6b6478; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.fd-icon-btn:hover { background: #f1edf8; color: #4c1d95; }
.fd-switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: #3b3446; margin-left: 8px; user-select: none; }
.fd-switch input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: #d6cfe3; position: relative; transition: background .15s; margin: 0; }
.fd-switch input::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.fd-switch input:checked { background: var(--fd-brand); }
.fd-switch input:checked::after { transform: translateX(14px); }
.fd-add-q { width: 100%; border: 1.5px dashed #cfc2e8; background: rgba(255, 255, 255, .6); color: #5b3f93; border-radius: 14px; padding: 11px; font-weight: 700; font-size: 13.5px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.fd-add-q:hover { background: #fff; }
.fd-add-row { display: flex; gap: 8px; margin-top: 6px; }

/* ---- Side ---- */
/* Sticky, and scrolls on its own when taller than the screen (otherwise its last panels can never be reached). */
.fd-side { position: sticky; top: 88px; display: grid; gap: 12px; max-height: calc(100vh - 100px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-bottom: 4px; }
.fd-panel { background: #fff; border: 1px solid var(--fd-line); border-radius: 18px; padding: 16px; }
.fd-panel h4 { margin: 0 0 10px; font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.fd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fd-stats div { background: var(--fd-soft); border-radius: 12px; padding: 9px; text-align: center; }
.fd-stats b { display: block; font-size: 20px; color: #4c1d95; }
.fd-stats span { font-size: 11.5px; color: var(--fd-muted); }
.fd-check { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: 13px; }
.fd-check li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; line-height: 1.45; }
.fd-check li i { color: var(--fd-brand); margin-top: 2px; }
.fd-check li.warn i { color: #c2410c; }
.fd-check small { display: block; color: var(--fd-muted); }
.fd-save-state { font-size: 12px; color: var(--fd-muted); display: flex; align-items: center; gap: 6px; }
.fd-side .fd-btn { width: 100%; justify-content: center; }

/* ---- Preview ---- */
.fd-preview .fd-q-title, .fd-preview .fd-q-type { pointer-events: none; }
.fd-pv-q { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.fd-pv-q em { color: #d93025; font-style: normal; }
.fd-pv-opt { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; }
.fd-pv-scale { display: flex; align-items: flex-end; gap: 14px; font-size: 13px; color: var(--fd-muted); flex-wrap: wrap; }
.fd-pv-scale span { display: grid; justify-items: center; gap: 6px; }
.fd-pv-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.fd-pv-grid th, .fd-pv-grid td { padding: 8px 6px; text-align: center; border-bottom: 1px solid #f0ebf7; }
.fd-pv-grid td:first-child { text-align: left; }

/* ---- Modal ---- */
.fd-modal { position: fixed; inset: 0; background: rgba(28, 16, 52, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.fd-modal-box { background: #fff; border-radius: 22px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 30px 80px rgba(20, 10, 40, .35); }
.fd-modal-box h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.fd-steps { list-style: none; counter-reset: s; margin: 16px 0; padding: 0; display: grid; gap: 12px; }
.fd-steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; font-size: 14px; line-height: 1.5; }
.fd-steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--fd-soft); color: #4c1d95; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.fd-msg { margin-top: 12px; padding: 11px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.fd-msg.err { background: #fdecec; color: #a12121; }
.fd-msg.ok { background: #e9f7ef; color: #16653a; }
.fd-msg.info { background: #fff6e6; color: #8a5300; }

@media (max-width: 960px) {
  .fd-editor { grid-template-columns: minmax(0, 1fr); }
  .fd-side { position: static; max-height: none; overflow: visible; }
  .fd-mtop { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: #fff; border: 1px solid var(--fd-line); border-radius: 16px; padding: 10px 12px; margin-bottom: 10px; position: sticky; top: 72px; z-index: 5; }
  .fd-mtop span { font-size: 13px; color: var(--fd-muted); }
  .fd-mtop .fd-btn { padding: 9px 14px; font-size: 13.5px; }
}
@media (max-width: 640px) {
  .fd-brief { padding: 16px; border-radius: 18px; }
  .fd-row { grid-template-columns: 1fr; }
  .fd-canvas { padding: 10px; border-radius: 16px; }
  .fd-card { padding: 14px; }
  .fd-title-input { font-size: 21px; }
  .fd-q-top { flex-direction: column; align-items: stretch; }
  .fd-q-title { width: 100%; flex: none; }
  .fd-mtop span { font-size: 12px; }
  .fd-mtop .fd-btn { white-space: nowrap; padding: 9px 12px; font-size: 13px; }
  .fd-opt select { max-width: 112px; }
  .fd-q-type { max-width: none; width: 100%; }
  .fd-grid { grid-template-columns: 1fr; }
}
