DANGDOCAO commited on
Commit
bab94a3
·
verified ·
1 Parent(s): 6684e94
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ HVU_QA/frontend/HVU.png filter=lfs diff=lfs merge=lfs -text
HVU_QA/backend/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .app import create_app
2
+
3
+ __all__ = ["create_app"]
HVU_QA/backend/app.py ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import time
5
+ from pathlib import Path
6
+
7
+ from flask import Flask, jsonify, request, send_from_directory
8
+
9
+ from generate_question import (
10
+ APP_TITLE,
11
+ QUESTION_LIMIT,
12
+ QuestionGenerator,
13
+ format_questions,
14
+ normalize_text,
15
+ parse_question_count,
16
+ resolve_model_dir,
17
+ )
18
+
19
+ IGNORED_MODEL_DIR_NAMES = {
20
+ ".git",
21
+ ".vscode",
22
+ "__pycache__",
23
+ "backend",
24
+ "frontend",
25
+ "venv",
26
+ }
27
+
28
+
29
+ def project_root() -> Path:
30
+ return Path(__file__).resolve().parents[1]
31
+
32
+
33
+ def build_generator(
34
+ model_dir: str | Path | None = None,
35
+ prefer_nested_model: bool = True,
36
+ ) -> QuestionGenerator:
37
+ root = project_root()
38
+ selected_model_dir = (
39
+ Path(model_dir).expanduser()
40
+ if model_dir is not None
41
+ else Path(os.getenv("HVU_MODEL_DIR", str(root / "t5-viet-qg-finetuned"))).expanduser()
42
+ )
43
+ if not selected_model_dir.is_absolute():
44
+ selected_model_dir = root / selected_model_dir
45
+
46
+ return QuestionGenerator(
47
+ model_dir=str(selected_model_dir),
48
+ task_prefix=os.getenv("HVU_TASK_PREFIX", "sinh câu hỏi"),
49
+ max_source_length=int(os.getenv("HVU_MAX_SOURCE_LENGTH", "512")),
50
+ max_new_tokens=int(os.getenv("HVU_MAX_NEW_TOKENS", "64")),
51
+ device=os.getenv("HVU_DEVICE", "auto"),
52
+ cpu_threads=_read_optional_int(os.getenv("HVU_CPU_THREADS")),
53
+ gpu_dtype=os.getenv("HVU_GPU_DTYPE", "auto"),
54
+ prefer_nested_model=prefer_nested_model,
55
+ )
56
+
57
+
58
+ def _read_optional_int(value: str | None) -> int | None:
59
+ if value in (None, ""):
60
+ return None
61
+ return int(value)
62
+
63
+
64
+ def _humanize_model_segment(value: str) -> str:
65
+ normalized = value.replace("_", "-")
66
+ parts: list[str] = []
67
+ for part in normalized.split("-"):
68
+ lowered = part.lower()
69
+ if not lowered:
70
+ continue
71
+ if lowered in {"t5", "qg", "qa", "hvu"}:
72
+ parts.append(lowered.upper())
73
+ elif lowered == "seq2seq":
74
+ parts.append("Seq2Seq")
75
+ elif lowered == "checkpoint":
76
+ parts.append("Checkpoint")
77
+ elif part.isdigit():
78
+ parts.append(part)
79
+ else:
80
+ parts.append(part.capitalize())
81
+ return "-".join(parts) or "Model"
82
+
83
+
84
+ def _display_model_name(meta: dict[str, object]) -> str:
85
+ raw_name = Path(str(meta.get("model_root") or meta.get("model_dir") or "model")).name
86
+ return _humanize_model_segment(raw_name)
87
+
88
+
89
+ def _model_label(relative_path: str | Path) -> str:
90
+ path = Path(relative_path)
91
+ return path.name or "model"
92
+
93
+
94
+ def _iter_model_candidates(root: Path):
95
+ for child in sorted(root.iterdir(), key=lambda path: path.name.lower()):
96
+ if not child.is_dir() or child.name.startswith(".") or child.name in IGNORED_MODEL_DIR_NAMES:
97
+ continue
98
+
99
+ if (child / "config.json").exists():
100
+ yield {"path": child, "prefer_nested_model": False}
101
+
102
+ for nested_name in ("best-model", "final-model"):
103
+ nested = child / nested_name
104
+ if nested.is_dir() and (nested / "config.json").exists():
105
+ yield {"path": nested, "prefer_nested_model": False}
106
+
107
+
108
+ def _discover_available_models(
109
+ root: Path,
110
+ active_generator: QuestionGenerator | None = None,
111
+ ) -> list[dict[str, str]]:
112
+ models: list[dict[str, str]] = []
113
+ seen_model_roots: set[str] = set()
114
+ root = root.resolve()
115
+
116
+ for candidate_info in _iter_model_candidates(root):
117
+ candidate = candidate_info["path"]
118
+ prefer_nested_model = bool(candidate_info["prefer_nested_model"])
119
+ model_key = str(candidate.resolve())
120
+ if model_key in seen_model_roots:
121
+ continue
122
+
123
+ try:
124
+ relative_candidate = candidate.resolve().relative_to(root)
125
+ except ValueError:
126
+ continue
127
+
128
+ seen_model_roots.add(model_key)
129
+ models.append(
130
+ {
131
+ "id": relative_candidate.as_posix(),
132
+ "label": _model_label(relative_candidate),
133
+ "model_root": str(candidate.resolve()),
134
+ "model_dir": str(resolve_model_dir(candidate, prefer_nested_model=False).resolve()),
135
+ "prefer_nested_model": prefer_nested_model,
136
+ }
137
+ )
138
+
139
+ if active_generator is not None:
140
+ current_root = active_generator.model_root.resolve()
141
+ current_dir = active_generator.model_dir.resolve()
142
+ exists = any(
143
+ Path(item["model_root"]).resolve() == current_root
144
+ or Path(item["model_dir"]).resolve() == current_dir
145
+ for item in models
146
+ )
147
+ if not exists:
148
+ models.append(
149
+ {
150
+ "id": current_root.as_posix(),
151
+ "label": _display_model_name(active_generator.metadata()),
152
+ "model_root": str(current_root),
153
+ "model_dir": str(current_dir),
154
+ "prefer_nested_model": False,
155
+ }
156
+ )
157
+
158
+ return models
159
+
160
+
161
+ def _selected_model_id(
162
+ app: Flask,
163
+ models: list[dict[str, str]],
164
+ active_generator: QuestionGenerator | None = None,
165
+ ) -> str:
166
+ explicit_selection = str(app.config.get("SELECTED_MODEL_ID") or "").strip()
167
+ if explicit_selection and any(item["id"] == explicit_selection for item in models):
168
+ return explicit_selection
169
+
170
+ active_generator = active_generator or _generator(app)
171
+ current_root = active_generator.model_root.resolve()
172
+ current_dir = active_generator.model_dir.resolve()
173
+
174
+ for item in models:
175
+ if Path(item["model_dir"]).resolve() == current_dir:
176
+ return item["id"]
177
+
178
+ for item in models:
179
+ if Path(item["model_root"]).resolve() == current_root:
180
+ return item["id"]
181
+
182
+ return models[0]["id"] if models else ""
183
+
184
+
185
+ def _switch_generator(app: Flask, model_id: str) -> QuestionGenerator:
186
+ available_models = _discover_available_models(app.config["PROJECT_ROOT"], _generator(app))
187
+ selected_model = next((item for item in available_models if item["id"] == model_id), None)
188
+ if selected_model is None:
189
+ raise ValueError("Model được chọn không hợp lệ hoặc chưa tồn tại trong thư mục dự án.")
190
+
191
+ current_model_id = _selected_model_id(app, available_models)
192
+ if current_model_id != model_id:
193
+ app.config["GENERATOR"] = build_generator(
194
+ selected_model["model_root"],
195
+ prefer_nested_model=bool(selected_model.get("prefer_nested_model")),
196
+ )
197
+
198
+ app.config["SELECTED_MODEL_ID"] = model_id
199
+ return _generator(app)
200
+
201
+
202
+ def _info_payload(app: Flask, active_generator: QuestionGenerator | None = None) -> dict[str, object]:
203
+ active_generator = active_generator or _generator(app)
204
+ meta = active_generator.metadata()
205
+ available_models = _discover_available_models(app.config["PROJECT_ROOT"], active_generator)
206
+ selected_model_id = _selected_model_id(app, available_models, active_generator)
207
+ model_name = next(
208
+ (item["label"] for item in available_models if item["id"] == selected_model_id),
209
+ _display_model_name(meta),
210
+ )
211
+
212
+ return {
213
+ "ok": True,
214
+ "title": APP_TITLE,
215
+ "model_name": model_name,
216
+ "selected_model_id": selected_model_id,
217
+ "available_models": [{"id": item["id"], "label": item["label"]} for item in available_models],
218
+ "meta": meta,
219
+ }
220
+
221
+
222
+ def create_app(generator: QuestionGenerator | None = None) -> Flask:
223
+ root = project_root()
224
+ frontend_root = root / "frontend"
225
+
226
+ app = Flask(__name__, static_folder=None)
227
+ app.json.ensure_ascii = False
228
+ app.config["GENERATOR"] = generator or build_generator()
229
+ app.config["PROJECT_ROOT"] = root
230
+ app.config["FRONTEND_ROOT"] = frontend_root
231
+ app.config["SELECTED_MODEL_ID"] = ""
232
+
233
+ @app.get("/")
234
+ def index():
235
+ return send_from_directory(app.config["FRONTEND_ROOT"], "index.html")
236
+
237
+ @app.get("/frontend/<path:filename>")
238
+ def frontend_file(filename: str):
239
+ return send_from_directory(app.config["FRONTEND_ROOT"], filename)
240
+
241
+ @app.get("/assets/<path:filename>")
242
+ def asset_file(filename: str):
243
+ return send_from_directory(app.config["FRONTEND_ROOT"], filename)
244
+
245
+ @app.get("/api/info")
246
+ def info():
247
+ return jsonify(_info_payload(app))
248
+
249
+ @app.post("/api/model")
250
+ def set_model():
251
+ payload = request.get_json(silent=True) or {}
252
+ model_id = str(payload.get("model_id") or "").strip()
253
+ if not model_id:
254
+ return jsonify({"ok": False, "error": "Vui lòng chọn model trước khi chuyển."}), 400
255
+
256
+ try:
257
+ active_generator = _switch_generator(app, model_id)
258
+ except ValueError as exc:
259
+ return jsonify({"ok": False, "error": str(exc)}), 404
260
+
261
+ return jsonify(_info_payload(app, active_generator))
262
+
263
+ @app.post("/api/generate")
264
+ def generate():
265
+ payload = request.get_json(silent=True) or {}
266
+ requested_model_id = str(payload.get("model_id") or "").strip()
267
+
268
+ if requested_model_id:
269
+ try:
270
+ active_generator = _switch_generator(app, requested_model_id)
271
+ except ValueError as exc:
272
+ return jsonify({"ok": False, "error": str(exc)}), 400
273
+ else:
274
+ active_generator = _generator(app)
275
+
276
+ text = normalize_text(payload.get("text"))
277
+ if not text:
278
+ return jsonify({"ok": False, "error": "Vui lòng nhập đoạn văn bản trước khi sinh câu hỏi."}), 400
279
+
280
+ raw_count = payload.get("num_questions")
281
+ if raw_count in (None, ""):
282
+ count = 100
283
+ else:
284
+ try:
285
+ count = int(raw_count)
286
+ except (TypeError, ValueError):
287
+ return jsonify({"ok": False, "error": "Số câu hỏi phải là số nguyên trong khoảng 1 đến 100."}), 400
288
+
289
+ if count < 1 or count > QUESTION_LIMIT:
290
+ return jsonify({"ok": False, "error": f"Số câu hỏi phải nằm trong khoảng 1 đến {QUESTION_LIMIT}."}), 400
291
+
292
+ started = time.perf_counter()
293
+ try:
294
+ questions = active_generator.generate(text, parse_question_count(count))
295
+ except Exception as exc: # noqa: BLE001
296
+ return jsonify({"ok": False, "error": str(exc)}), 500
297
+
298
+ elapsed_ms = round((time.perf_counter() - started) * 1000, 2)
299
+ info_payload = _info_payload(app, active_generator)
300
+ return jsonify(
301
+ {
302
+ "ok": True,
303
+ "text": text,
304
+ "num_questions": count,
305
+ "questions": questions,
306
+ "formatted": format_questions(questions),
307
+ "elapsed_ms": elapsed_ms,
308
+ "model_name": info_payload["model_name"],
309
+ "selected_model_id": info_payload["selected_model_id"],
310
+ "meta": active_generator.metadata(),
311
+ }
312
+ )
313
+
314
+ return app
315
+
316
+
317
+ def _generator(app: Flask) -> QuestionGenerator:
318
+ generator: QuestionGenerator = app.config["GENERATOR"]
319
+ return generator
HVU_QA/frontend/HVU.png ADDED

Git LFS Details

  • SHA256: 79c74bf899cb310e3583d67478e9dab811354cf053bc1bdc9d1b8b0819f0af31
  • Pointer size: 131 Bytes
  • Size of remote file: 270 kB
