:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-2: #edf4f4;
  --text: #17303a;
  --muted: #5e737b;
  --line: #d8e3e5;
  --primary: #1f7a79;
  --primary-dark: #155b5a;
  --accent: #2c6fb2;
  --danger: #c45a4e;
  --success: #2f8f65;
  --shadow: 0 20px 60px rgba(16, 37, 45, 0.08);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(180deg, #eef5f5 0%, #f7f9fa 100%);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }

.app-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(44,111,178,.12), rgba(31,122,121,.14));
  border: 1px solid rgba(31,122,121,.16);
  overflow: hidden;
}
.brand-circle {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--accent), var(--primary));
  left: 11px;
  top: 17px;
}
.brand-wing {
  position: absolute;
  width: 30px;
  height: 18px;
  border-radius: 0 18px 18px 18px;
  background: linear-gradient(145deg, var(--primary), #6db5b0);
  right: 8px;
  top: 10px;
  transform: rotate(-20deg);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--primary);
}
h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: clamp(1.35rem, 2.3vw, 1.9rem); line-height: 1.15; }
h3 { font-size: 1.05rem; }
p { line-height: 1.65; color: var(--muted); }

.main-grid {
  display: grid;
  gap: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(23,48,58,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel-intro {
  padding: 36px;
}

.tag {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(31,122,121,.10);
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.feature-grid,
.score-cards,
.visual-grid,
.narrative-grid {
  display: grid;
  gap: 16px;
}

.feature-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 26px 0; }
.feature-card,
.score-card,
.visual-card,
.narrative-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  background: #fff;
}
.feature-card h3,
.visual-card h3,
.narrative-card h3 { margin-bottom: 10px; }

.cta-row,
.form-actions,
.results-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: .2s ease;
}
.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.secondary-btn:hover,
.ghost-btn:hover { background: #e8efef; }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.progress-wrap { margin-bottom: 22px; }
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: .92rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.progress-bar {
  width: 100%;
  height: 10px;
  background: #e7efef;
  border-radius: 999px;
  overflow: hidden;
}
#progressFill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  transition: width .2s ease;
}

.section-header { margin-bottom: 20px; }
.question-group {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
  margin-bottom: 18px;
}
.question-group h3 { margin-bottom: 6px; }
.question-group > p { margin: 0 0 16px; }
.question-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid #edf1f2;
}
.question-item:first-of-type { border-top: none; padding-top: 0; }
.question-item label {
  color: var(--text);
  font-weight: 500;
}
.question-item select {
  width: 190px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
}
.question-item select:focus {
  outline: 2px solid rgba(31,122,121,.18);
  border-color: var(--primary);
}

.score-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 20px 0 8px; }
.score-card strong { display: block; font-size: 2.1rem; margin: 10px 0 8px; }
.score-label { font-size: .88rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.score-card small { color: var(--muted); }
.score-card.danger { background: rgba(196,90,78,.08); border-color: rgba(196,90,78,.20); }
.score-card.success { background: rgba(47,143,101,.08); border-color: rgba(47,143,101,.20); }
.score-card.accent { background: rgba(44,111,178,.08); border-color: rgba(44,111,178,.20); }

.visual-grid { grid-template-columns: 1.15fr .85fr; margin-top: 18px; }
.balance-chart {
  position: relative;
  min-height: 340px;
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(47,143,101,.10) 0 50%, rgba(196,90,78,.10) 50% 100%),
    linear-gradient(180deg, rgba(47,143,101,.08) 0 50%, rgba(196,90,78,.08) 50% 100%);
  border: 1px solid var(--line);
  overflow: hidden;
}
.axis {
  position: absolute;
  background: rgba(23,48,58,.22);
}
.axis-y { width: 2px; height: 100%; left: 50%; top: 0; }
.axis-x { height: 2px; width: 100%; top: 50%; left: 0; }
.axis-label {
  position: absolute;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}
.y-top { top: 12px; left: 14px; }
.y-bottom { bottom: 12px; left: 14px; }
.x-left { left: 14px; bottom: 16px; }
.x-right { right: 14px; bottom: 16px; }
.quadrant {
  position: absolute;
  font-size: .86rem;
  font-weight: 700;
  color: rgba(23,48,58,.72);
  padding: 10px 12px;
}
.q1 { left: 54%; top: 10px; }
.q2 { right: 10px; top: 10px; }
.q3 { left: 10px; bottom: 34px; }
.q4 { right: 10px; bottom: 34px; }
.balance-point {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 8px rgba(31,122,121,.14);
  transform: translate(-50%, -50%);
  transition: left .3s ease, top .3s ease;
}

.bars { display: grid; gap: 18px; margin-top: 12px; }
.bar-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: .94rem;
  color: var(--text);
  font-weight: 600;
}
.bar-track {
  height: 16px;
  background: #edf1f2;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width .3s ease;
}
.bar-fill.danger { background: linear-gradient(135deg, #d36e61, var(--danger)); }
.bar-fill.success { background: linear-gradient(135deg, #46a779, var(--success)); }
.bar-fill.accent { background: linear-gradient(135deg, #5c8fd0, var(--accent)); }

.followup-panel {
  margin-top: 18px;
  background: linear-gradient(180deg, #ffffff, #f8fbfb);
}
.followup-panel ul {
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

@media (max-width: 920px) {
  .visual-grid { grid-template-columns: 1fr; }
  .question-item { grid-template-columns: 1fr; }
  .question-item select { width: 100%; }
}

@media (max-width: 640px) {
  .app-shell { padding: 16px; }
  .panel, .panel-intro { padding: 20px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .results-head, .form-actions, .cta-row { justify-content: flex-start; }
  .balance-chart { min-height: 280px; }
}

@media print {
  body { background: #fff; }
  .topbar, .form-actions, .cta-row, #printBtn, #resetBtn { display: none !important; }
  .panel { box-shadow: none; border: 1px solid #ddd; }
  .hidden { display: none !important; }
}


.inline-actions { margin-top: 14px; }

.diary-panel { margin-top: 20px; }
.diary-intro { margin: 10px 0 20px; }
.diary-days {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}
.diary-day {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
}
.diary-day h3 { margin-bottom: 14px; }
.diary-sliders {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.diary-sliders label,
.diary-texts label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 500;
}
.diary-sliders input[type="range"] { width: 100%; }
.diary-sliders strong {
  color: var(--primary);
  font-size: 1.05rem;
}
.diary-texts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.diary-texts input {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
}
.diary-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 18px;
}
.diary-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 16px;
}
.diary-chart-wrap {
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
}
.diary-chart-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 920px) {
  .diary-grid,
  .visual-grid {
    grid-template-columns: 1fr;
  }
  .diary-sliders,
  .diary-texts {
    grid-template-columns: 1fr;
  }
}
