/* ===== CSS Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
  --max-width: 720px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== Header ===== */
.site-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
}
.site-header h1 { font-size: 1.8rem; font-weight: 800; }
.site-header .subtitle { font-size: .9rem; opacity: .9; margin-top: .25rem; }

/* ===== Layout ===== */
.container { max-width: var(--max-width); margin: 1.5rem auto; padding: 0 1rem; }

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}
.card h2 { font-size: 1.15rem; margin-bottom: 1rem; color: var(--accent); }
.card.hidden { display: none; }

/* ===== Form ===== */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .4rem;
  color: #374151;
}
.form-group .security-notice {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 4px;
  margin-left: .5rem;
  font-weight: 500;
}

input[type="url"],
input[type="password"],
textarea {
  width: 100%;
  padding: .7rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  transition: border-color .15s;
  background: #fafbfc;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.hint { font-size: .78rem; color: var(--text-secondary); margin-top: .25rem; }
.char-count { font-size: .75rem; color: var(--text-secondary); text-align: right; }
.status-box {
  padding: .7rem 1rem;
  border-radius: 8px;
  font-size: .85rem;
  margin-bottom: 1rem;
}
.status-box.success { background: #d1fae5; color: #065f46; }
.status-box.error { background: #fee2e2; color: #991b1b; }
.status-box.loading { background: #e0e7ff; color: #3730a3; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: .7rem 1.5rem;
  border-radius: 8px;
  border: none;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-generate {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(239,68,68,.3);
}
.btn-generate:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(239,68,68,.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--border);
  color: var(--text);
}

/* ===== Model Cards ===== */
.model-select { display: flex; gap: .75rem; flex-wrap: wrap; }
.model-card {
  flex: 1;
  min-width: 180px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.model-card.selected { border-color: var(--accent); background: #eef2ff; }
.model-card.disabled { opacity: .5; cursor: not-allowed; background: #f3f4f6; }
.model-card .model-name { font-weight: 700; font-size: .95rem; }
.model-card .model-id { font-size: .75rem; color: var(--text-secondary); margin: .2rem 0; }
.model-card .model-pricing { font-size: .7rem; color: var(--text-secondary); }
.model-card .model-pricing span { display: block; }
.model-card .model-badge {
  position: absolute; top: -.5rem; right: -.5rem;
  font-size: .65rem; padding: .15rem .5rem; border-radius: 10px;
  font-weight: 600;
}
.model-card.selected .model-badge { background: var(--accent); color: #fff; }
.model-card.disabled .model-badge { background: #9ca3af; color: #fff; }

/* ===== Tendency ===== */
.tendency-select { display: flex; flex-direction: column; gap: .5rem; }
.tendency-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.tendency-option:has(input:checked) {
  border-color: var(--accent);
  background: #eef2ff;
}
.tendency-option input { display: none; }
.tendency-option .tendency-icon { font-size: 1.2rem; }
.tendency-option .tendency-name { font-weight: 600; font-size: .85rem; min-width: 6rem; }
.tendency-option .tendency-desc { font-size: .78rem; color: var(--text-secondary); }

/* ===== Region Grid ===== */
.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .5rem;
}
.region-check {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
}
.region-check:has(input:checked) {
  border-color: var(--accent);
  background: #eef2ff;
}
.region-check input { width: 1rem; height: 1rem; }

/* ===== Slider ===== */
input[type="range"] {
  width: 100%;
  margin: .5rem 0;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--text-secondary);
}

/* ===== Disclaimer ===== */
.disclaimer {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  font-size: .82rem;
  margin-bottom: 1rem;
}
.disclaimer ul { padding-left: 1.2rem; }
.disclaimer li { margin-bottom: .35rem; }

.security-info {
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: .5rem .75rem;
  border-radius: 6px;
  margin-top: .35rem !important;
  font-size: .78rem !important;
}

/* ===== Progress ===== */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin: 1rem 0;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  border-radius: 4px;
  transition: width .3s ease;
  width: 0%;
}
.progress-text {
  text-align: center;
  font-size: .85rem;
  color: var(--text-secondary);
}

/* ===== Live Comments ===== */
.live-comments {
  max-height: 480px;
  overflow-y: auto;
  margin-top: 1rem;
}
.live-comment {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  animation: fadeIn .3s ease;
}
.live-comment:last-child { border-bottom: none; }
.live-comment .lc-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: .2rem;
}
.live-comment .lc-nickname { color: var(--accent); }
.live-comment .lc-country { font-size: .75rem; color: var(--text-secondary); }
.live-comment .lc-text { font-size: .82rem; line-height: 1.5; }
.live-comment .lc-reply {
  margin-left: 1.2rem;
  padding-left: .6rem;
  border-left: 2px solid var(--border);
  margin-top: .3rem;
  font-size: .78rem;
  color: #4b5563;
}
.live-comment .lc-reply-to { font-size: .7rem; color: var(--accent); margin-bottom: .15rem; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Error ===== */
.error-card { border-color: var(--error); }
.error-card h2 { color: var(--error) !important; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
.site-footer .notice {
  margin-top: .25rem;
  font-weight: 600;
  color: #92400e;
}

/* ===== Complete ===== */
#complete-info { font-size: .9rem; margin-bottom: 1rem; }
#complete-info p { margin-bottom: .5rem; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .model-select { flex-direction: column; }
  .region-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 1rem; }
}

/* ===== Result Comments ===== */
.result-summary { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 8px; padding: .8rem; margin: .8rem 0; }
.result-summary h3 { font-size: .85rem; color: #3730a3; margin-bottom: .3rem; }
.result-summary p { font-size: .8rem; color: #1e1b4b; }
.result-comments-container { max-height: 500px; overflow-y: auto; margin-top: .8rem; }
.result-comment { background: #fff; border-radius: 8px; padding: .7rem; margin-bottom: .5rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.result-header { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; font-size: .75rem; margin-bottom: .3rem; }
.result-icon { font-size: .9rem; }
.result-country { color: #6c757d; font-size: .7rem; }
.result-occ { color: #9ca3af; font-size: .7rem; }
.result-stance { background: #f3f4f6; padding: 0 .3rem; border-radius: 3px; font-size: .65rem; }
.result-num { margin-left: auto; color: #d1d5db; font-size: .7rem; }
.result-body { font-size: .85rem; line-height: 1.5; }
.result-comment .replies { margin-top: .3rem; margin-left: 1rem; padding-left: .6rem; border-left: 2px solid #e5e7eb; }
.result-comment .reply { font-size: .78rem; color: #4b5563; margin-bottom: .2rem; }
.result-comment .reply-nick { font-weight: 600; color: #4f46e5; }