HVU_QA/frontend/app.js ADDED
@@ -0,0 +1,1233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const STORAGE_KEY = "hvu_qa_history_v1";
2
+ const QUESTION_COUNT_LIMITS = { min: 0, max: 100, default: 0 };
3
+ const SAMPLE_SNIPPETS = [
4
+ {
5
+ id: "luat-giao-duc-dai-hoc",
6
+ title: "Luật Giáo dục đại học",
7
+ preview: "Quy định về cơ sở giáo dục đại học, chương trình đào tạo và quyền tự chủ.",
8
+ text: "Cơ sở giáo dục đại học có nhiệm vụ tổ chức hoạt động đào tạo, nghiên cứu khoa học, hợp tác quốc tế và phục vụ cộng đồng theo quy định của pháp luật. Cơ sở giáo dục đại học được thực hiện quyền tự chủ gắn với trách nhiệm giải trình, bảo đảm chất lượng đào tạo, công khai điều kiện bảo đảm chất lượng và kết quả hoạt động với cơ quan quản lý nhà nước, người học và xã hội.",
9
+ suggestedCount: 5,
10
+ },
11
+ {
12
+ id: "bo-luat-lao-dong",
13
+ title: "Bộ luật Lao động",
14
+ preview: "Nội dung về hợp đồng lao động, quyền và nghĩa vụ của người lao động.",
15
+ text: "Hợp đồng lao động là sự thỏa thuận giữa người lao động và người sử dụng lao động về việc làm có trả công, tiền lương, điều kiện lao động, quyền và nghĩa vụ của mỗi bên. Khi giao kết hợp đồng lao động, các bên phải tuân thủ nguyên tắc tự nguyện, bình đẳng, thiện chí, hợp tác và trung thực; không được thỏa thuận nội dung làm giảm quyền lợi của người lao động so với quy định của pháp luật.",
16
+ suggestedCount: 4,
17
+ },
18
+ {
19
+ id: "luat-an-toan-thong-tin-mang",
20
+ title: "Luật An toàn thông tin mạng",
21
+ preview: "Yêu cầu bảo vệ thông tin, phòng ngừa rủi ro và trách nhiệm của tổ chức, cá nhân.",
22
+ text: "Cơ quan, tổ chức, cá nhân tham gia hoạt động trên môi trường mạng có trách nhiệm bảo đảm an toàn thông tin mạng; áp dụng biện pháp quản lý, kỹ thuật phù hợp để phòng ngừa, phát hiện, ngăn chặn và xử lý nguy cơ mất an toàn thông tin. Việc thu thập, xử lý và sử dụng thông tin trên môi trường mạng phải đúng mục đích, đúng thẩm quyền và bảo đảm quyền, lợi ích hợp pháp của cơ quan, tổ chức, cá nhân có liên quan.",
23
+ suggestedCount: 5,
24
+ },
25
+ ];
26
+ const AUTHOR_PROFILES = [
27
+ {
28
+ id: "do-cao-dang",
29
+ name: "Đỗ Cao Đăng",
30
+ role: "Sinh viên thực hiện",
31
+ summary: "Thành viên nhóm thực hiện đề tài.",
32
+ description: "Sinh viên tham gia triển khai và hoàn thiện hệ thống.",
33
+ unit: "Khoa Kỹ thuật - Công nghệ",
34
+ email: "docaodang532001@gmail.com",
35
+ },
36
+ {
37
+ id: "hoang-tuan-ngoc",
38
+ name: "Hoàng Tuấn Ngọc",
39
+ role: "Sinh viên thực hiện",
40
+ summary: "Thành viên nhóm thực hiện đề tài.",
41
+ description: "Sinh viên đồng thực hiện và phối hợp phát triển nội dung cho hệ thống.",
42
+ unit: "Khoa Kỹ thuật - Công nghệ",
43
+ email: "hoangtuanngoc2005@gmail.com",
44
+ },
45
+ {
46
+ id: "nguyen-tien-ha",
47
+ name: "TS. Nguyễn Tiến Hà",
48
+ role: "Giảng viên hướng dẫn",
49
+ summary: "Giảng viên hướng dẫn chuyên môn cho đề tài.",
50
+ description: "Giảng viên hướng dẫn học thuật và định hướng chuyên môn cho đề tài.",
51
+ unit: "Khoa Kỹ thuật - Công nghệ",
52
+ email: "nguyentienha@hvu.edu.vn",
53
+ },
54
+ ];
55
+
56
+ const state = {
57
+ history: loadHistory(),
58
+ selectedId: null,
59
+ thread: [],
60
+ availableModels: [],
61
+ activeModelId: "",
62
+ isSwitchingModel: false,
63
+ selectedAuthorId: null,
64
+ isAuthorPanelOpen: false,
65
+ };
66
+
67
+ const voiceState = {
68
+ isSupported: false,
69
+ isListening: false,
70
+ recognition: null,
71
+ discardOnStop: false,
72
+ stopRequested: false,
73
+ baseText: "",
74
+ finalTranscript: "",
75
+ interimTranscript: "",
76
+ lastErrorMessage: "",
77
+ };
78
+
79
+ const elements = {
80
+ menuToggle: document.getElementById("menuToggle"),
81
+ sidebarContent: document.getElementById("sidebarContent"),
82
+ modelSelect: document.getElementById("modelSelect"),
83
+ deviceStatus: document.getElementById("deviceStatus"),
84
+ modelStatus: document.getElementById("modelStatus"),
85
+ historyList: document.getElementById("historyList"),
86
+ clearHistory: document.getElementById("clearHistory"),
87
+ resultCard: document.getElementById("resultCard"),
88
+ form: document.getElementById("generatorForm"),
89
+ sourceShell: document.getElementById("sourceShell"),
90
+ sourceText: document.getElementById("sourceText"),
91
+ voiceInputButton: document.getElementById("voiceInputButton"),
92
+ voiceStatus: document.getElementById("voiceStatus"),
93
+ questionCount: document.getElementById("questionCount"),
94
+ questionCountValue: document.getElementById("questionCountValue"),
95
+ decreaseCount: document.getElementById("decreaseCount"),
96
+ increaseCount: document.getElementById("increaseCount"),
97
+ generateButton: document.getElementById("generateButton"),
98
+ authorToggle: document.getElementById("authorToggle"),
99
+ authorContent: document.getElementById("authorContent"),
100
+ authorList: document.getElementById("authorList"),
101
+ copyrightLine: document.getElementById("copyrightLine"),
102
+ heroTitle: document.getElementById("heroTitle"),
103
+ landingPanel: document.getElementById("landingPanel"),
104
+ sampleList: document.getElementById("sampleList"),
105
+ landingRuntimeBadge: document.getElementById("landingRuntimeBadge"),
106
+ landingStatusText: document.getElementById("landingStatusText"),
107
+ landingModelName: document.getElementById("landingModelName"),
108
+ landingDeviceName: document.getElementById("landingDeviceName"),
109
+ landingModelCount: document.getElementById("landingModelCount"),
110
+ };
111
+
112
+ bootstrap();
113
+
114
+ function bootstrap() {
115
+ hydrateQuestionCount();
116
+ syncSidebar(false);
117
+ renderHistory();
118
+ renderAuthors();
119
+ renderLandingSamples();
120
+ attachEvents();
121
+ hideResultCard();
122
+ activateHeroTitle();
123
+ syncCopyright();
124
+ autoResizeTextarea();
125
+ initVoiceInput();
126
+ syncLandingPanel();
127
+ fetchInfo();
128
+ }
129
+
130
+ function hydrateQuestionCount() {
131
+ syncQuestionCount(elements.questionCount.value);
132
+ }
133
+
134
+ function attachEvents() {
135
+ elements.menuToggle.addEventListener("click", () => {
136
+ syncSidebar(!document.body.classList.contains("sidebar-open"));
137
+ });
138
+
139
+ document.addEventListener("keydown", (event) => {
140
+ if (event.key === "Escape" && document.body.classList.contains("sidebar-open")) {
141
+ syncSidebar(false);
142
+ }
143
+ });
144
+
145
+ elements.clearHistory.addEventListener("click", () => {
146
+ stopVoiceInput(true);
147
+ state.history = [];
148
+ state.selectedId = null;
149
+ state.thread = [];
150
+ persistHistory();
151
+ renderHistory();
152
+ hideResultCard();
153
+ });
154
+
155
+ elements.historyList.addEventListener("click", (event) => {
156
+ const button = event.target.closest("[data-history-id]");
157
+ if (!button) return;
158
+
159
+ stopVoiceInput(true);
160
+
161
+ const entry = state.history.find((item) => item.id === button.dataset.historyId);
162
+ if (!entry) return;
163
+
164
+ state.selectedId = entry.id;
165
+ state.thread = [entry];
166
+ elements.sourceText.value = entry.text || entry.title || "";
167
+ autoResizeTextarea();
168
+ renderHistory();
169
+ renderThread();
170
+ });
171
+
172
+ elements.resultCard.addEventListener("click", async (event) => {
173
+ const button = event.target.closest("[data-copy-entry-id][data-copy-target]");
174
+ if (!button) return;
175
+
176
+ const entryId = button.dataset.copyEntryId;
177
+ const target = button.dataset.copyTarget;
178
+ const textToCopy = buildCopyText(entryId, target);
179
+ if (!textToCopy) return;
180
+
181
+ const copied = await copyToClipboard(textToCopy);
182
+ if (!copied) return;
183
+
184
+ button.classList.add("is-copied");
185
+ button.setAttribute("aria-label", "Đã sao chép");
186
+ window.setTimeout(() => {
187
+ button.classList.remove("is-copied");
188
+ button.setAttribute("aria-label", "Sao chép");
189
+ }, 1400);
190
+ });
191
+
192
+ elements.sourceText.addEventListener("input", () => {
193
+ autoResizeTextarea();
194
+ });
195
+
196
+ elements.sampleList?.addEventListener("click", (event) => {
197
+ const button = event.target.closest("[data-sample-id]");
198
+ if (!button) return;
199
+
200
+ const sample = SAMPLE_SNIPPETS.find((item) => item.id === button.dataset.sampleId);
201
+ if (!sample) return;
202
+
203
+ stopVoiceInput(true);
204
+ elements.sourceText.value = sample.text;
205
+ if (Number(elements.questionCount.value || QUESTION_COUNT_LIMITS.default) <= 0) {
206
+ syncQuestionCount(sample.suggestedCount || 5);
207
+ }
208
+ autoResizeTextarea();
209
+ elements.sourceText.focus();
210
+ });
211
+
212
+ elements.voiceInputButton.addEventListener("click", () => {
213
+ toggleVoiceInput();
214
+ });
215
+
216
+ elements.modelSelect.addEventListener("change", () => {
217
+ const nextModelId = String(elements.modelSelect.value || "").trim();
218
+ if (!nextModelId || nextModelId === state.activeModelId || state.isSwitchingModel) {
219
+ return;
220
+ }
221
+ switchModel(nextModelId);
222
+ });
223
+
224
+ elements.authorToggle?.addEventListener("click", () => {
225
+ state.isAuthorPanelOpen = !state.isAuthorPanelOpen;
226
+ renderAuthors();
227
+ });
228
+
229
+ elements.authorList?.addEventListener("click", (event) => {
230
+ const button = event.target.closest("[data-author-id]");
231
+ if (!button) return;
232
+ selectAuthor(button.dataset.authorId);
233
+ });
234
+
235
+ elements.decreaseCount.addEventListener("click", () => {
236
+ syncQuestionCount(Number(elements.questionCount.value || QUESTION_COUNT_LIMITS.default) - 1);
237
+ });
238
+
239
+ elements.increaseCount.addEventListener("click", () => {
240
+ syncQuestionCount(Number(elements.questionCount.value || QUESTION_COUNT_LIMITS.default) + 1);
241
+ });
242
+
243
+ elements.form.addEventListener("submit", async (event) => {
244
+ event.preventDefault();
245
+
246
+ if (state.isSwitchingModel) {
247
+ renderMessage("Vui lòng chờ chuyển model xong rồi thử lại.");
248
+ return;
249
+ }
250
+
251
+ if (voiceState.isListening) {
252
+ renderMessage("Vui lòng dừng micro trước khi sinh câu hỏi.");
253
+ return;
254
+ }
255
+
256
+ const text = elements.sourceText.value.trim();
257
+ const numQuestions = Number(elements.questionCount.value || String(QUESTION_COUNT_LIMITS.default));
258
+
259
+ if (!text) {
260
+ renderMessage("Vui lòng nhập đoạn văn bản trước khi sinh câu hỏi.");
261
+ elements.sourceText.focus();
262
+ return;
263
+ }
264
+
265
+ if (numQuestions <= 0) {
266
+ renderMessage("Vui lòng tăng số câu hỏi lên ít nhất 1.");
267
+ elements.increaseCount.focus();
268
+ return;
269
+ }
270
+
271
+ const pendingEntry = {
272
+ id: makeId(),
273
+ title: shrink(text, 52),
274
+ text,
275
+ questions: [],
276
+ elapsedMs: null,
277
+ device: null,
278
+ count: numQuestions,
279
+ createdAt: new Date().toISOString(),
280
+ status: "pending",
281
+ errorMessage: "",
282
+ };
283
+
284
+ state.thread = [...state.thread, pendingEntry];
285
+ renderThread();
286
+ elements.sourceText.value = "";
287
+ autoResizeTextarea();
288
+
289
+ setLoading(true);
290
+
291
+ try {
292
+ const response = await fetch("/api/generate", {
293
+ method: "POST",
294
+ headers: { "Content-Type": "application/json" },
295
+ body: JSON.stringify({
296
+ model_id: state.activeModelId || undefined,
297
+ text,
298
+ num_questions: numQuestions,
299
+ }),
300
+ });
301
+ const payload = await response.json();
302
+
303
+ if (!response.ok || !payload.ok) {
304
+ throw new Error(payload.error || "Không thể sinh câu hỏi lúc này.");
305
+ }
306
+
307
+ const entry = {
308
+ id: pendingEntry.id,
309
+ title: shrink(text, 52),
310
+ text: payload.text,
311
+ questions: payload.questions,
312
+ elapsedMs: payload.elapsed_ms,
313
+ device: payload.meta.active_device || payload.meta.predicted_device,
314
+ count: payload.questions?.length || numQuestions,
315
+ createdAt: pendingEntry.createdAt,
316
+ status: "done",
317
+ errorMessage: "",
318
+ };
319
+
320
+ state.selectedId = entry.id;
321
+ state.history = [entry, ...state.history.filter((item) => item.questions?.length)].slice(0, 10);
322
+ state.thread = state.thread.map((item) => (item.id === pendingEntry.id ? entry : item));
323
+ persistHistory();
324
+ renderHistory();
325
+ renderThread();
326
+ } catch (error) {
327
+ state.thread = state.thread.map((item) =>
328
+ item.id === pendingEntry.id
329
+ ? {
330
+ ...item,
331
+ status: "error",
332
+ errorMessage: error.message || "Có lỗi xảy ra khi sinh câu hỏi.",
333
+ }
334
+ : item,
335
+ );
336
+ renderThread();
337
+ } finally {
338
+ setLoading(false);
339
+ }
340
+ });
341
+ }
342
+
343
+ function syncQuestionCount(value) {
344
+ const parsedValue = Number(value);
345
+ const normalizedValue = Number.isFinite(parsedValue) ? Math.trunc(parsedValue) : QUESTION_COUNT_LIMITS.default;
346
+ const safeValue = Math.min(
347
+ QUESTION_COUNT_LIMITS.max,
348
+ Math.max(QUESTION_COUNT_LIMITS.min, normalizedValue),
349
+ );
350
+ const isLoading = isInterfaceBusy();
351
+
352
+ elements.questionCount.value = String(safeValue);
353
+ elements.questionCountValue.textContent = String(safeValue);
354
+ elements.decreaseCount.disabled = isLoading || safeValue <= QUESTION_COUNT_LIMITS.min;
355
+ elements.increaseCount.disabled = isLoading || safeValue >= QUESTION_COUNT_LIMITS.max;
356
+ }
357
+
358
+ function syncSidebar(isOpen) {
359
+ document.body.classList.toggle("sidebar-open", isOpen);
360
+ elements.menuToggle.setAttribute("aria-expanded", String(isOpen));
361
+ elements.sidebarContent.setAttribute("aria-hidden", String(!isOpen));
362
+ }
363
+
364
+ function initVoiceInput() {
365
+ const SpeechRecognitionApi = window.SpeechRecognition || window.webkitSpeechRecognition;
366
+
367
+ if (!SpeechRecognitionApi) {
368
+ voiceState.isSupported = false;
369
+ syncVoiceUi(buildVoiceUnsupportedMessage(), "error");
370
+ return;
371
+ }
372
+
373
+ if (!canUseBrowserVoiceInput()) {
374
+ voiceState.isSupported = false;
375
+ syncVoiceUi(buildVoiceOriginMessage(), "error");
376
+ return;
377
+ }
378
+
379
+ voiceState.recognition = createSpeechRecognition(SpeechRecognitionApi);
380
+ voiceState.isSupported = true;
381
+ syncVoiceUi("");
382
+ }
383
+
384
+ function toggleVoiceInput() {
385
+ if (!voiceState.isSupported) {
386
+ syncVoiceUi(
387
+ canUseBrowserVoiceInput() ? buildVoiceUnsupportedMessage() : buildVoiceOriginMessage(),
388
+ "error",
389
+ );
390
+ return;
391
+ }
392
+
393
+ if (voiceState.isListening) {
394
+ stopVoiceInput(false);
395
+ return;
396
+ }
397
+
398
+ startVoiceInput();
399
+ }
400
+
401
+ function startVoiceInput() {
402
+ if (!voiceState.recognition) {
403
+ syncVoiceUi(buildVoiceUnsupportedMessage(), "error");
404
+ return;
405
+ }
406
+
407
+ try {
408
+ voiceState.baseText = elements.sourceText.value.trimEnd();
409
+ voiceState.finalTranscript = "";
410
+ voiceState.interimTranscript = "";
411
+ voiceState.discardOnStop = false;
412
+ voiceState.stopRequested = false;
413
+ voiceState.lastErrorMessage = "";
414
+ syncVoiceUi("Đang bật nhận giọng nói...");
415
+ voiceState.recognition.start();
416
+ } catch (error) {
417
+ voiceState.discardOnStop = false;
418
+ syncVoiceUi(humanizeVoiceStartError(error), "error");
419
+ }
420
+ }
421
+
422
+ function stopVoiceInput(discardRecording = false) {
423
+ if (!voiceState.isListening || !voiceState.recognition) {
424
+ return;
425
+ }
426
+
427
+ voiceState.discardOnStop = Boolean(discardRecording);
428
+ voiceState.stopRequested = true;
429
+
430
+ if (discardRecording) {
431
+ voiceState.finalTranscript = "";
432
+ voiceState.interimTranscript = "";
433
+ elements.sourceText.value = voiceState.baseText;
434
+ autoResizeTextarea();
435
+ }
436
+
437
+ syncVoiceUi(discardRecording ? "Đang hủy nhận giọng nói..." : "Đang dừng micro...");
438
+ voiceState.recognition.stop();
439
+ }
440
+
441
+ function createSpeechRecognition(SpeechRecognitionApi) {
442
+ const recognition = new SpeechRecognitionApi();
443
+ recognition.lang = "vi-VN";
444
+ recognition.continuous = true;
445
+ recognition.interimResults = true;
446
+ recognition.maxAlternatives = 1;
447
+
448
+ recognition.onstart = () => {
449
+ voiceState.isListening = true;
450
+ voiceState.stopRequested = false;
451
+ voiceState.lastErrorMessage = "";
452
+ syncVoiceUi("Đang nghe... hãy nói vào micro.");
453
+ };
454
+
455
+ recognition.onresult = (event) => {
456
+ if (voiceState.discardOnStop) {
457
+ return;
458
+ }
459
+
460
+ let nextFinalTranscript = "";
461
+ let nextInterimTranscript = "";
462
+
463
+ for (let index = event.resultIndex; index < event.results.length; index += 1) {
464
+ const transcript = String(event.results[index][0]?.transcript || "").trim();
465
+ if (!transcript) continue;
466
+
467
+ if (event.results[index].isFinal) {
468
+ nextFinalTranscript = appendSpeechChunk(nextFinalTranscript, transcript);
469
+ } else {
470
+ nextInterimTranscript = appendSpeechChunk(nextInterimTranscript, transcript);
471
+ }
472
+ }
473
+
474
+ if (nextFinalTranscript) {
475
+ voiceState.finalTranscript = appendSpeechChunk(voiceState.finalTranscript, nextFinalTranscript);
476
+ }
477
+
478
+ voiceState.interimTranscript = nextInterimTranscript;
479
+ syncSpeechDraft();
480
+ syncVoiceUi("Đang nghe... bấm lại nếu muốn dừng.");
481
+ };
482
+
483
+ recognition.onerror = (event) => {
484
+ console.warn("SpeechRecognition error:", event.error);
485
+
486
+ if (event.error === "aborted" && (voiceState.discardOnStop || voiceState.stopRequested)) {
487
+ voiceState.lastErrorMessage = "";
488
+ return;
489
+ }
490
+
491
+ voiceState.lastErrorMessage = humanizeVoiceRecognitionError(event.error);
492
+ };
493
+
494
+ recognition.onend = () => {
495
+ const shouldDiscard = voiceState.discardOnStop;
496
+ const recognizedText = appendSpeechChunk(voiceState.finalTranscript, voiceState.interimTranscript);
497
+ const hasRecognizedText = Boolean(recognizedText.trim());
498
+
499
+ voiceState.isListening = false;
500
+
501
+ if (!shouldDiscard && hasRecognizedText) {
502
+ elements.sourceText.value = appendSpeechChunk(voiceState.baseText, recognizedText);
503
+ autoResizeTextarea();
504
+ }
505
+
506
+ let finalMessage = "";
507
+ let finalTone = "default";
508
+
509
+ if (voiceState.lastErrorMessage) {
510
+ finalMessage = voiceState.lastErrorMessage;
511
+ finalTone = "error";
512
+ } else if (!shouldDiscard && hasRecognizedText) {
513
+ finalMessage = "Đã chèn nội dung giọng nói vào ô nhập.";
514
+ } else if (!shouldDiscard && !voiceState.stopRequested) {
515
+ finalMessage = "Không nhận diện được nội dung giọng nói. Hãy thử lại.";
516
+ finalTone = "error";
517
+ }
518
+
519
+ voiceState.discardOnStop = false;
520
+ voiceState.stopRequested = false;
521
+ voiceState.finalTranscript = "";
522
+ voiceState.interimTranscript = "";
523
+ voiceState.lastErrorMessage = "";
524
+ voiceState.baseText = elements.sourceText.value.trimEnd();
525
+
526
+ syncVoiceUi(finalMessage, finalTone);
527
+ };
528
+
529
+ return recognition;
530
+ }
531
+
532
+ function appendSpeechChunk(base, chunk) {
533
+ const normalizedBase = String(base || "");
534
+ const normalizedChunk = String(chunk || "").trim();
535
+
536
+ if (!normalizedChunk) return normalizedBase;
537
+ if (!normalizedBase.trim()) return normalizedChunk;
538
+
539
+ return /[\s(]$/.test(normalizedBase) ? `${normalizedBase}${normalizedChunk}` : `${normalizedBase} ${normalizedChunk}`;
540
+ }
541
+
542
+ function humanizeVoiceStartError(error) {
543
+ const errorName = error?.name || "";
544
+
545
+ if (errorName === "InvalidStateError") {
546
+ return "Micro đang hoạt động. Hãy dừng phiên hiện tại trước khi bật lại.";
547
+ }
548
+
549
+ if (errorName === "NotAllowedError" || errorName === "SecurityError") {
550
+ if (!canUseBrowserVoiceInput()) {
551
+ return buildVoiceOriginMessage();
552
+ }
553
+ return "Bạn chưa cấp quyền micro cho trình duyệt.";
554
+ }
555
+
556
+ if (errorName === "NotFoundError" || errorName === "DevicesNotFoundError") {
557
+ return "Không tìm thấy thiết bị micro.";
558
+ }
559
+
560
+ return "Không thể bật nhận giọng nói lúc này. Hãy thử lại.";
561
+ }
562
+
563
+ function humanizeVoiceRecognitionError(errorCode) {
564
+ if (errorCode === "not-allowed" || errorCode === "service-not-allowed") {
565
+ if (!canUseBrowserVoiceInput()) {
566
+ return buildVoiceOriginMessage();
567
+ }
568
+ return "Bạn chưa cấp quyền micro hoặc nhận giọng nói cho trình duyệt.";
569
+ }
570
+
571
+ if (errorCode === "audio-capture") {
572
+ return "Không tìm thấy micro hoặc micro đang bị chiếm dụng.";
573
+ }
574
+
575
+ if (errorCode === "network") {
576
+ if (!navigator.onLine) {
577
+ return "Thiết bị đang offline. Hãy kết nối Internet rồi thử lại.";
578
+ }
579
+
580
+ if (!canUseBrowserVoiceInput()) {
581
+ return buildVoiceOriginMessage();
582
+ }
583
+
584
+ return "Trình duyệt không kết nối được dịch vụ nhận giọng nói. Hãy dùng Chrome hoặc Edge, kiểm tra mạng, VPN hay firewall rồi thử lại.";
585
+ }
586
+
587
+ if (errorCode === "language-not-supported") {
588
+ return "Trình duyệt không hỗ trợ nhận giọng nói tiếng Việt.";
589
+ }
590
+
591
+ if (errorCode === "no-speech") {
592
+ return "Không nghe thấy giọng nói. Hãy thử nói gần micro hơn.";
593
+ }
594
+
595
+ return "Không thể nhận giọng nói lúc này. Hãy thử lại.";
596
+ }
597
+
598
+ function canUseBrowserVoiceInput() {
599
+ return window.isSecureContext || isLocalhost(window.location.hostname);
600
+ }
601
+
602
+ function isLocalhost(hostname) {
603
+ return (
604
+ hostname === "localhost" ||
605
+ hostname.endsWith(".localhost") ||
606
+ hostname === "127.0.0.1" ||
607
+ hostname === "::1" ||
608
+ hostname === "[::1]"
609
+ );
610
+ }
611
+
612
+ function buildVoiceUnsupportedMessage() {
613
+ return "Trình duyệt này chưa hỗ trợ nhập giọng nói trực tiếp. Hãy dùng Chrome hoặc Edge bản mới.";
614
+ }
615
+
616
+ function buildVoiceOriginMessage() {
617
+ return "Nhập bằng giọng nói qua trình duyệt chỉ hoạt động trên HTTPS hoặc localhost. Hãy mở ứng dụng bằng https:// hoặc http://localhost.";
618
+ }
619
+
620
+ function syncSpeechDraft() {
621
+ const stableText = appendSpeechChunk(voiceState.baseText, voiceState.finalTranscript);
622
+ elements.sourceText.value = appendSpeechChunk(stableText, voiceState.interimTranscript);
623
+ autoResizeTextarea();
624
+ }
625
+
626
+ function syncVoiceUi(message, tone = "default") {
627
+ const resolvedMessage = String(message || "").trim();
628
+
629
+ elements.voiceStatus.textContent = resolvedMessage;
630
+ elements.voiceStatus.classList.toggle("is-empty", !resolvedMessage);
631
+ elements.voiceStatus.classList.toggle("is-error", tone === "error");
632
+ elements.voiceStatus.classList.toggle("is-active", voiceState.isListening);
633
+ elements.voiceInputButton.disabled = !voiceState.isSupported;
634
+ elements.voiceInputButton.classList.toggle("is-listening", voiceState.isListening);
635
+ elements.voiceInputButton.classList.toggle("is-unsupported", !voiceState.isSupported);
636
+ elements.voiceInputButton.setAttribute(
637
+ "aria-label",
638
+ voiceState.isListening ? "Dừng nhận giọng nói" : "Nhập bằng giọng nói qua trình duyệt",
639
+ );
640
+ }
641
+
642
+ function autoResizeTextarea() {
643
+ const collapsedHeight = 30;
644
+ const expandedMinHeight = 86;
645
+ const hasContent = elements.sourceText.value.trim().length > 0;
646
+
647
+ elements.sourceText.style.height = `${collapsedHeight}px`;
648
+ const nextHeight = Math.min(elements.sourceText.scrollHeight, 240);
649
+ elements.sourceText.style.height = `${Math.max(nextHeight, hasContent ? expandedMinHeight : collapsedHeight)}px`;
650
+ elements.sourceShell.classList.toggle("is-expanded", hasContent || nextHeight > collapsedHeight + 4);
651
+ }
652
+
653
+ function loadHistory() {
654
+ try {
655
+ const saved = window.localStorage.getItem(STORAGE_KEY);
656
+ if (!saved) {
657
+ return [];
658
+ }
659
+
660
+ const parsed = JSON.parse(saved);
661
+ if (!Array.isArray(parsed)) return [];
662
+
663
+ return parsed
664
+ .map((item) => ({
665
+ ...item,
666
+ id: item.id || makeId(),
667
+ createdAt: item.createdAt || new Date().toISOString(),
668
+ }))
669
+ .filter((item) => Array.isArray(item.questions) && item.questions.length > 0);
670
+ } catch {
671
+ return [];
672
+ }
673
+ }
674
+
675
+ function persistHistory() {
676
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify(state.history));
677
+ }
678
+
679
+ async function fetchInfo() {
680
+ try {
681
+ const response = await fetch("/api/info");
682
+ const payload = await response.json();
683
+
684
+ if (!response.ok || !payload.ok) {
685
+ throw new Error(payload.error || "Không đọc được thông tin hệ thống.");
686
+ }
687
+
688
+ applySystemInfo(payload);
689
+ } catch (error) {
690
+ state.availableModels = [];
691
+ state.activeModelId = "";
692
+ renderModelOptions("Không tải được danh sách model.");
693
+ elements.deviceStatus.textContent = "Không kết nối được backend.";
694
+ elements.modelStatus.textContent = error.message || "Vui lòng kiểm tra lại backend hoặc server Flask.";
695
+ syncLandingStatus({
696
+ modelName: "Không tải được danh sách model",
697
+ deviceName: "Chưa kết nối backend",
698
+ modelCount: 0,
699
+ badgeText: "Lỗi kết nối",
700
+ badgeTone: "error",
701
+ statusText: error.message || "Không thể đọc thông tin hệ thống từ backend.",
702
+ });
703
+ }
704
+ }
705
+
706
+ async function switchModel(modelId) {
707
+ const previousModelId = state.activeModelId;
708
+
709
+ state.isSwitchingModel = true;
710
+ syncInteractiveControls();
711
+ elements.modelStatus.textContent = "Đang chuyển model...";
712
+ syncLandingStatus({
713
+ modelName: state.availableModels.find((item) => item.id === modelId)?.label || "Đang chuyển model...",
714
+ deviceName: elements.deviceStatus.textContent || "Đang kiểm tra...",
715
+ modelCount: state.availableModels.length,
716
+ badgeText: "Đang chuyển",
717
+ badgeTone: "pending",
718
+ statusText: "Hệ thống đang chuyển model theo lựa chọn của bạn.",
719
+ });
720
+
721
+ try {
722
+ const response = await fetch("/api/model", {
723
+ method: "POST",
724
+ headers: { "Content-Type": "application/json" },
725
+ body: JSON.stringify({ model_id: modelId }),
726
+ });
727
+ const payload = await response.json();
728
+
729
+ if (!response.ok || !payload.ok) {
730
+ throw new Error(payload.error || "Không thể chuyển model lúc này.");
731
+ }
732
+
733
+ applySystemInfo(payload);
734
+ } catch (error) {
735
+ state.activeModelId = previousModelId;
736
+ renderModelOptions();
737
+ elements.modelStatus.textContent = error.message || "Không thể chuyển model lúc này.";
738
+ syncLandingStatus({
739
+ modelName:
740
+ state.availableModels.find((item) => item.id === previousModelId)?.label
741
+ || state.availableModels[0]?.label
742
+ || "Không xác định",
743
+ deviceName: elements.deviceStatus.textContent || "Đang kiểm tra...",
744
+ modelCount: state.availableModels.length,
745
+ badgeText: "Lỗi chuyển model",
746
+ badgeTone: "error",
747
+ statusText: error.message || "Không thể chuyển model lúc này.",
748
+ });
749
+ } finally {
750
+ state.isSwitchingModel = false;
751
+ syncInteractiveControls();
752
+ }
753
+ }
754
+
755
+ function applySystemInfo(payload) {
756
+ const availableModels = Array.isArray(payload.available_models) ? payload.available_models : [];
757
+ const fallbackModelId = String(payload.selected_model_id || payload.model_name || "default-model");
758
+ const fallbackModelLabel = String(payload.model_name || "Model hiện tại");
759
+
760
+ state.availableModels = availableModels.length
761
+ ? availableModels
762
+ : [{ id: fallbackModelId, label: fallbackModelLabel }];
763
+ state.activeModelId = String(payload.selected_model_id || state.availableModels[0]?.id || "");
764
+ renderModelOptions();
765
+
766
+ const activeModel =
767
+ state.availableModels.find((item) => item.id === state.activeModelId)?.label || payload.model_name || "Model";
768
+
769
+ elements.deviceStatus.textContent = humanizeDevice(payload.meta.active_device || payload.meta.predicted_device);
770
+ elements.modelStatus.textContent = payload.meta.loaded
771
+ ? `${activeModel} đã sẵn sàng cho tác vụ sinh câu hỏi.`
772
+ : `Đã chọn ${activeModel}. Model sẽ được nạp tự động ở lần sinh câu hỏi đầu tiên.`;
773
+
774
+ syncLandingStatus({
775
+ modelName: activeModel,
776
+ deviceName: humanizeDeviceCompact(payload.meta.active_device || payload.meta.predicted_device),
777
+ modelCount: state.availableModels.length,
778
+ badgeText: payload.meta.loaded ? "Sẵn sàng" : "Chờ nạp model",
779
+ badgeTone: payload.meta.loaded ? "ready" : "pending",
780
+ statusText: payload.meta.loaded
781
+ ? `${activeModel} đã nạp xong và có thể sử dụng ngay.`
782
+ : `${activeModel} sẽ được nạp tự động ở lần sinh câu hỏi đầu tiên.`,
783
+ });
784
+ }
785
+
786
+ function renderModelOptions(emptyLabel = "Chưa có model khả dụng.") {
787
+ elements.modelSelect.innerHTML = "";
788
+
789
+ if (!state.availableModels.length) {
790
+ const fallbackOption = document.createElement("option");
791
+ fallbackOption.value = "";
792
+ fallbackOption.textContent = emptyLabel;
793
+ elements.modelSelect.appendChild(fallbackOption);
794
+ elements.modelSelect.disabled = true;
795
+ return;
796
+ }
797
+
798
+ for (const model of state.availableModels) {
799
+ const option = document.createElement("option");
800
+ option.value = model.id;
801
+ option.textContent = model.label;
802
+ elements.modelSelect.appendChild(option);
803
+ }
804
+
805
+ if (!state.availableModels.some((item) => item.id === state.activeModelId)) {
806
+ state.activeModelId = state.availableModels[0].id;
807
+ }
808
+
809
+ elements.modelSelect.value = state.activeModelId;
810
+ syncInteractiveControls();
811
+ }
812
+
813
+ function renderAuthors() {
814
+ if (!elements.authorToggle || !elements.authorContent || !elements.authorList) return;
815
+
816
+ elements.authorToggle.setAttribute("aria-expanded", String(state.isAuthorPanelOpen));
817
+ elements.authorToggle.classList.toggle("is-open", state.isAuthorPanelOpen);
818
+ elements.authorContent.hidden = !state.isAuthorPanelOpen;
819
+
820
+ if (!state.isAuthorPanelOpen) {
821
+ elements.authorList.innerHTML = "";
822
+ return;
823
+ }
824
+
825
+ elements.authorList.innerHTML = AUTHOR_PROFILES.map((author) => {
826
+ const isActive = author.id === state.selectedAuthorId;
827
+ const detailMarkup = isActive ? buildAuthorDetailMarkup(author) : "";
828
+ return `
829
+ <article
830
+ class="author-person ${isActive ? "is-active" : ""}"
831
+ data-author-shell="${escapeHtml(author.id)}"
832
+ >
833
+ <button
834
+ class="author-person-trigger"
835
+ type="button"
836
+ data-author-id="${escapeHtml(author.id)}"
837
+ aria-expanded="${String(isActive)}"
838
+ >
839
+ <div class="author-person-top">
840
+ <span class="author-person-role">${escapeHtml(author.role)}</span>
841
+ <span class="author-person-chevron" aria-hidden="true">
842
+ <svg viewBox="0 0 24 24" fill="none">
843
+ <path
844
+ d="m8 10 4 4 4-4"
845
+ stroke="currentColor"
846
+ stroke-linecap="round"
847
+ stroke-linejoin="round"
848
+ stroke-width="1.8"
849
+ />
850
+ </svg>
851
+ </span>
852
+ </div>
853
+ <strong>${escapeHtml(author.name)}</strong>
854
+ <span class="author-person-summary">${escapeHtml(author.summary)}</span>
855
+ </button>
856
+ ${detailMarkup}
857
+ </article>
858
+ `;
859
+ }).join("");
860
+ }
861
+
862
+ function renderLandingSamples() {
863
+ if (!elements.sampleList) return;
864
+
865
+ elements.sampleList.innerHTML = SAMPLE_SNIPPETS.map((sample) => `
866
+ <button class="sample-card" type="button" data-sample-id="${escapeHtml(sample.id)}">
867
+ <strong>${escapeHtml(sample.title)}</strong>
868
+ <span>${escapeHtml(sample.preview)}</span>
869
+ </button>
870
+ `).join("");
871
+ }
872
+
873
+ function syncLandingPanel() {
874
+ if (!elements.landingPanel) return;
875
+ elements.landingPanel.hidden = !elements.resultCard.hidden;
876
+ }
877
+
878
+ function syncLandingStatus({
879
+ modelName = "Đang tải...",
880
+ deviceName = "Đang kiểm tra...",
881
+ modelCount = 0,
882
+ badgeText = "Đang kiểm tra",
883
+ badgeTone = "pending",
884
+ statusText = "Đang đồng bộ trạng thái hệ thống.",
885
+ } = {}) {
886
+ if (
887
+ !elements.landingRuntimeBadge
888
+ || !elements.landingStatusText
889
+ || !elements.landingModelName
890
+ || !elements.landingDeviceName
891
+ || !elements.landingModelCount
892
+ ) {
893
+ return;
894
+ }
895
+
896
+ elements.landingRuntimeBadge.textContent = badgeText;
897
+ elements.landingRuntimeBadge.classList.remove("is-ready", "is-pending", "is-error");
898
+ elements.landingRuntimeBadge.classList.add(
899
+ badgeTone === "ready" ? "is-ready" : badgeTone === "error" ? "is-error" : "is-pending",
900
+ );
901
+ elements.landingStatusText.textContent = statusText;
902
+ elements.landingModelName.textContent = modelName;
903
+ elements.landingDeviceName.textContent = deviceName;
904
+ elements.landingModelCount.textContent = String(modelCount);
905
+ }
906
+
907
+ function selectAuthor(authorId) {
908
+ if (!AUTHOR_PROFILES.some((author) => author.id === authorId)) {
909
+ return;
910
+ }
911
+
912
+ state.selectedAuthorId = state.selectedAuthorId === authorId ? null : authorId;
913
+ renderAuthors();
914
+ }
915
+
916
+ function buildAuthorDetailMarkup(author) {
917
+ const metaItems = [
918
+ { label: "Vai trò", value: author.description },
919
+ { label: "Đơn vị", value: author.unit },
920
+ ...(author.email ? [{ label: "Email", value: author.email }] : []),
921
+ ];
922
+
923
+ return `
924
+ <div class="author-person-body">
925
+ <div class="author-person-meta">
926
+ ${metaItems
927
+ .map(
928
+ (item) => `
929
+ <div class="author-person-meta-row" title="${escapeHtml(item.value)}">
930
+ <span class="author-person-meta-label">${escapeHtml(item.label)}</span>
931
+ <span class="author-person-meta-value">${escapeHtml(item.value)}</span>
932
+ </div>
933
+ `,
934
+ )
935
+ .join("")}
936
+ </div>
937
+ </div>
938
+ `;
939
+ }
940
+
941
+ function humanizeDevice(device) {
942
+ if (device === "cuda") return "Đang sử dụng GPU CUDA.";
943
+ return "Đang sử dụng CPU.";
944
+ }
945
+
946
+ function humanizeDeviceCompact(device) {
947
+ if (device === "cuda") return "GPU CUDA";
948
+ return "CPU";
949
+ }
950
+
951
+ function renderHistory() {
952
+ if (!state.history.length) {
953
+ elements.historyList.innerHTML = '<div class="history-empty">Chưa có lịch sử. Hãy tạo bộ câu hỏi đầu tiên của bạn.</div>';
954
+ return;
955
+ }
956
+
957
+ elements.historyList.innerHTML = state.history
958
+ .map((item) => {
959
+ const activeClass = item.id === state.selectedId ? "is-active" : "";
960
+ return `
961
+ <button class="history-item ${activeClass}" type="button" data-history-id="${item.id}">
962
+ <span class="history-icon" aria-hidden="true">
963
+ <svg viewBox="0 0 24 24" width="18" height="18" fill="none">
964
+ <path d="M12 20c4.4 0 8-2.9 8-6.5S16.4 7 12 7 4 9.9 4 13.5c0 1.6.7 3 1.9 4.1L5 21l3.2-1.6c1.1.4 2.4.6 3.8.6Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>
965
+ </svg>
966
+ </span>
967
+ <span class="history-main">
968
+ <strong>${escapeHtml(item.title || "Đoạn văn mới")}</strong>
969
+ <span>${escapeHtml(formatTimestamp(item.createdAt))}</span>
970
+ </span>
971
+ </button>
972
+ `;
973
+ })
974
+ .join("");
975
+ }
976
+
977
+ function showResultCard() {
978
+ elements.resultCard.hidden = false;
979
+ elements.resultCard.classList.add("is-visible");
980
+ syncLandingPanel();
981
+ }
982
+
983
+ function hideResultCard() {
984
+ elements.resultCard.hidden = true;
985
+ elements.resultCard.classList.remove("is-visible");
986
+ elements.resultCard.classList.remove("has-entry");
987
+ elements.resultCard.classList.remove("is-updating");
988
+ elements.resultCard.innerHTML = "";
989
+ syncLandingPanel();
990
+ }
991
+
992
+ function renderMessage(message) {
993
+ showResultCard();
994
+ elements.resultCard.classList.remove("is-updating");
995
+
996
+ if (state.thread.length) {
997
+ elements.resultCard.classList.add("has-entry");
998
+ elements.resultCard.innerHTML = `
999
+ <p class="result-message result-message-inline">${escapeHtml(message)}</p>
1000
+ ${renderThreadMarkup(state.thread)}
1001
+ `;
1002
+ return;
1003
+ }
1004
+
1005
+ elements.resultCard.classList.remove("has-entry");
1006
+ elements.resultCard.innerHTML = `
1007
+ <p class="result-message">${escapeHtml(message)}</p>
1008
+ `;
1009
+ }
1010
+
1011
+ function renderThread() {
1012
+ if (!state.thread.length) {
1013
+ hideResultCard();
1014
+ return;
1015
+ }
1016
+
1017
+ showResultCard();
1018
+ elements.resultCard.classList.add("has-entry");
1019
+ elements.resultCard.classList.remove("is-updating");
1020
+ elements.resultCard.innerHTML = renderThreadMarkup(state.thread);
1021
+ }
1022
+
1023
+ function renderThreadMarkup(entries) {
1024
+ return `
1025
+ <div class="result-feed">
1026
+ ${entries.map((entry) => renderThreadItem(entry)).join("")}
1027
+ </div>
1028
+ `;
1029
+ }
1030
+
1031
+ function renderThreadItem(entry) {
1032
+ const questions = Array.isArray(entry.questions) ? entry.questions : [];
1033
+ const questionItems = questions.map((item) => `<li>${escapeHtml(item)}</li>`).join("");
1034
+ const statusLabel =
1035
+ entry.status === "pending" ? "ĐANG XỬ LÝ" : entry.status === "error" ? "LỖI" : entry.device ? entry.device.toUpperCase() : "AUTO";
1036
+ const questionBlock =
1037
+ entry.status === "pending"
1038
+ ? `
1039
+ <div class="result-pending">
1040
+ <div class="atom-loader atom-loader-inline" aria-hidden="true">
1041
+ <span class="atom-core"></span>
1042
+ <span class="atom-orbit atom-orbit-a"><span class="atom-electron"></span></span>
1043
+ <span class="atom-orbit atom-orbit-b"><span class="atom-electron"></span></span>
1044
+ <span class="atom-orbit atom-orbit-c"><span class="atom-electron"></span></span>
1045
+ </div>
1046
+ <p class="result-note">Đang sinh câu hỏi từ đoạn văn bản này...</p>
1047
+ </div>
1048
+ `
1049
+ : entry.status === "error"
1050
+ ? `<p class="result-message">${escapeHtml(entry.errorMessage || "Có lỗi xảy ra khi sinh câu hỏi.")}</p>`
1051
+ : questions.length
1052
+ ? `<ol class="result-questions">${questionItems}</ol>`
1053
+ : '<p class="result-note">Mục lịch sử này chưa lưu danh sách câu hỏi. Hãy bấm “Sinh câu hỏi” để tạo lại.</p>';
1054
+
1055
+ return `
1056
+ <article class="result-thread-item" data-entry-id="${escapeHtml(entry.id)}">
1057
+ <div class="result-meta">
1058
+ <span>${escapeHtml(formatTimestamp(entry.createdAt))}</span>
1059
+ <span>${escapeHtml(statusLabel)}</span>
1060
+ <span>${escapeHtml(String(entry.count || questions.length || 0))} câu hỏi</span>
1061
+ ${entry.elapsedMs ? `<span>${escapeHtml(String(entry.elapsedMs))} ms</span>` : ""}
1062
+ </div>
1063
+
1064
+ <section class="result-section">
1065
+ <div class="result-section-head">
1066
+ <h3 class="result-source-title">Văn bản đầu vào</h3>
1067
+ <button class="copy-button" type="button" data-copy-entry-id="${escapeHtml(entry.id)}" data-copy-target="source" aria-label="Sao chép">
1068
+ ${copyIconMarkup()}
1069
+ </button>
1070
+ </div>
1071
+ <p class="result-source">${escapeHtml(entry.text || entry.title || "")}</p>
1072
+ </section>
1073
+
1074
+ <section class="result-section">
1075
+ <div class="result-section-head">
1076
+ <h3 class="result-questions-title">Câu hỏi sinh ra</h3>
1077
+ <button class="copy-button" type="button" data-copy-entry-id="${escapeHtml(entry.id)}" data-copy-target="response" aria-label="Sao chép">
1078
+ ${copyIconMarkup()}
1079
+ </button>
1080
+ </div>
1081
+ ${questionBlock}
1082
+ </section>
1083
+ </article>
1084
+ `;
1085
+ }
1086
+
1087
+ function copyIconMarkup() {
1088
+ return `
1089
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
1090
+ <path
1091
+ d="M9 9.75A2.25 2.25 0 0 1 11.25 7.5h6A2.25 2.25 0 0 1 19.5 9.75v6A2.25 2.25 0 0 1 17.25 18h-6A2.25 2.25 0 0 1 9 15.75v-6Z"
1092
+ stroke="currentColor"
1093
+ stroke-linecap="round"
1094
+ stroke-linejoin="round"
1095
+ stroke-width="1.7"
1096
+ />
1097
+ <path
1098
+ d="M15 7.5v-.75A2.25 2.25 0 0 0 12.75 4.5h-6A2.25 2.25 0 0 0 4.5 6.75v6A2.25 2.25 0 0 0 6.75 15H9"
1099
+ stroke="currentColor"
1100
+ stroke-linecap="round"
1101
+ stroke-linejoin="round"
1102
+ stroke-width="1.7"
1103
+ />
1104
+ </svg>
1105
+ `;
1106
+ }
1107
+
1108
+ function buildCopyText(entryId, target) {
1109
+ const entry = state.thread.find((item) => item.id === entryId) || state.history.find((item) => item.id === entryId);
1110
+ if (!entry) return "";
1111
+
1112
+ if (target === "source") {
1113
+ return String(entry.text || entry.title || "").trim();
1114
+ }
1115
+
1116
+ if (entry.status === "pending") {
1117
+ return "Đang sinh câu hỏi từ đoạn văn bản này...";
1118
+ }
1119
+
1120
+ if (entry.status === "error") {
1121
+ return String(entry.errorMessage || "Có lỗi xảy ra khi sinh câu hỏi.").trim();
1122
+ }
1123
+
1124
+ const questions = Array.isArray(entry.questions) ? entry.questions : [];
1125
+ if (questions.length) {
1126
+ return questions.map((item, index) => `${index + 1}. ${item}`).join("\n");
1127
+ }
1128
+
1129
+ return "Mục lịch sử này chưa lưu danh sách câu hỏi. Hãy bấm “Sinh câu hỏi” để tạo lại.";
1130
+ }
1131
+
1132
+ async function copyToClipboard(text) {
1133
+ try {
1134
+ await navigator.clipboard.writeText(text);
1135
+ return true;
1136
+ } catch {
1137
+ try {
1138
+ const area = document.createElement("textarea");
1139
+ area.value = text;
1140
+ area.setAttribute("readonly", "");
1141
+ area.style.position = "fixed";
1142
+ area.style.opacity = "0";
1143
+ document.body.appendChild(area);
1144
+ area.select();
1145
+ const success = document.execCommand("copy");
1146
+ area.remove();
1147
+ return success;
1148
+ } catch {
1149
+ return false;
1150
+ }
1151
+ }
1152
+ }
1153
+
1154
+ function setLoading(isLoading) {
1155
+ elements.generateButton.classList.toggle("is-loading", isLoading);
1156
+ document.body.classList.toggle("is-generating", isLoading);
1157
+ elements.resultCard.classList.toggle("is-updating", isLoading && elements.resultCard.classList.contains("has-entry"));
1158
+ syncQuestionCount(elements.questionCount.value);
1159
+ syncInteractiveControls();
1160
+ }
1161
+
1162
+ function isInterfaceBusy() {
1163
+ return document.body.classList.contains("is-generating") || state.isSwitchingModel;
1164
+ }
1165
+
1166
+ function syncInteractiveControls() {
1167
+ const isBusy = isInterfaceBusy();
1168
+ elements.generateButton.disabled = isBusy;
1169
+ elements.modelSelect.disabled = isBusy || state.availableModels.length <= 1;
1170
+ }
1171
+
1172
+ function activateHeroTitle() {
1173
+ const node = elements.heroTitle;
1174
+ if (!node) return;
1175
+
1176
+ const fullText = String(node.dataset.text || "").trim();
1177
+ if (!fullText) return;
1178
+
1179
+ node.textContent = fullText;
1180
+ node.classList.remove("is-ready");
1181
+
1182
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
1183
+ node.classList.add("is-ready");
1184
+ return;
1185
+ }
1186
+
1187
+ window.requestAnimationFrame(() => {
1188
+ node.classList.add("is-ready");
1189
+ });
1190
+ }
1191
+
1192
+ function shrink(text, maxLength) {
1193
+ const normalized = String(text || "").trim();
1194
+ if (normalized.length <= maxLength) return normalized;
1195
+ return `${normalized.slice(0, maxLength - 3).trim()}...`;
1196
+ }
1197
+
1198
+ function formatTimestamp(value) {
1199
+ const date = new Date(value);
1200
+ if (Number.isNaN(date.getTime())) return "Vừa xong";
1201
+
1202
+ const now = new Date();
1203
+ const sameDay = date.toDateString() === now.toDateString();
1204
+ const yesterday = new Date(now);
1205
+ yesterday.setDate(now.getDate() - 1);
1206
+
1207
+ const timeLabel = date.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" });
1208
+ if (sameDay) return `Hôm nay ${timeLabel}`;
1209
+ if (date.toDateString() === yesterday.toDateString()) return `Hôm qua ${timeLabel}`;
1210
+
1211
+ return date.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit", year: "numeric" });
1212
+ }
1213
+
1214
+ function syncCopyright() {
1215
+ const year = new Date().getFullYear();
1216
+ elements.copyrightLine.textContent = `© ${year} HVU - KTCN`;
1217
+ }
1218
+
1219
+ function escapeHtml(value) {
1220
+ return String(value || "")
1221
+ .replaceAll("&", "&amp;")
1222
+ .replaceAll("<", "&lt;")
1223
+ .replaceAll(">", "&gt;")
1224
+ .replaceAll('"', "&quot;")
1225
+ .replaceAll("'", "&#39;");
1226
+ }
1227
+
1228
+ function makeId() {
1229
+ if (window.crypto && typeof window.crypto.randomUUID === "function") {
1230
+ return window.crypto.randomUUID();
1231
+ }
1232
+ return `item-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1233
+ }
HVU_QA/frontend/index.html ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="vi">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>HVU QA - Mô hình sinh câu hỏi thường gặp</title>
7
+ <meta
8
+ name="description"
9
+ content="Hệ thống sinh câu hỏi thường gặp của Trường Đại học Hùng Vương."
10
+ />
11
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
12
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
13
+ <link
14
+ href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap"
15
+ rel="stylesheet"
16
+ />
17
+ <link rel="stylesheet" href="/frontend/style.css" />
18
+ <script src="/frontend/app.js" defer></script>
19
+ </head>
20
+ <body>
21
+ <div class="page-shell">
22
+ <aside class="sidebar" id="sidebar">
23
+ <div class="sidebar-top">
24
+ <button
25
+ class="menu-toggle"
26
+ id="menuToggle"
27
+ type="button"
28
+ aria-label="Mở hoặc đóng thanh bên"
29
+ aria-expanded="false"
30
+ aria-controls="sidebarContent"
31
+ >
32
+ <span></span>
33
+ <span></span>
34
+ <span></span>
35
+ </button>
36
+ </div>
37
+
38
+ <div class="sidebar-content" id="sidebarContent" aria-hidden="true">
39
+ <section class="side-card">
40
+ <p class="side-label">Chọn model</p>
41
+ <label class="select-shell">
42
+ <span class="select-icon" aria-hidden="true">
43
+ <svg viewBox="0 0 24 24" fill="none">
44
+ <path
45
+ d="M12 3 4.5 7.2v9.6L12 21l7.5-4.2V7.2L12 3Zm0 0v8.4m0 0 7.5-4.2M12 11.4 4.5 7.2"
46
+ stroke="currentColor"
47
+ stroke-linecap="round"
48
+ stroke-linejoin="round"
49
+ stroke-width="1.6"
50
+ />
51
+ </svg>
52
+ </span>
53
+ <select id="modelSelect" disabled>
54
+ <option>Đang tải danh sách model...</option>
55
+ </select>
56
+ </label>
57
+ </section>
58
+
59
+ <section class="side-card status-card">
60
+ <div class="status-chip">
61
+ <span class="status-dot" aria-hidden="true"></span>
62
+ <p id="deviceStatus">Đang kiểm tra thiết bị...</p>
63
+ </div>
64
+ <p class="status-note" id="modelStatus">Model sẽ được nạp ở lần sinh câu hỏi đầu tiên.</p>
65
+ </section>
66
+
67
+ <section class="side-card history-card">
68
+ <div class="history-header">
69
+ <p class="side-label">Lịch sử</p>
70
+ <button id="clearHistory" type="button">Xóa</button>
71
+ </div>
72
+ <div class="history-list" id="historyList"></div>
73
+ </section>
74
+
75
+ <section class="author-card">
76
+ <button
77
+ class="author-toggle"
78
+ id="authorToggle"
79
+ type="button"
80
+ aria-expanded="false"
81
+ aria-controls="authorContent"
82
+ >
83
+ <div class="author-header">
84
+ <div class="author-header-icon" aria-hidden="true">
85
+ <svg viewBox="0 0 24 24" fill="none">
86
+ <path
87
+ d="M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm-7 8c0-3.314 3.134-6 7-6s7 2.686 7 6"
88
+ stroke="currentColor"
89
+ stroke-linecap="round"
90
+ stroke-linejoin="round"
91
+ stroke-width="1.8"
92
+ />
93
+ </svg>
94
+ </div>
95
+ <div>
96
+ <p class="author-title">Tác giả</p>
97
+ </div>
98
+ </div>
99
+ <span class="author-toggle-icon" aria-hidden="true">
100
+ <svg viewBox="0 0 24 24" fill="none">
101
+ <path
102
+ d="m8 10 4 4 4-4"
103
+ stroke="currentColor"
104
+ stroke-linecap="round"
105
+ stroke-linejoin="round"
106
+ stroke-width="1.8"
107
+ />
108
+ </svg>
109
+ </span>
110
+ </button>
111
+
112
+ <div class="author-content" id="authorContent" hidden>
113
+ <div class="author-grid" id="authorList"></div>
114
+ </div>
115
+
116
+ <div class="author-footer">
117
+ <p id="copyrightLine">© 2026 HVU - KTCN</p>
118
+ </div>
119
+ </section>
120
+ </div>
121
+ </aside>
122
+
123
+ <main class="workspace">
124
+ <header class="topbar">
125
+ <div class="identity">
126
+ <img class="logo" src="/frontend/HVU.png" alt="Logo Trường Đại học Hùng Vương" />
127
+ <div class="identity-copy">
128
+ <h1>Trường Đại học Hùng Vương</h1>
129
+ <p>Khoa Kỹ thuật - công nghệ</p>
130
+ </div>
131
+ </div>
132
+ </header>
133
+
134
+ <section class="hero-panel">
135
+ <div class="hero-copy">
136
+ <h2>
137
+ <span
138
+ class="typewriter-text"
139
+ id="heroTitle"
140
+ data-text="Mô hình sinh câu hỏi thường gặp"
141
+ aria-label="Mô hình sinh câu hỏi thường gặp"
142
+ ></span>
143
+ </h2>
144
+ </div>
145
+ </section>
146
+
147
+ <section class="result-card" id="resultCard" aria-live="polite" hidden></section>
148
+
149
+ <form class="composer" id="generatorForm">
150
+ <div class="input-shell" id="sourceShell">
151
+ <label class="visually-hidden" for="sourceText">Nhập đoạn văn bản</label>
152
+ <textarea
153
+ id="sourceText"
154
+ name="sourceText"
155
+ rows="1"
156
+ placeholder="Nhập đoạn văn bản ..."
157
+ required
158
+ ></textarea>
159
+
160
+ <div class="composer-actions">
161
+ <div class="count-shell" aria-label="Số câu hỏi">
162
+ <span class="count-label">Số câu hỏi</span>
163
+ <div class="count-stepper" role="group" aria-label="Điều chỉnh số câu hỏi">
164
+ <button class="count-button" id="decreaseCount" type="button" aria-label="Giảm số câu hỏi">
165
+ <span aria-hidden="true">-</span>
166
+ </button>
167
+ <output class="count-value" id="questionCountValue" for="questionCount">0</output>
168
+ <button class="count-button" id="increaseCount" type="button" aria-label="Tăng số câu hỏi">
169
+ <span aria-hidden="true">+</span>
170
+ </button>
171
+ </div>
172
+ <input id="questionCount" name="questionCount" type="hidden" value="0" />
173
+ </div>
174
+
175
+ <div class="action-cluster">
176
+ <span class="voice-status is-empty" id="voiceStatus" aria-live="polite"></span>
177
+ <div class="action-buttons">
178
+ <button
179
+ class="voice-button"
180
+ id="voiceInputButton"
181
+ type="button"
182
+ aria-label="Nhập bằng giọng nói qua trình duyệt"
183
+ >
184
+ <span class="voice-button-icon" aria-hidden="true">
185
+ <svg viewBox="0 0 24 24" fill="none">
186
+ <path
187
+ d="M12 15a3.5 3.5 0 0 0 3.5-3.5v-4a3.5 3.5 0 1 0-7 0v4A3.5 3.5 0 0 0 12 15Z"
188
+ stroke="currentColor"
189
+ stroke-linecap="round"
190
+ stroke-linejoin="round"
191
+ stroke-width="1.8"
192
+ />
193
+ <path
194
+ d="M6.5 11.5a5.5 5.5 0 1 0 11 0M12 17v3m-3 0h6"
195
+ stroke="currentColor"
196
+ stroke-linecap="round"
197
+ stroke-linejoin="round"
198
+ stroke-width="1.8"
199
+ />
200
+ </svg>
201
+ </span>
202
+ </button>
203
+
204
+ <button class="generate-button" id="generateButton" type="submit">
205
+ <span class="atom-loader atom-loader-sm" aria-hidden="true">
206
+ <span class="atom-core"></span>
207
+ <span class="atom-orbit atom-orbit-a"><span class="atom-electron"></span></span>
208
+ <span class="atom-orbit atom-orbit-b"><span class="atom-electron"></span></span>
209
+ <span class="atom-orbit atom-orbit-c"><span class="atom-electron"></span></span>
210
+ </span>
211
+ <span class="button-label">Sinh câu hỏi</span>
212
+ </button>
213
+ </div>
214
+ </div>
215
+ </div>
216
+ </div>
217
+ </form>
218
+
219
+ <section class="landing-panel" id="landingPanel">
220
+ <article class="landing-card landing-guide">
221
+ <div class="landing-card-head">
222
+ <p class="landing-kicker">Hướng dẫn nhanh</p>
223
+ <p class="landing-card-note">Tạo bộ câu hỏi từ đoạn văn bản đầu vào.</p>
224
+ </div>
225
+ <ol class="landing-guide-list">
226
+ <li>Nhập hoặc dán đoạn văn bản vào ô nhập.</li>
227
+ <li>Chọn số lượng câu hỏi cần sinh.</li>
228
+ <li>Nhấn <strong>Sinh câu hỏi</strong> để hệ thống xử lý.</li>
229
+ </ol>
230
+ </article>
231
+
232
+ <article class="landing-card landing-samples">
233
+ <div class="landing-card-head">
234
+ <p class="landing-kicker">Ví dụ mẫu</p>
235
+ <p class="landing-card-note">Chọn văn bản luật mẫu để chèn nhanh nội dung thử nghiệm.</p>
236
+ </div>
237
+ <div class="landing-sample-grid" id="sampleList"></div>
238
+ </article>
239
+
240
+ <article class="landing-card landing-system">
241
+ <div class="landing-card-head">
242
+ <p class="landing-kicker">Tr���ng thái model</p>
243
+ <span class="landing-runtime-badge is-pending" id="landingRuntimeBadge">Đang kiểm tra</span>
244
+ </div>
245
+ <p class="landing-card-note" id="landingStatusText">Đang kết nối backend và đọc cấu hình hệ thống.</p>
246
+ <div class="landing-system-list">
247
+ <div class="landing-system-row">
248
+ <span>Model đang dùng</span>
249
+ <strong id="landingModelName">Đang tải...</strong>
250
+ </div>
251
+ <div class="landing-system-row">
252
+ <span>Thiết bị xử lý</span>
253
+ <strong id="landingDeviceName">Đang kiểm tra...</strong>
254
+ </div>
255
+ <div class="landing-system-row">
256
+ <span>Số model khả dụng</span>
257
+ <strong id="landingModelCount">0</strong>
258
+ </div>
259
+ </div>
260
+ </article>
261
+ </section>
262
+ </main>
263
+ </div>
264
+ </body>
265
+ </html>
HVU_QA/frontend/style.css ADDED
@@ -0,0 +1,1792 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --bg: #f6f4fb;
3
+ --panel: rgba(255, 255, 255, 0.88);
4
+ --panel-soft: rgba(250, 248, 255, 0.92);
5
+ --line: rgba(92, 85, 168, 0.12);
6
+ --line-strong: rgba(92, 85, 168, 0.22);
7
+ --text: #232343;
8
+ --text-soft: #66648a;
9
+ --text-muted: #9793b5;
10
+ --accent: #5c63e7;
11
+ --accent-strong: #434dc7;
12
+ --accent-soft: rgba(92, 99, 231, 0.09);
13
+ --warm: #e0607c;
14
+ --gold: #f0b558;
15
+ --shadow-main: 0 28px 64px rgba(70, 62, 132, 0.12);
16
+ --shadow-soft: 0 12px 28px rgba(97, 88, 171, 0.08);
17
+ --radius-xl: 30px;
18
+ --radius-lg: 24px;
19
+ --radius-md: 18px;
20
+ --radius-sm: 14px;
21
+ }
22
+
23
+ * {
24
+ box-sizing: border-box;
25
+ }
26
+
27
+ html,
28
+ body {
29
+ min-height: 100%;
30
+ }
31
+
32
+ body {
33
+ margin: 0;
34
+ font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
35
+ color: var(--text);
36
+ background:
37
+ radial-gradient(circle at 15% 15%, rgba(92, 99, 231, 0.08), transparent 22%),
38
+ radial-gradient(circle at 85% 85%, rgba(224, 96, 124, 0.1), transparent 18%),
39
+ linear-gradient(180deg, #f8f6fc 0%, #f2eef9 100%);
40
+ }
41
+
42
+ button,
43
+ input,
44
+ select,
45
+ textarea {
46
+ font: inherit;
47
+ }
48
+
49
+ .page-shell {
50
+ --sidebar-width: 96px;
51
+ width: min(1420px, calc(100vw - 32px));
52
+ min-height: calc(100vh - 32px);
53
+ margin: 16px auto;
54
+ display: grid;
55
+ grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
56
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(246, 241, 255, 0.82));
57
+ border: 1px solid rgba(255, 255, 255, 0.88);
58
+ border-radius: 28px;
59
+ box-shadow: var(--shadow-main);
60
+ overflow: hidden;
61
+ backdrop-filter: blur(18px);
62
+ transition: grid-template-columns 0.28s ease;
63
+ }
64
+
65
+ body.sidebar-open .page-shell {
66
+ --sidebar-width: 360px;
67
+ }
68
+
69
+ .sidebar {
70
+ padding: 18px;
71
+ background: linear-gradient(180deg, rgba(247, 244, 255, 0.98), rgba(239, 244, 255, 0.96));
72
+ border-right: 1px solid var(--line);
73
+ display: flex;
74
+ flex-direction: column;
75
+ gap: 14px;
76
+ }
77
+
78
+ .sidebar-top {
79
+ min-height: 64px;
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ }
84
+
85
+ .menu-toggle {
86
+ width: 56px;
87
+ height: 56px;
88
+ border: 0;
89
+ border-radius: 18px;
90
+ background: #fff;
91
+ box-shadow: var(--shadow-soft);
92
+ display: inline-grid;
93
+ place-content: center;
94
+ gap: 5px;
95
+ cursor: pointer;
96
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
97
+ }
98
+
99
+ .menu-toggle:hover {
100
+ transform: translateY(-1px);
101
+ box-shadow: 0 16px 30px rgba(97, 88, 171, 0.12);
102
+ }
103
+
104
+ .menu-toggle span {
105
+ width: 24px;
106
+ height: 3px;
107
+ border-radius: 999px;
108
+ background: #5d5a8c;
109
+ transition: transform 0.24s ease, opacity 0.24s ease;
110
+ }
111
+
112
+ body.sidebar-open .menu-toggle span:nth-child(1) {
113
+ transform: translateY(8px) rotate(45deg);
114
+ }
115
+
116
+ body.sidebar-open .menu-toggle span:nth-child(2) {
117
+ opacity: 0;
118
+ }
119
+
120
+ body.sidebar-open .menu-toggle span:nth-child(3) {
121
+ transform: translateY(-8px) rotate(-45deg);
122
+ }
123
+
124
+ .sidebar-content {
125
+ display: grid;
126
+ gap: 14px;
127
+ opacity: 0;
128
+ max-height: 0;
129
+ overflow: hidden;
130
+ pointer-events: none;
131
+ transform: translateY(-8px);
132
+ transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.28s ease;
133
+ }
134
+
135
+ body.sidebar-open .sidebar-content {
136
+ opacity: 1;
137
+ max-height: 2000px;
138
+ pointer-events: auto;
139
+ transform: translateY(0);
140
+ }
141
+
142
+ .side-card,
143
+ .author-card,
144
+ .result-card,
145
+ .composer {
146
+ border: 1px solid rgba(255, 255, 255, 0.92);
147
+ box-shadow: var(--shadow-soft);
148
+ }
149
+
150
+ .side-card {
151
+ padding: 14px;
152
+ border-radius: 20px;
153
+ background: linear-gradient(180deg, rgba(242, 245, 255, 0.98), rgba(252, 252, 255, 0.94));
154
+ border-color: rgba(151, 161, 240, 0.16);
155
+ }
156
+
157
+ .side-label {
158
+ margin: 0 0 12px;
159
+ font-size: 0.8rem;
160
+ font-weight: 700;
161
+ letter-spacing: 0.03em;
162
+ color: var(--text-muted);
163
+ }
164
+
165
+ .select-shell {
166
+ min-height: 54px;
167
+ display: flex;
168
+ align-items: center;
169
+ gap: 12px;
170
+ padding: 0 14px;
171
+ border-radius: 16px;
172
+ border: 1px solid var(--line);
173
+ background: #fff;
174
+ }
175
+
176
+ .select-icon {
177
+ width: 20px;
178
+ height: 20px;
179
+ color: var(--accent);
180
+ display: inline-flex;
181
+ }
182
+
183
+ .select-shell select {
184
+ width: 100%;
185
+ border: 0;
186
+ outline: none;
187
+ background: transparent;
188
+ color: #585480;
189
+ font-weight: 500;
190
+ }
191
+
192
+ .status-card {
193
+ display: grid;
194
+ gap: 8px;
195
+ }
196
+
197
+ .status-chip {
198
+ display: flex;
199
+ align-items: center;
200
+ gap: 10px;
201
+ }
202
+
203
+ .status-chip p,
204
+ .status-note {
205
+ margin: 0;
206
+ }
207
+
208
+ .status-chip p {
209
+ font-size: 0.92rem;
210
+ font-weight: 600;
211
+ color: #57527d;
212
+ }
213
+
214
+ .status-note {
215
+ font-size: 0.84rem;
216
+ line-height: 1.6;
217
+ color: var(--text-muted);
218
+ }
219
+
220
+ .status-dot {
221
+ width: 10px;
222
+ height: 10px;
223
+ border-radius: 50%;
224
+ background: linear-gradient(135deg, var(--warm), var(--accent));
225
+ box-shadow: 0 0 0 5px rgba(92, 99, 231, 0.1);
226
+ }
227
+
228
+ .history-card {
229
+ min-height: 240px;
230
+ display: flex;
231
+ flex-direction: column;
232
+ }
233
+
234
+ .history-header {
235
+ display: flex;
236
+ align-items: center;
237
+ justify-content: space-between;
238
+ gap: 12px;
239
+ margin-bottom: 8px;
240
+ }
241
+
242
+ .history-header .side-label {
243
+ margin: 0;
244
+ }
245
+
246
+ .history-header button {
247
+ border: 0;
248
+ background: transparent;
249
+ color: var(--accent);
250
+ font-weight: 600;
251
+ cursor: pointer;
252
+ }
253
+
254
+ .history-list {
255
+ display: grid;
256
+ gap: 10px;
257
+ max-height: 100%;
258
+ overflow: auto;
259
+ padding-right: 4px;
260
+ }
261
+
262
+ .history-list::-webkit-scrollbar {
263
+ width: 8px;
264
+ }
265
+
266
+ .history-list::-webkit-scrollbar-thumb {
267
+ border-radius: 999px;
268
+ background: rgba(92, 99, 231, 0.2);
269
+ }
270
+
271
+ .history-item {
272
+ width: 100%;
273
+ border: 1px solid transparent;
274
+ border-radius: 16px;
275
+ background: rgba(255, 255, 255, 0.82);
276
+ padding: 12px 14px;
277
+ display: grid;
278
+ grid-template-columns: auto 1fr;
279
+ gap: 12px;
280
+ align-items: start;
281
+ text-align: left;
282
+ color: inherit;
283
+ cursor: pointer;
284
+ transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
285
+ }
286
+
287
+ .history-item:hover,
288
+ .history-item.is-active {
289
+ transform: translateY(-1px);
290
+ border-color: rgba(92, 99, 231, 0.18);
291
+ box-shadow: 0 12px 24px rgba(92, 99, 231, 0.1);
292
+ }
293
+
294
+ .history-icon {
295
+ width: 24px;
296
+ height: 24px;
297
+ color: var(--accent);
298
+ display: inline-grid;
299
+ place-items: center;
300
+ margin-top: 3px;
301
+ }
302
+
303
+ .history-main strong,
304
+ .history-main span {
305
+ display: block;
306
+ }
307
+
308
+ .history-main strong {
309
+ font-size: 0.95rem;
310
+ line-height: 1.45;
311
+ font-weight: 600;
312
+ color: #4a466e;
313
+ }
314
+
315
+ .history-main span {
316
+ margin-top: 4px;
317
+ font-size: 0.8rem;
318
+ color: var(--text-muted);
319
+ }
320
+
321
+ .history-empty {
322
+ padding: 14px;
323
+ border-radius: 16px;
324
+ background: rgba(255, 255, 255, 0.7);
325
+ color: var(--text-muted);
326
+ line-height: 1.6;
327
+ }
328
+
329
+ .author-card {
330
+ border-radius: 22px;
331
+ padding: 16px;
332
+ display: grid;
333
+ gap: 12px;
334
+ background: linear-gradient(180deg, rgba(255, 243, 247, 0.98), rgba(247, 242, 255, 0.96));
335
+ border-color: rgba(236, 158, 182, 0.18);
336
+ }
337
+
338
+ .author-toggle {
339
+ min-width: 0;
340
+ width: 100%;
341
+ padding: 0;
342
+ border: 0;
343
+ background: transparent;
344
+ color: inherit;
345
+ display: flex;
346
+ align-items: center;
347
+ justify-content: space-between;
348
+ gap: 12px;
349
+ text-align: left;
350
+ cursor: pointer;
351
+ }
352
+
353
+ .author-toggle:focus-visible {
354
+ outline: 2px solid rgba(92, 99, 231, 0.24);
355
+ outline-offset: 4px;
356
+ border-radius: 18px;
357
+ }
358
+
359
+ .author-header {
360
+ min-width: 0;
361
+ display: grid;
362
+ grid-template-columns: auto 1fr;
363
+ gap: 12px;
364
+ align-items: center;
365
+ }
366
+
367
+ .author-header > :last-child {
368
+ min-width: 0;
369
+ }
370
+
371
+ .author-toggle-icon {
372
+ width: 34px;
373
+ height: 34px;
374
+ border-radius: 12px;
375
+ background: rgba(255, 255, 255, 0.8);
376
+ color: #7b75a6;
377
+ display: inline-grid;
378
+ place-items: center;
379
+ flex: none;
380
+ transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
381
+ }
382
+
383
+ .author-toggle-icon svg {
384
+ width: 18px;
385
+ height: 18px;
386
+ }
387
+
388
+ .author-toggle.is-open .author-toggle-icon {
389
+ transform: rotate(180deg);
390
+ background: rgba(240, 234, 255, 0.98);
391
+ color: var(--accent-strong);
392
+ }
393
+
394
+ .author-header-icon {
395
+ width: 44px;
396
+ height: 44px;
397
+ border-radius: 16px;
398
+ background: linear-gradient(180deg, rgba(240, 228, 255, 0.98), rgba(255, 240, 246, 0.98));
399
+ color: var(--accent);
400
+ display: inline-grid;
401
+ place-items: center;
402
+ box-shadow: 0 10px 20px rgba(123, 117, 166, 0.08);
403
+ }
404
+
405
+ .author-header-icon svg {
406
+ width: 20px;
407
+ height: 20px;
408
+ }
409
+
410
+ .author-title,
411
+ .author-footer p,
412
+ .author-person-summary,
413
+ .author-person-meta-label,
414
+ .author-person-meta-value {
415
+ margin: 0;
416
+ }
417
+
418
+ .author-title {
419
+ font-size: 0.82rem;
420
+ font-weight: 800;
421
+ letter-spacing: 0.04em;
422
+ color: #7b75a6;
423
+ overflow-wrap: anywhere;
424
+ word-break: break-word;
425
+ white-space: normal;
426
+ }
427
+
428
+ .author-grid {
429
+ min-width: 0;
430
+ display: grid;
431
+ gap: 10px;
432
+ }
433
+
434
+ .author-content {
435
+ min-width: 0;
436
+ display: grid;
437
+ gap: 12px;
438
+ }
439
+
440
+ .author-content[hidden] {
441
+ display: none;
442
+ }
443
+
444
+ .author-person {
445
+ min-width: 0;
446
+ width: 100%;
447
+ border: 1px solid rgba(184, 167, 224, 0.24);
448
+ border-radius: 18px;
449
+ background: rgba(255, 255, 255, 0.74);
450
+ display: grid;
451
+ overflow: hidden;
452
+ transition:
453
+ transform 0.18s ease,
454
+ box-shadow 0.18s ease,
455
+ border-color 0.18s ease,
456
+ background 0.18s ease;
457
+ }
458
+
459
+ .author-person:hover,
460
+ .author-person.is-active {
461
+ transform: translateY(-1px);
462
+ border-color: rgba(92, 99, 231, 0.22);
463
+ background: rgba(255, 255, 255, 0.94);
464
+ box-shadow: 0 12px 24px rgba(92, 99, 231, 0.1);
465
+ }
466
+
467
+ .author-person-trigger {
468
+ min-width: 0;
469
+ width: 100%;
470
+ padding: 14px;
471
+ border: 0;
472
+ background: transparent;
473
+ text-align: left;
474
+ color: inherit;
475
+ display: grid;
476
+ gap: 8px;
477
+ cursor: pointer;
478
+ }
479
+
480
+ .author-person-trigger > * {
481
+ min-width: 0;
482
+ }
483
+
484
+ .author-person-trigger:focus-visible {
485
+ outline: 2px solid rgba(92, 99, 231, 0.28);
486
+ outline-offset: 2px;
487
+ }
488
+
489
+ .author-person-top {
490
+ min-width: 0;
491
+ display: flex;
492
+ align-items: flex-start;
493
+ justify-content: space-between;
494
+ gap: 10px;
495
+ }
496
+
497
+ .author-person-role {
498
+ min-width: 0;
499
+ flex: 1 1 auto;
500
+ padding: 0;
501
+ color: var(--accent-strong);
502
+ display: block;
503
+ font-size: 0.74rem;
504
+ font-weight: 700;
505
+ line-height: 1.35;
506
+ overflow-wrap: anywhere;
507
+ word-break: break-word;
508
+ white-space: normal;
509
+ }
510
+
511
+ .author-person-chevron {
512
+ width: 18px;
513
+ height: 18px;
514
+ color: #7b75a6;
515
+ display: inline-grid;
516
+ place-items: center;
517
+ flex: none;
518
+ transition: transform 0.18s ease, color 0.18s ease;
519
+ }
520
+
521
+ .author-person-chevron svg {
522
+ width: 16px;
523
+ height: 16px;
524
+ }
525
+
526
+ .author-person.is-active .author-person-chevron {
527
+ transform: rotate(180deg);
528
+ color: var(--accent-strong);
529
+ }
530
+
531
+ .author-person strong {
532
+ display: block;
533
+ font-size: 1rem;
534
+ line-height: 1.35;
535
+ color: #403a67;
536
+ overflow-wrap: anywhere;
537
+ word-break: break-word;
538
+ white-space: normal;
539
+ }
540
+
541
+ .author-person-summary {
542
+ font-size: 0.84rem;
543
+ line-height: 1.55;
544
+ color: #6f6996;
545
+ overflow-wrap: anywhere;
546
+ word-break: break-word;
547
+ white-space: normal;
548
+ }
549
+
550
+ .author-person-body {
551
+ min-width: 0;
552
+ margin: 0 14px 14px;
553
+ padding-top: 12px;
554
+ border-top: 1px solid rgba(187, 171, 227, 0.2);
555
+ display: grid;
556
+ gap: 8px;
557
+ }
558
+
559
+ .author-person-body > * {
560
+ min-width: 0;
561
+ }
562
+
563
+ .author-person-meta {
564
+ min-width: 0;
565
+ display: grid;
566
+ gap: 8px;
567
+ }
568
+
569
+ .author-person-meta-row {
570
+ min-width: 0;
571
+ display: grid;
572
+ grid-template-columns: 1fr;
573
+ gap: 2px;
574
+ align-items: start;
575
+ }
576
+
577
+ .author-person-meta-label {
578
+ font-size: 0.75rem;
579
+ font-weight: 700;
580
+ letter-spacing: 0.03em;
581
+ color: #8a84b2;
582
+ white-space: normal;
583
+ }
584
+
585
+ .author-person-meta-value {
586
+ min-width: 0;
587
+ font-size: 0.88rem;
588
+ line-height: 1.4;
589
+ font-weight: 700;
590
+ color: #4e4878;
591
+ overflow-wrap: anywhere;
592
+ word-break: break-word;
593
+ white-space: normal;
594
+ }
595
+
596
+ .author-footer {
597
+ padding-top: 2px;
598
+ }
599
+
600
+ .author-footer p {
601
+ font-size: 0.9rem;
602
+ color: #6b648d;
603
+ overflow-wrap: anywhere;
604
+ word-break: break-word;
605
+ white-space: normal;
606
+ }
607
+
608
+ .workspace {
609
+ display: flex;
610
+ flex-direction: column;
611
+ min-width: 0;
612
+ background:
613
+ radial-gradient(circle at 50% 24%, rgba(92, 99, 231, 0.12), transparent 22%),
614
+ linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 244, 255, 0.9));
615
+ }
616
+
617
+ .topbar {
618
+ min-height: auto;
619
+ padding: 42px 34px 10px;
620
+ display: flex;
621
+ justify-content: center;
622
+ text-align: center;
623
+ background: transparent;
624
+ }
625
+
626
+ .identity {
627
+ display: grid;
628
+ justify-items: center;
629
+ gap: 16px;
630
+ }
631
+
632
+ .logo {
633
+ width: clamp(88px, 10vw, 110px);
634
+ height: clamp(88px, 10vw, 110px);
635
+ object-fit: contain;
636
+ flex: none;
637
+ filter: drop-shadow(0 12px 24px rgba(92, 99, 231, 0.12));
638
+ }
639
+
640
+ .identity-copy {
641
+ display: grid;
642
+ justify-items: center;
643
+ gap: 8px;
644
+ }
645
+
646
+ .identity-copy h1,
647
+ .identity-copy p,
648
+ .hero-copy h2,
649
+ .button-label {
650
+ margin: 0;
651
+ }
652
+
653
+ .identity-copy h1 {
654
+ max-width: none;
655
+ font-size: clamp(1.55rem, 2.45vw, 2.55rem);
656
+ line-height: 1.1;
657
+ font-weight: 800;
658
+ letter-spacing: -0.04em;
659
+ color: #22203d;
660
+ white-space: nowrap;
661
+ }
662
+
663
+ .identity-copy p {
664
+ font-size: clamp(1.08rem, 1.38vw, 1.42rem);
665
+ line-height: 1.2;
666
+ font-weight: 700;
667
+ color: #4d466f;
668
+ text-wrap: balance;
669
+ }
670
+
671
+ .hero-panel {
672
+ padding: 0 34px 18px;
673
+ display: grid;
674
+ justify-items: center;
675
+ gap: 10px;
676
+ text-align: center;
677
+ }
678
+
679
+ .hero-copy {
680
+ width: min(100%, 1180px);
681
+ display: grid;
682
+ justify-items: center;
683
+ }
684
+
685
+ .hero-copy h2 {
686
+ max-width: none;
687
+ min-height: auto;
688
+ font-size: clamp(1.65rem, 3vw, 2.9rem);
689
+ line-height: 1.12;
690
+ font-weight: 800;
691
+ letter-spacing: -0.04em;
692
+ color: var(--accent-strong);
693
+ white-space: nowrap;
694
+ }
695
+
696
+ .typewriter-text {
697
+ position: relative;
698
+ display: inline-block;
699
+ padding: 0.04em 0.08em 0.08em;
700
+ opacity: 0;
701
+ transform: translateY(18px) scale(0.985);
702
+ filter: blur(10px);
703
+ transition:
704
+ opacity 0.75s ease,
705
+ transform 0.75s cubic-bezier(0.2, 0.8, 0.2, 1),
706
+ filter 0.75s ease;
707
+ overflow: hidden;
708
+ }
709
+
710
+ .typewriter-text::before {
711
+ content: "";
712
+ position: absolute;
713
+ inset: -8% -5%;
714
+ background: linear-gradient(
715
+ 112deg,
716
+ transparent 0%,
717
+ rgba(255, 255, 255, 0) 38%,
718
+ rgba(255, 255, 255, 0.78) 49%,
719
+ rgba(255, 255, 255, 0.18) 56%,
720
+ transparent 66%
721
+ );
722
+ transform: translateX(-135%) skewX(-18deg);
723
+ opacity: 0;
724
+ pointer-events: none;
725
+ }
726
+
727
+ .typewriter-text.is-ready {
728
+ opacity: 1;
729
+ transform: translateY(0) scale(1);
730
+ filter: blur(0);
731
+ text-shadow: 0 16px 28px rgba(92, 99, 231, 0.12);
732
+ }
733
+
734
+ .typewriter-text.is-ready::before {
735
+ opacity: 1;
736
+ animation: title-sheen 1.45s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
737
+ }
738
+
739
+ .result-card {
740
+ margin: 6px 34px 18px;
741
+ padding: 0;
742
+ min-height: 0;
743
+ position: relative;
744
+ background: transparent;
745
+ border: 0;
746
+ box-shadow: none;
747
+ overflow: visible;
748
+ }
749
+
750
+ .result-card.is-visible {
751
+ animation: result-card-in 0.3s ease;
752
+ }
753
+
754
+ .result-card.is-updating {
755
+ box-shadow: none;
756
+ }
757
+
758
+ .result-feed {
759
+ display: grid;
760
+ gap: 16px;
761
+ }
762
+
763
+ .result-thread-item {
764
+ padding: 22px 24px;
765
+ border-radius: 24px;
766
+ background: rgba(255, 255, 255, 0.96);
767
+ border: 1px solid rgba(132, 141, 231, 0.14);
768
+ box-shadow: 0 14px 28px rgba(92, 99, 231, 0.06);
769
+ }
770
+
771
+ .result-thread-item:nth-child(even) {
772
+ background: rgba(255, 253, 249, 0.96);
773
+ border-color: rgba(240, 191, 143, 0.18);
774
+ }
775
+
776
+ .atom-loader {
777
+ --atom-size: 58px;
778
+ --atom-border: rgba(92, 99, 231, 0.26);
779
+ --atom-glow: rgba(92, 99, 231, 0.2);
780
+ position: relative;
781
+ width: var(--atom-size);
782
+ height: var(--atom-size);
783
+ display: inline-grid;
784
+ place-items: center;
785
+ border-radius: 50%;
786
+ filter: drop-shadow(0 10px 22px var(--atom-glow));
787
+ }
788
+
789
+ .atom-loader-sm {
790
+ --atom-size: 30px;
791
+ position: absolute;
792
+ left: 18px;
793
+ top: 50%;
794
+ transform: translateY(-50%);
795
+ z-index: 1;
796
+ }
797
+
798
+ .atom-loader-inline {
799
+ --atom-size: 42px;
800
+ }
801
+
802
+ .atom-core {
803
+ width: calc(var(--atom-size) * 0.28);
804
+ height: calc(var(--atom-size) * 0.28);
805
+ border-radius: 50%;
806
+ background: radial-gradient(circle at 35% 35%, #ffffff 0%, #ffe4eb 28%, #9ba9ff 68%, #5c63e7 100%);
807
+ box-shadow:
808
+ 0 0 0 calc(var(--atom-size) * 0.085) rgba(255, 255, 255, 0.28),
809
+ 0 0 calc(var(--atom-size) * 0.34) rgba(92, 99, 231, 0.24);
810
+ position: relative;
811
+ z-index: 2;
812
+ }
813
+
814
+ .atom-orbit {
815
+ position: absolute;
816
+ inset: 6%;
817
+ border: 1.5px solid var(--atom-border);
818
+ border-radius: 50%;
819
+ will-change: transform;
820
+ }
821
+
822
+ .atom-orbit-a {
823
+ transform: rotate(10deg);
824
+ }
825
+
826
+ .atom-orbit-b {
827
+ inset: 14%;
828
+ transform: rotate(72deg);
829
+ }
830
+
831
+ .atom-orbit-c {
832
+ inset: 14%;
833
+ transform: rotate(-58deg);
834
+ }
835
+
836
+ .atom-electron {
837
+ position: absolute;
838
+ width: calc(var(--atom-size) * 0.12);
839
+ height: calc(var(--atom-size) * 0.12);
840
+ border-radius: 50%;
841
+ box-shadow: 0 0 calc(var(--atom-size) * 0.18) rgba(255, 255, 255, 0.34);
842
+ }
843
+
844
+ .atom-orbit-a .atom-electron {
845
+ top: calc(var(--atom-size) * -0.045);
846
+ left: 50%;
847
+ transform: translateX(-50%);
848
+ background: radial-gradient(circle at 35% 35%, #ffffff 0%, #ffd7df 38%, #ff8ba7 100%);
849
+ }
850
+
851
+ .atom-orbit-b .atom-electron {
852
+ bottom: calc(var(--atom-size) * -0.05);
853
+ left: 50%;
854
+ transform: translateX(-50%);
855
+ background: radial-gradient(circle at 35% 35%, #ffffff 0%, #dbe2ff 42%, #7e90ff 100%);
856
+ }
857
+
858
+ .atom-orbit-c .atom-electron {
859
+ top: 50%;
860
+ right: calc(var(--atom-size) * -0.05);
861
+ transform: translateY(-50%);
862
+ background: radial-gradient(circle at 35% 35%, #ffffff 0%, #ffe6b9 40%, #f0b558 100%);
863
+ }
864
+
865
+ body.is-generating .result-card:not(.has-entry) .atom-orbit-a,
866
+ .generate-button.is-loading .atom-orbit-a {
867
+ animation: atom-orbit-a-spin 1.75s linear infinite;
868
+ }
869
+
870
+ body.is-generating .result-card:not(.has-entry) .atom-orbit-b,
871
+ .generate-button.is-loading .atom-orbit-b {
872
+ animation: atom-orbit-b-spin 1.2s linear infinite;
873
+ }
874
+
875
+ body.is-generating .result-card:not(.has-entry) .atom-orbit-c,
876
+ .generate-button.is-loading .atom-orbit-c {
877
+ animation: atom-orbit-c-spin 2.25s linear infinite;
878
+ }
879
+
880
+ body.is-generating .result-card:not(.has-entry) .atom-core,
881
+ .generate-button.is-loading .atom-core {
882
+ animation: atom-core-pulse 1s ease-in-out infinite alternate;
883
+ }
884
+
885
+ .result-meta {
886
+ display: flex;
887
+ flex-wrap: wrap;
888
+ gap: 8px;
889
+ margin-bottom: 16px;
890
+ }
891
+
892
+ .result-meta span {
893
+ min-height: 32px;
894
+ padding: 0 12px;
895
+ border-radius: 999px;
896
+ background: rgba(235, 238, 255, 0.9);
897
+ color: var(--accent-strong);
898
+ display: inline-flex;
899
+ align-items: center;
900
+ font-size: 0.82rem;
901
+ font-weight: 700;
902
+ line-height: 1;
903
+ }
904
+
905
+ .result-meta span:nth-child(4n + 2) {
906
+ background: rgba(255, 235, 240, 0.9);
907
+ color: #b44c70;
908
+ }
909
+
910
+ .result-meta span:nth-child(4n + 3) {
911
+ background: rgba(255, 243, 223, 0.95);
912
+ color: #9f6e19;
913
+ }
914
+
915
+ .result-meta span:nth-child(4n + 4) {
916
+ background: rgba(234, 246, 255, 0.95);
917
+ color: #356c97;
918
+ }
919
+
920
+ .result-meta span + span::before {
921
+ content: none;
922
+ }
923
+
924
+ .result-section {
925
+ padding: 0;
926
+ border: 0;
927
+ border-radius: 0;
928
+ background: transparent;
929
+ }
930
+
931
+ .result-section + .result-section {
932
+ margin-top: 18px;
933
+ padding-top: 18px;
934
+ border-top: 1px solid rgba(132, 141, 231, 0.14);
935
+ }
936
+
937
+ .result-source-title,
938
+ .result-questions-title {
939
+ margin: 0;
940
+ min-height: 32px;
941
+ padding: 0 14px;
942
+ border-radius: 999px;
943
+ display: inline-flex;
944
+ align-items: center;
945
+ font-size: 0.78rem;
946
+ font-weight: 800;
947
+ letter-spacing: 0.04em;
948
+ }
949
+
950
+ .result-source-title {
951
+ background: rgba(236, 238, 255, 0.92);
952
+ color: var(--accent-strong);
953
+ }
954
+
955
+ .result-questions-title {
956
+ background: rgba(255, 244, 225, 0.96);
957
+ color: #9f6e19;
958
+ }
959
+
960
+ .result-section-head {
961
+ display: flex;
962
+ align-items: center;
963
+ justify-content: space-between;
964
+ gap: 12px;
965
+ margin-bottom: 10px;
966
+ }
967
+
968
+ .copy-button {
969
+ width: auto;
970
+ height: auto;
971
+ padding: 4px;
972
+ border: 0;
973
+ border-radius: 10px;
974
+ background: transparent;
975
+ color: #68639a;
976
+ display: inline-grid;
977
+ place-items: center;
978
+ cursor: pointer;
979
+ transition: background 0.18s ease, color 0.18s ease;
980
+ }
981
+
982
+ .copy-button:hover {
983
+ background: rgba(235, 238, 255, 0.78);
984
+ color: var(--accent-strong);
985
+ }
986
+
987
+ .copy-button.is-copied {
988
+ background: rgba(226, 244, 233, 0.92);
989
+ color: #2f8a54;
990
+ }
991
+
992
+ .copy-button svg {
993
+ width: 17px;
994
+ height: 17px;
995
+ }
996
+
997
+ .result-source,
998
+ .result-note,
999
+ .result-message {
1000
+ margin: 0;
1001
+ padding: 0;
1002
+ line-height: 1.8;
1003
+ }
1004
+
1005
+ .result-source {
1006
+ background: transparent;
1007
+ border: 0;
1008
+ white-space: pre-wrap;
1009
+ }
1010
+
1011
+ .result-questions {
1012
+ display: grid;
1013
+ gap: 0;
1014
+ list-style: none;
1015
+ padding: 0;
1016
+ margin: 0;
1017
+ counter-reset: question;
1018
+ }
1019
+
1020
+ .result-questions li {
1021
+ position: relative;
1022
+ padding: 12px 0 12px 32px;
1023
+ background: transparent;
1024
+ border: 0;
1025
+ line-height: 1.75;
1026
+ counter-increment: question;
1027
+ }
1028
+
1029
+ .result-questions li + li {
1030
+ border-top: 1px solid rgba(132, 141, 231, 0.12);
1031
+ }
1032
+
1033
+ .result-questions li::before {
1034
+ content: counter(question) ".";
1035
+ position: absolute;
1036
+ left: 0;
1037
+ top: 12px;
1038
+ width: auto;
1039
+ height: auto;
1040
+ border-radius: 0;
1041
+ background: transparent;
1042
+ color: var(--accent-strong);
1043
+ display: inline-block;
1044
+ font-size: 0.84rem;
1045
+ font-weight: 700;
1046
+ }
1047
+
1048
+ .result-note {
1049
+ color: #726c9a;
1050
+ }
1051
+
1052
+ .result-pending {
1053
+ display: flex;
1054
+ align-items: center;
1055
+ gap: 14px;
1056
+ padding: 4px 0;
1057
+ background: transparent;
1058
+ }
1059
+
1060
+ .result-pending .result-note {
1061
+ padding: 0;
1062
+ background: transparent;
1063
+ }
1064
+
1065
+ .result-pending .atom-orbit-a {
1066
+ animation: atom-orbit-a-spin 1.75s linear infinite;
1067
+ }
1068
+
1069
+ .result-pending .atom-orbit-b {
1070
+ animation: atom-orbit-b-spin 1.2s linear infinite;
1071
+ }
1072
+
1073
+ .result-pending .atom-orbit-c {
1074
+ animation: atom-orbit-c-spin 2.25s linear infinite;
1075
+ }
1076
+
1077
+ .result-pending .atom-core {
1078
+ animation: atom-core-pulse 1s ease-in-out infinite alternate;
1079
+ }
1080
+
1081
+ .result-message {
1082
+ color: #9f3d61;
1083
+ }
1084
+
1085
+ .result-message-inline {
1086
+ margin: 0 0 14px;
1087
+ }
1088
+
1089
+ .landing-panel {
1090
+ margin: 0 18px 18px;
1091
+ display: grid;
1092
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(280px, 0.95fr);
1093
+ gap: 16px;
1094
+ }
1095
+
1096
+ .landing-card {
1097
+ padding: 20px 20px 18px;
1098
+ border-radius: 24px;
1099
+ background: linear-gradient(180deg, rgba(250, 249, 255, 0.98), rgba(255, 255, 255, 0.94));
1100
+ border: 1px solid rgba(143, 154, 238, 0.16);
1101
+ box-shadow: 0 14px 28px rgba(92, 99, 231, 0.06);
1102
+ display: grid;
1103
+ gap: 14px;
1104
+ }
1105
+
1106
+ .landing-card-head {
1107
+ padding: 14px 16px;
1108
+ border-radius: 18px;
1109
+ border: 1px solid rgba(146, 156, 239, 0.14);
1110
+ background: rgba(255, 255, 255, 0.78);
1111
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
1112
+ display: flex;
1113
+ align-items: start;
1114
+ justify-content: space-between;
1115
+ gap: 12px;
1116
+ flex-wrap: wrap;
1117
+ }
1118
+
1119
+ .landing-kicker,
1120
+ .landing-card-note,
1121
+ .landing-guide-list {
1122
+ margin: 0;
1123
+ }
1124
+
1125
+ .landing-kicker {
1126
+ font-size: 0.8rem;
1127
+ font-weight: 800;
1128
+ letter-spacing: 0.04em;
1129
+ color: #7b75a6;
1130
+ flex: none;
1131
+ }
1132
+
1133
+ .landing-card-note {
1134
+ font-size: 0.88rem;
1135
+ line-height: 1.65;
1136
+ color: #807aa8;
1137
+ flex: 1 1 220px;
1138
+ min-width: 0;
1139
+ }
1140
+
1141
+ .landing-samples .landing-card-head {
1142
+ display: grid;
1143
+ grid-template-columns: 1fr;
1144
+ align-items: start;
1145
+ gap: 8px;
1146
+ }
1147
+
1148
+ .landing-samples .landing-kicker {
1149
+ white-space: nowrap;
1150
+ }
1151
+
1152
+ .landing-samples .landing-card-note {
1153
+ white-space: normal;
1154
+ }
1155
+
1156
+ .landing-samples .landing-card-note {
1157
+ font-size: 0.84rem;
1158
+ line-height: 1.4;
1159
+ }
1160
+
1161
+ .landing-guide-list {
1162
+ padding: 0;
1163
+ list-style: none;
1164
+ counter-reset: landing-step;
1165
+ display: grid;
1166
+ gap: 10px;
1167
+ color: #4f4a79;
1168
+ line-height: 1.65;
1169
+ }
1170
+
1171
+ .landing-guide-list li {
1172
+ position: relative;
1173
+ padding: 14px 16px 14px 50px;
1174
+ border-radius: 18px;
1175
+ border: 1px solid rgba(146, 156, 239, 0.14);
1176
+ background: rgba(255, 255, 255, 0.78);
1177
+ counter-increment: landing-step;
1178
+ }
1179
+
1180
+ .landing-guide-list li::before {
1181
+ content: counter(landing-step);
1182
+ position: absolute;
1183
+ left: 16px;
1184
+ top: 14px;
1185
+ width: 22px;
1186
+ height: 22px;
1187
+ border-radius: 999px;
1188
+ background: rgba(92, 99, 231, 0.12);
1189
+ color: var(--accent-strong);
1190
+ display: inline-grid;
1191
+ place-items: center;
1192
+ font-size: 0.76rem;
1193
+ font-weight: 800;
1194
+ line-height: 1;
1195
+ }
1196
+
1197
+ .landing-guide-list strong {
1198
+ color: var(--accent-strong);
1199
+ }
1200
+
1201
+ .landing-sample-grid {
1202
+ display: grid;
1203
+ gap: 12px;
1204
+ }
1205
+
1206
+ .sample-card {
1207
+ width: 100%;
1208
+ padding: 14px 16px;
1209
+ border: 1px solid rgba(146, 156, 239, 0.16);
1210
+ border-radius: 18px;
1211
+ background: rgba(255, 255, 255, 0.84);
1212
+ color: inherit;
1213
+ display: grid;
1214
+ gap: 6px;
1215
+ text-align: left;
1216
+ cursor: pointer;
1217
+ transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
1218
+ }
1219
+
1220
+ .sample-card:hover {
1221
+ transform: translateY(-1px);
1222
+ border-color: rgba(92, 99, 231, 0.24);
1223
+ background: rgba(255, 255, 255, 0.96);
1224
+ box-shadow: 0 12px 22px rgba(92, 99, 231, 0.08);
1225
+ }
1226
+
1227
+ .sample-card strong,
1228
+ .sample-card span {
1229
+ display: block;
1230
+ }
1231
+
1232
+ .sample-card strong {
1233
+ font-size: 0.95rem;
1234
+ color: #474271;
1235
+ }
1236
+
1237
+ .sample-card span {
1238
+ font-size: 0.84rem;
1239
+ line-height: 1.55;
1240
+ color: #7d78a6;
1241
+ }
1242
+
1243
+ .landing-runtime-badge {
1244
+ min-height: 30px;
1245
+ padding: 0 12px;
1246
+ border-radius: 999px;
1247
+ display: inline-flex;
1248
+ align-items: center;
1249
+ flex: none;
1250
+ font-size: 0.78rem;
1251
+ font-weight: 800;
1252
+ letter-spacing: 0.02em;
1253
+ }
1254
+
1255
+ .landing-runtime-badge.is-ready {
1256
+ background: rgba(227, 244, 233, 0.92);
1257
+ color: #2f8a54;
1258
+ }
1259
+
1260
+ .landing-runtime-badge.is-pending {
1261
+ background: rgba(236, 238, 255, 0.92);
1262
+ color: var(--accent-strong);
1263
+ }
1264
+
1265
+ .landing-runtime-badge.is-error {
1266
+ background: rgba(255, 235, 240, 0.92);
1267
+ color: #b44c70;
1268
+ }
1269
+
1270
+ .landing-system > .landing-card-note {
1271
+ padding: 14px 16px;
1272
+ border-radius: 18px;
1273
+ border: 1px solid rgba(146, 156, 239, 0.14);
1274
+ background: rgba(255, 255, 255, 0.78);
1275
+ }
1276
+
1277
+ .landing-system-list {
1278
+ display: grid;
1279
+ gap: 10px;
1280
+ }
1281
+
1282
+ .landing-system-row {
1283
+ display: grid;
1284
+ gap: 4px;
1285
+ padding: 14px 16px;
1286
+ border: 1px solid rgba(146, 156, 239, 0.14);
1287
+ border-radius: 18px;
1288
+ background: rgba(255, 255, 255, 0.78);
1289
+ }
1290
+
1291
+ .landing-system-row:first-child {
1292
+ padding-top: 14px;
1293
+ }
1294
+
1295
+ .landing-system-row span,
1296
+ .landing-system-row strong {
1297
+ display: block;
1298
+ }
1299
+
1300
+ .landing-system-row span {
1301
+ font-size: 0.76rem;
1302
+ font-weight: 700;
1303
+ letter-spacing: 0.03em;
1304
+ color: #8b86b2;
1305
+ }
1306
+
1307
+ .landing-system-row strong {
1308
+ font-size: 0.96rem;
1309
+ line-height: 1.45;
1310
+ color: #474271;
1311
+ overflow-wrap: anywhere;
1312
+ word-break: break-word;
1313
+ }
1314
+
1315
+ .composer {
1316
+ margin: 0 18px 18px;
1317
+ padding: 20px 22px;
1318
+ border-radius: 28px;
1319
+ background: linear-gradient(180deg, rgba(247, 248, 255, 0.96), rgba(255, 255, 255, 0.94));
1320
+ border-color: rgba(143, 154, 238, 0.22);
1321
+ }
1322
+
1323
+ .input-shell {
1324
+ min-width: 0;
1325
+ display: flex;
1326
+ flex-direction: column;
1327
+ align-items: stretch;
1328
+ gap: 18px;
1329
+ min-height: 128px;
1330
+ padding: 0;
1331
+ border: 0;
1332
+ background: transparent;
1333
+ transition:
1334
+ min-height 0.22s ease,
1335
+ padding 0.22s ease;
1336
+ }
1337
+
1338
+ .input-shell.is-expanded {
1339
+ min-height: 172px;
1340
+ }
1341
+
1342
+ .visually-hidden {
1343
+ position: absolute;
1344
+ width: 1px;
1345
+ height: 1px;
1346
+ padding: 0;
1347
+ margin: -1px;
1348
+ overflow: hidden;
1349
+ clip: rect(0, 0, 0, 0);
1350
+ white-space: nowrap;
1351
+ border: 0;
1352
+ }
1353
+
1354
+ .input-shell textarea {
1355
+ width: 100%;
1356
+ min-height: 30px;
1357
+ max-height: 240px;
1358
+ border: 0;
1359
+ outline: none;
1360
+ resize: none;
1361
+ background: transparent;
1362
+ color: #4b4670;
1363
+ line-height: 1.72;
1364
+ padding: 0;
1365
+ transition: height 0.18s ease;
1366
+ }
1367
+
1368
+ .input-shell textarea::placeholder {
1369
+ color: #8e88b6;
1370
+ }
1371
+
1372
+ .voice-status {
1373
+ min-height: 0;
1374
+ font-size: 0.82rem;
1375
+ color: #7f7aa8;
1376
+ line-height: 1.5;
1377
+ max-width: min(100%, 420px);
1378
+ text-align: right;
1379
+ }
1380
+
1381
+ .voice-status.is-empty {
1382
+ display: none;
1383
+ }
1384
+
1385
+ .voice-status.is-active {
1386
+ color: var(--accent-strong);
1387
+ }
1388
+
1389
+ .voice-status.is-error {
1390
+ color: #b44c70;
1391
+ }
1392
+
1393
+ .voice-button {
1394
+ width: 42px;
1395
+ min-width: 42px;
1396
+ min-height: 42px;
1397
+ padding: 0;
1398
+ border: 1px solid rgba(128, 138, 235, 0.2);
1399
+ border-radius: 999px;
1400
+ background: rgba(240, 242, 255, 0.82);
1401
+ color: #5f5aa0;
1402
+ display: inline-flex;
1403
+ align-items: center;
1404
+ justify-content: center;
1405
+ cursor: pointer;
1406
+ transition:
1407
+ transform 0.18s ease,
1408
+ box-shadow 0.18s ease,
1409
+ border-color 0.18s ease,
1410
+ background 0.18s ease,
1411
+ color 0.18s ease;
1412
+ }
1413
+
1414
+ .voice-button:hover:not(:disabled) {
1415
+ transform: translateY(-1px);
1416
+ border-color: rgba(92, 99, 231, 0.3);
1417
+ background: rgba(235, 238, 255, 0.94);
1418
+ box-shadow: 0 10px 20px rgba(92, 99, 231, 0.08);
1419
+ }
1420
+
1421
+ .voice-button.is-listening {
1422
+ border-color: rgba(224, 96, 124, 0.28);
1423
+ background: rgba(255, 235, 240, 0.92);
1424
+ color: #b44c70;
1425
+ box-shadow: 0 0 0 6px rgba(224, 96, 124, 0.08);
1426
+ }
1427
+
1428
+ .voice-button:disabled,
1429
+ .voice-button.is-unsupported {
1430
+ opacity: 0.56;
1431
+ cursor: not-allowed;
1432
+ box-shadow: none;
1433
+ }
1434
+
1435
+ .voice-button-icon {
1436
+ width: 18px;
1437
+ height: 18px;
1438
+ display: inline-flex;
1439
+ }
1440
+
1441
+ .voice-button-icon svg {
1442
+ width: 100%;
1443
+ height: 100%;
1444
+ }
1445
+
1446
+ .composer-actions {
1447
+ display: flex;
1448
+ align-items: end;
1449
+ justify-content: space-between;
1450
+ gap: 14px;
1451
+ padding-top: 16px;
1452
+ border-top: 1px solid rgba(132, 141, 231, 0.12);
1453
+ }
1454
+
1455
+ .action-cluster {
1456
+ min-width: 0;
1457
+ margin-left: auto;
1458
+ display: grid;
1459
+ justify-items: end;
1460
+ gap: 10px;
1461
+ }
1462
+
1463
+ .action-buttons {
1464
+ display: flex;
1465
+ align-items: center;
1466
+ justify-content: flex-end;
1467
+ gap: 10px;
1468
+ min-width: 0;
1469
+ }
1470
+
1471
+ .count-shell {
1472
+ min-height: 0;
1473
+ padding: 0;
1474
+ display: inline-grid;
1475
+ gap: 8px;
1476
+ color: #6a6493;
1477
+ white-space: nowrap;
1478
+ }
1479
+
1480
+ .count-label {
1481
+ font-size: 0.78rem;
1482
+ font-weight: 500;
1483
+ color: #7a75a6;
1484
+ }
1485
+
1486
+ .count-stepper {
1487
+ display: inline-grid;
1488
+ grid-template-columns: 42px minmax(62px, auto) 42px;
1489
+ align-items: center;
1490
+ gap: 8px;
1491
+ }
1492
+
1493
+ .count-button {
1494
+ width: 42px;
1495
+ height: 42px;
1496
+ border: 0;
1497
+ border-radius: 12px;
1498
+ background: linear-gradient(180deg, rgba(231, 235, 255, 0.98), rgba(246, 244, 255, 0.96));
1499
+ color: var(--accent-strong);
1500
+ display: inline-grid;
1501
+ place-items: center;
1502
+ font-weight: 700;
1503
+ cursor: pointer;
1504
+ transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
1505
+ }
1506
+
1507
+ .count-button:hover:not(:disabled) {
1508
+ transform: translateY(-1px);
1509
+ box-shadow: 0 10px 20px rgba(92, 99, 231, 0.14);
1510
+ }
1511
+
1512
+ .count-button:disabled {
1513
+ opacity: 0.42;
1514
+ cursor: default;
1515
+ }
1516
+
1517
+ .count-button span {
1518
+ font-size: 1.3rem;
1519
+ line-height: 1;
1520
+ }
1521
+
1522
+ .count-value {
1523
+ min-width: 62px;
1524
+ min-height: 42px;
1525
+ border-radius: 12px;
1526
+ background: rgba(240, 242, 255, 0.7);
1527
+ color: #4f4a7a;
1528
+ display: inline-grid;
1529
+ place-items: center;
1530
+ font-weight: 800;
1531
+ }
1532
+
1533
+ .generate-button {
1534
+ min-width: 214px;
1535
+ min-height: 58px;
1536
+ padding: 0 20px 0 62px;
1537
+ border-radius: 16px;
1538
+ border: 0;
1539
+ background: linear-gradient(135deg, var(--accent), var(--warm));
1540
+ box-shadow: 0 14px 30px rgba(93, 99, 190, 0.22);
1541
+ color: #fff;
1542
+ position: relative;
1543
+ overflow: hidden;
1544
+ display: inline-flex;
1545
+ align-items: center;
1546
+ justify-content: center;
1547
+ gap: 12px;
1548
+ cursor: pointer;
1549
+ transition: transform 0.18s ease, box-shadow 0.18s ease;
1550
+ }
1551
+
1552
+ .generate-button:hover:not(:disabled) {
1553
+ transform: translateY(-1px);
1554
+ box-shadow: 0 18px 34px rgba(93, 99, 190, 0.26);
1555
+ }
1556
+
1557
+ .generate-button:disabled {
1558
+ cursor: wait;
1559
+ }
1560
+
1561
+ .generate-button::before {
1562
+ content: "";
1563
+ position: absolute;
1564
+ inset: 1px;
1565
+ border-radius: inherit;
1566
+ background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 48%, rgba(255, 255, 255, 0.1));
1567
+ }
1568
+
1569
+ .generate-button .atom-loader {
1570
+ --atom-border: rgba(255, 255, 255, 0.34);
1571
+ --atom-glow: rgba(255, 255, 255, 0.28);
1572
+ opacity: 0.94;
1573
+ transition: transform 0.24s ease, opacity 0.24s ease, filter 0.24s ease;
1574
+ }
1575
+
1576
+ .generate-button .atom-core {
1577
+ background: radial-gradient(circle at 35% 35%, #ffffff 0%, #ffe7ed 30%, #ffc9d4 58%, #ffffff 100%);
1578
+ box-shadow:
1579
+ 0 0 0 calc(var(--atom-size) * 0.085) rgba(255, 255, 255, 0.16),
1580
+ 0 0 calc(var(--atom-size) * 0.26) rgba(255, 255, 255, 0.22);
1581
+ }
1582
+
1583
+ .generate-button.is-loading .atom-loader {
1584
+ opacity: 1;
1585
+ filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.32));
1586
+ }
1587
+
1588
+ .button-label {
1589
+ font-size: 0.96rem;
1590
+ font-weight: 700;
1591
+ position: relative;
1592
+ z-index: 1;
1593
+ }
1594
+
1595
+ @keyframes result-card-in {
1596
+ from {
1597
+ opacity: 0;
1598
+ transform: translateY(16px);
1599
+ }
1600
+
1601
+ to {
1602
+ opacity: 1;
1603
+ transform: translateY(0);
1604
+ }
1605
+ }
1606
+
1607
+ @keyframes atom-core-pulse {
1608
+ from {
1609
+ transform: scale(0.92);
1610
+ }
1611
+
1612
+ to {
1613
+ transform: scale(1.1);
1614
+ }
1615
+ }
1616
+
1617
+ @keyframes atom-orbit-a-spin {
1618
+ from {
1619
+ transform: rotate(10deg);
1620
+ }
1621
+
1622
+ to {
1623
+ transform: rotate(370deg);
1624
+ }
1625
+ }
1626
+
1627
+ @keyframes atom-orbit-b-spin {
1628
+ from {
1629
+ transform: rotate(72deg);
1630
+ }
1631
+
1632
+ to {
1633
+ transform: rotate(-288deg);
1634
+ }
1635
+ }
1636
+
1637
+ @keyframes atom-orbit-c-spin {
1638
+ from {
1639
+ transform: rotate(-58deg);
1640
+ }
1641
+
1642
+ to {
1643
+ transform: rotate(302deg);
1644
+ }
1645
+ }
1646
+
1647
+ @keyframes title-sheen {
1648
+ 0% {
1649
+ transform: translateX(-135%) skewX(-18deg);
1650
+ }
1651
+
1652
+ 100% {
1653
+ transform: translateX(135%) skewX(-18deg);
1654
+ }
1655
+ }
1656
+
1657
+ @media (max-width: 1180px) {
1658
+ .landing-panel {
1659
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1660
+ }
1661
+
1662
+ .landing-system {
1663
+ grid-column: 1 / -1;
1664
+ }
1665
+
1666
+ .composer-actions {
1667
+ flex-direction: column;
1668
+ align-items: stretch;
1669
+ }
1670
+
1671
+ .action-cluster {
1672
+ width: 100%;
1673
+ justify-items: stretch;
1674
+ }
1675
+
1676
+ .action-buttons {
1677
+ width: 100%;
1678
+ justify-content: flex-start;
1679
+ }
1680
+
1681
+ .voice-status {
1682
+ max-width: none;
1683
+ text-align: left;
1684
+ }
1685
+
1686
+ .count-shell {
1687
+ width: 100%;
1688
+ }
1689
+
1690
+ .action-buttons .generate-button {
1691
+ width: auto;
1692
+ min-width: 0;
1693
+ flex: 1 1 auto;
1694
+ }
1695
+ }
1696
+
1697
+ @media (max-width: 900px) {
1698
+ .page-shell {
1699
+ width: 100%;
1700
+ min-height: 100vh;
1701
+ margin: 0;
1702
+ border-radius: 0;
1703
+ grid-template-columns: 1fr;
1704
+ }
1705
+
1706
+ body.sidebar-open .page-shell,
1707
+ .page-shell {
1708
+ grid-template-columns: 1fr;
1709
+ }
1710
+
1711
+ .sidebar {
1712
+ border-right: 0;
1713
+ border-bottom: 1px solid var(--line);
1714
+ }
1715
+
1716
+ .topbar,
1717
+ .hero-panel {
1718
+ padding-left: 20px;
1719
+ padding-right: 20px;
1720
+ }
1721
+
1722
+ .result-card {
1723
+ margin-left: 20px;
1724
+ margin-right: 20px;
1725
+ }
1726
+
1727
+ .landing-panel {
1728
+ margin-left: 12px;
1729
+ margin-right: 12px;
1730
+ grid-template-columns: 1fr;
1731
+ }
1732
+
1733
+ .landing-system {
1734
+ grid-column: auto;
1735
+ }
1736
+
1737
+ .landing-samples .landing-card-head {
1738
+ grid-template-columns: 1fr;
1739
+ }
1740
+
1741
+ .landing-samples .landing-kicker,
1742
+ .landing-samples .landing-card-note {
1743
+ white-space: normal;
1744
+ }
1745
+
1746
+ .composer {
1747
+ margin-left: 12px;
1748
+ margin-right: 12px;
1749
+ }
1750
+ }
1751
+
1752
+ @media (max-width: 760px) {
1753
+ .identity-copy h1,
1754
+ .hero-copy h2 {
1755
+ white-space: normal;
1756
+ }
1757
+ }
1758
+
1759
+ @media (max-width: 640px) {
1760
+ .topbar {
1761
+ padding-top: 30px;
1762
+ }
1763
+
1764
+ .logo {
1765
+ width: 68px;
1766
+ height: 68px;
1767
+ }
1768
+
1769
+ .hero-copy h2 {
1770
+ font-size: clamp(1.35rem, 7.4vw, 2.1rem);
1771
+ min-height: auto;
1772
+ }
1773
+
1774
+ .result-card {
1775
+ min-height: 180px;
1776
+ padding: 0;
1777
+ }
1778
+
1779
+ .generate-button {
1780
+ min-width: 0;
1781
+ }
1782
+ }
1783
+
1784
+ @media (prefers-reduced-motion: reduce) {
1785
+ *,
1786
+ *::before,
1787
+ *::after {
1788
+ animation: none !important;
1789
+ transition: none !important;
1790
+ scroll-behavior: auto !important;
1791
+ }
1792
+ }