:root {
  --bg: #f6fbf0;
  --card: #ffffff;
  --text: #24313a;
  --muted: #5f6e57;
  --accent: #669933;
  --accent-dark: #477522;
  --accent-soft: #edf5e3;
  --line: #dbe8cc;
  --danger: #a35f5f;
  --danger-soft: #f5e8e8;
  --shadow: 0 10px 30px rgba(46, 72, 26, 0.1);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbfff7 0%, #eef6e6 100%);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid #315f13; outline-offset: 3px; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 100; background: #fff; color: var(--text); padding: 10px 14px; border-radius: 10px; }
.skip-link:focus { top: 12px; }
.app-shell { width: min(100%, 788px); margin: 0 auto; padding: 12px 14px 36px; }
.topbar { min-height: 58px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px clamp(14px, 3vw, 24px); padding: 4px 2px 10px; border-bottom: 2px solid var(--accent); margin-bottom: 12px; }
.header-logo { display: block; width: clamp(145px, 28vw, 210px); height: auto; }
.status-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; }
.status-pill { max-width: 280px; border-radius: 999px; padding: 5px 9px; font-size: .78rem; color: #375229; background: var(--accent-soft); text-align: right; }
.status-pill.error { color: #713f3f; background: var(--danger-soft); }
.home-button { min-height: 42px; border: 1px solid transparent; border-radius: 12px; padding: 9px 14px; background: #669933; color: #fff; font-weight: 700; white-space: nowrap; text-align: center; }
.home-button:hover { background: var(--accent-dark); }
.hero, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 26px);
  margin-bottom: 16px;
  min-width: 0;
}
.hero { background: linear-gradient(135deg, #f0f7e8 0%, #f7fbf2 100%); border-color: #d2e3bf; border-radius: 24px; }
.home-hero { padding-block: 14px; }
.home-hero .lead { margin-bottom: 0; }
h1, h2, h3 { color: #28492e; line-height: 1.25; }
h1 { margin: 0 0 8px; font-size: clamp(1.65rem, 7vw, 2.15rem); }
h2 { margin: 0 0 12px; font-size: 1.3rem; }
h3 { margin: 0 0 9px; font-size: 1.08rem; }
p { line-height: 1.58; margin: 0 0 12px; }
.lead { font-size: 1.06rem; color: var(--muted); }
.muted, .meta, .hint { color: var(--muted); }
.small { font-size: .88rem; }
.provisional { border-left: 4px solid var(--danger); padding-left: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions > * { flex: 1 1 150px; }
.button, button.button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  text-align: center;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.secondary { background: var(--accent-soft); color: var(--text); }
.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.danger { background: var(--danger-soft); color: #793f3f; border-color: #e7caca; }
.text-button { border: 0; padding: 5px 0; background: transparent; color: var(--accent-dark); text-decoration: underline; font-weight: 700; }
.install-link { display: inline-flex; align-items: center; min-height: 44px; padding-block: 10px; }
.field { margin-top: 20px; }
.field > label, .field > .label { display: block; font-weight: 750; margin-bottom: 7px; }
.field .question { font-weight: 500; line-height: 1.5; }
textarea, input[type="text"], input[type="search"], input[type="date"], select {
  width: 100%;
  border: 1px solid #cfd9c4;
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
}
textarea { min-height: 118px; resize: vertical; line-height: 1.5; }
textarea:focus, input:focus, select:focus { border-color: var(--accent-dark); }
.emotion-group { border: 0; padding: 0; margin: 18px 0 0; }
.emotion-group legend { font-weight: 750; margin-bottom: 8px; }
.emotion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.emotion-item { border: 1px solid var(--line); border-radius: 13px; background: #fbfdf8; padding: 10px; min-width: 0; }
.emotion-check { display: flex; gap: 9px; align-items: center; font-weight: 650; }
.emotion-check input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
.intensity { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-top: 9px; }
.intensity input { width: 100%; accent-color: var(--accent); }
.intensity output { min-width: 2ch; font-weight: 700; }
.validation { color: #7b4545; margin-top: 10px; font-weight: 650; }
.info-box { background: var(--accent-soft); border: 1px solid #d2e3bf; border-radius: 14px; padding: 14px; margin-top: 14px; }
.warning-box { background: var(--danger-soft); border: 1px solid #e7caca; border-radius: 14px; padding: 14px; margin-top: 14px; }
details { border: 1px solid var(--line); border-radius: 14px; background: #fff; margin: 12px 0; overflow: hidden; }
summary { cursor: pointer; font-weight: 750; padding: 14px; color: #35562b; }
.details-body { padding: 0 14px 14px; }
.answer { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; margin: 6px 0 12px; background: #f7f9f4; border-radius: 10px; }
.history-toolbar { display: grid; gap: 12px; }
.history-card { position: relative; }
.history-title { margin-right: 36px; overflow-wrap: anywhere; }
.history-select { position: absolute; top: 21px; right: 20px; width: 22px; height: 22px; accent-color: var(--accent); }
.meta { display: grid; gap: 3px; font-size: .9rem; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 8px; margin: 4px 4px 0 0; background: var(--accent-soft); color: #365326; font-size: .8rem; font-weight: 700; }
.badge.draft { background: #f5eee2; color: #6e5636; }
.empty { text-align: center; padding: 34px 18px; }
mark { background: #fff1a8; color: inherit; border-radius: 3px; padding: 0 .08em; }
.reflection { border-left: 4px solid var(--accent); padding-left: 14px; margin-top: 16px; }
.alternative-choice-list { display: grid; gap: 12px; margin-top: 12px; }
.alternative-choice { display: block; border: 2px solid var(--line); border-radius: 14px; background: #fbfdf8; padding: 14px; cursor: pointer; }
.alternative-choice.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(102, 153, 51, .14); }
.alternative-choice-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: #28492e; font-weight: 750; }
.alternative-choice input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--accent); }
.alternative-choice .answer { display: block; background: #fff; }
.modal-root { position: fixed; inset: 0; z-index: 50; background: rgba(24, 35, 26, .58); padding: 18px; overflow-y: auto; display: grid; place-items: center; }
.modal-root[hidden] { display: none; }
.modal { width: min(100%, 620px); max-height: calc(100vh - 36px); overflow-y: auto; background: #fff; border-radius: 18px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 22px; }
.modal.large { width: min(100%, 720px); }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: calc(100% - 28px); border-radius: 999px; padding: 10px 15px; background: #24313a; color: #fff; box-shadow: var(--shadow); }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding-top: 10px; }
.print-only { display: none; }
#print-root { display: none; }

@media (max-width: 540px) {
  .app-shell { padding: 8px 10px 28px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .header-logo { width: clamp(126px, 40vw, 165px); }
  .home-button { grid-column: 2; padding-inline: 12px; }
  .status-stack { grid-column: 1 / -1; grid-row: 2; align-items: stretch; }
  .status-pill { max-width: none; text-align: left; }
  .emotion-grid { grid-template-columns: 1fr; }
  .actions > * { flex-basis: 100%; }
  .modal-root { padding: 10px; }
  .modal { padding: 18px; max-height: calc(100vh - 20px); }
}

@media print {
  @page { margin: 15mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .app-shell { width: 100%; max-width: none; padding: 0; }
  .no-print, #main { display: none !important; }
  #print-root { display: block !important; }
  #print-root[aria-hidden="true"] { display: none !important; }
  .print-document h1 { color: #000; font-size: 20pt; }
  .print-document h2 { color: #000; font-size: 15pt; border-bottom: 1px solid #999; padding-bottom: 5px; }
  .print-document h3 { color: #000; font-size: 12pt; }
  .print-exercise { border-top: 2px solid #777; margin-top: 12mm; padding-top: 5mm; }
  .print-exercise:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
  .print-block, .reflection { break-inside: avoid; }
  .answer { background: transparent; border: 1px solid #bbb; }
  a { color: #000; text-decoration: none; }
}
