:root {
  --plum: #7A3E74; --plum-dark: #66366A; --navy: #243447;
  --band: #F2EAF1; --gold: #C78B3C; --cream: #FFF8F0;
  --line: #e3d6dd; --shadow: 0 5px 22px rgb(102 54 106 / 6%);
  font-family: Arial, system-ui, sans-serif; color: var(--navy); background: var(--cream);
  font-synthesis: none; -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
a { color: var(--plum); text-underline-offset: 4px; }
button, input, textarea, select { font: inherit; }
button, a, summary { touch-action: manipulation; }
button { border: 0; border-radius: 12px; padding: 14px 20px; min-height: 48px; background: var(--plum); color: var(--cream); font-weight: 700; cursor: pointer; }
button:hover { background: var(--plum-dark); }
button:disabled { opacity: .6; cursor: wait; }
.secondary { background: var(--band); color: var(--plum-dark); }
.secondary:hover { background: #e8dce7; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
h1, h2, h3 { overflow-wrap: anywhere; font-family: Georgia, serif; font-weight: 700; }
h1 { margin: 0 0 16px; font-size: clamp(34px, 4.8vw, 48px); line-height: 1.12; color: var(--plum-dark); letter-spacing: -.8px; }
h2 { margin: 0 0 18px; font-size: 25px; line-height: 1.25; color: var(--plum-dark); }
h3 { color: var(--plum-dark); font-size: 20px; line-height: 1.4; margin: 24px 0 9px; }
p { line-height: 1.65; margin: 0 0 20px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.site-header { width: 100%; min-width: 0; max-width: 1080px; margin: auto; padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; min-width: 0; align-items: center; gap: 10px; color: var(--plum-dark); text-decoration: none; font: bold 19px Georgia, serif; }
.brand span { min-width: 0; overflow-wrap: anywhere; }
.brand-mark { width: 42px; height: 42px; stroke-width: 2.2; }
.icon-button { display: inline-flex; flex-shrink: 0; justify-content: center; align-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; color: var(--plum); background: var(--cream); }
main { width: 100%; min-width: 0; max-width: 820px; margin: 0 auto; padding: 40px 28px calc(128px + env(safe-area-inset-bottom)); }
main:focus { outline: none; }
.intro { min-width: 0; margin-bottom: 30px; }
.intro::before { content: ''; display: block; width: 38px; height: 3px; background: var(--gold); border-radius: 3px; margin: 0 0 22px; }
.subhead { min-width: 0; overflow-wrap: anywhere; font-size: 17px; max-width: 620px; margin: 0; }
.home { max-width: 980px; }
.home-hero { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 44px; padding: 10px 0 24px; }
.home-hero .intro { min-width: 0; max-width: 570px; margin: 0; }
.home-hero h1 { font-size: clamp(42px, 5.6vw, 62px); }
.hero-mark { width: 160px; height: 160px; padding: 24px; background: var(--band); color: var(--plum); border-radius: 50%; transform: rotate(-5deg); stroke-width: 1.8; }
.home-cards { display: grid; min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.home-card { display: flex; min-width: 0; align-items: center; gap: 18px; min-height: 124px; padding: 24px; text-decoration: none; color: var(--navy); background: #fffdf9; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.home-card:hover { transform: translateY(-2px); border-color: var(--plum); }
.home-card .card-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 16px; background: var(--band); color: var(--plum); flex-shrink: 0; }
.home-card strong { min-width: 0; overflow-wrap: anywhere; font: bold 22px/1.3 Georgia, serif; }
.home-card .arrow { margin-left: auto; font-size: 23px; color: var(--plum); }
.panel { min-width: 0; background: #fffdf9; border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); margin-bottom: 22px; }
.primary-add { margin-bottom: 28px; }
label { display: block; font-weight: 700; font-size: 14px; color: var(--plum-dark); margin-bottom: 8px; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid #baa6b7; border-radius: 10px; background: var(--cream); padding: 12px; color: var(--navy); min-height: 48px; }
textarea { min-height: 100px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #60616b; opacity: 1; }
.field { margin-bottom: 20px; }
.field-pair { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 16px; }
.button-row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
.entry-list { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 12px; }
.entry-row { background: #fffdf9; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); position: relative; }
.entry-row::before { content: ''; position: absolute; background: var(--gold); left: 0; width: 3px; height: 30px; top: 23px; border-radius: 3px; }
.entry-button, .mood-entry { padding: 22px 24px; width: 100%; text-align: left; background: transparent; color: var(--navy); border-radius: 14px; font-weight: 400; line-height: 1.6; }
.entry-button:hover { background: var(--band); }
.entry-date { font-size: 13px; letter-spacing: .2px; color: var(--plum-dark); font-weight: 700; }
.entry-type { font-weight: 700; }
.entry-note { overflow-wrap: anywhere; }
.empty-state { border: 1px dashed #cbb4c6; background: var(--band); border-radius: 16px; padding: 28px; margin: 0 0 30px; }
.text-button { color: var(--plum); background: transparent; font-size: 15px; text-decoration: underline; text-underline-offset: 4px; padding: 12px 0; font-weight: 400; }
.text-button:hover { color: var(--plum-dark); background: transparent; }
.info-panel { margin-top: 12px; background: var(--band); box-shadow: none; }
.info-panel p { margin: 0; }
.mood-picker { display: grid; min-width: 0; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0 0 26px; }
.mood-choice { min-width: 0; overflow-wrap: anywhere; background: #fffdf9; color: var(--navy); border: 1px solid var(--line); padding: 18px 4px; min-height: 110px; font-size: 13px; font-weight: 400; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: flex-start; }
.mood-choice .emoji { font-size: 32px; line-height: 1.2; }
.mood-choice:hover { background: var(--band); }
.mood-choice[aria-pressed="true"] { background: var(--band); border: 2px solid var(--plum); padding: 17px 3px; }
.mood-note { margin-top: 0; }
.mood-note input { margin-bottom: 16px; }
.mood-note button { width: 100%; }
.progress { display: flex; min-width: 0; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 28px; color: var(--plum); font-weight: 700; font-size: 14px; }
.progress-track { display: flex; min-width: 0; gap: 8px; flex: 1; max-width: 150px; }
.progress-track span { width: 100%; height: 5px; border-radius: 8px; background: var(--line); }
.progress-track .complete { background: var(--plum); }
.ai-panel { padding: 34px; background: var(--band); }
.ai-panel h2 { font-size: 27px; }
.ai-panel p { font-size: 17px; }
.ai-panel button { margin-top: 10px; width: 100%; }
.step-label { display: block; font: 700 13px Arial, sans-serif; margin-bottom: 12px; color: var(--plum); }
.ai-back { margin-top: 12px; }
.safety-card { min-width: 0; background: #fffdf9; border: 1px solid var(--line); border-radius: 16px; margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden; }
.safety-card summary { display: flex; min-width: 0; align-items: center; gap: 16px; cursor: pointer; padding: 25px; color: var(--plum-dark); font: bold 23px/1.35 Georgia, serif; list-style: none; }
.safety-card summary > span { min-width: 0; overflow-wrap: anywhere; }
.safety-card summary::-webkit-details-marker { display: none; }
.safety-card summary::after { content: '+'; flex-shrink: 0; margin-left: auto; font: 27px Arial, sans-serif; }
.safety-card[open] summary::after { content: '−'; }
.safety-card[open] summary { background: var(--band); }
.safety-body { padding: 6px 26px 26px; }
.safety-body p:last-child { margin-bottom: 0; }
.safety-body .callout { background: var(--band); border-radius: 12px; padding: 18px; margin-top: 24px; }
.safety-body .callout h3 { margin-top: 0; }
.about-panel p { font-size: 18px; }
.book-credit { margin-top: 28px; max-width: 440px; font-size: 15px; }
dialog { max-width: 500px; width: calc(100% - 36px); max-height: calc(100dvh - 60px); overflow: auto; background: var(--cream); color: var(--navy); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 20px 80px rgb(36 52 71 / 20%); }
dialog::backdrop { background: rgb(36 52 71 / 38%); }
.detail-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.storage-error { color: var(--plum-dark); padding: 14px; background: var(--band); border-radius: 10px; }
.tab-bar { position: fixed; z-index: 10; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; min-width: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; width: min(440px, calc(100% - 32px)); max-width: calc(100% - 32px); background: var(--cream); border: 1px solid var(--line); border-radius: 20px; padding: 8px; box-shadow: 0 6px 30px rgb(36 52 71 / 12%); margin-bottom: env(safe-area-inset-bottom); }
.tab-bar a { display: flex; min-width: 0; align-items: center; justify-content: center; flex-direction: column; gap: 6px; border-radius: 13px; padding: 11px 4px; min-height: 62px; text-decoration: none; color: var(--navy); font-size: 12px; }
.tab-bar a span { min-width: 0; overflow-wrap: anywhere; text-align: center; }
.tab-bar a[aria-current="page"] { color: var(--plum-dark); background: var(--band); font-weight: 700; }
.tab-bar a:hover { background: var(--band); }
.skip-link { position: fixed; left: 15px; top: -100px; z-index: 20; background: var(--cream); padding: 14px; }
.skip-link:focus { top: 12px; }
[hidden] { display: none !important; }
@media (max-width: 600px) {
  .site-header { padding: 16px 22px; }
  .brand { font-size: 17px; gap: 8px; }
  .brand-mark { width: 34px; height: 34px; }
  main { padding: 25px 24px calc(130px + env(safe-area-inset-bottom)); }
  .intro { margin-bottom: 26px; }
  .subhead { font-size: 16px; }
  .home-hero { display: block; padding: 4px 0 0; }
  .home-hero h1 { font-size: clamp(30px, 9vw, 40px); max-width: 100%; }
  .hero-mark { display: none; }
  .home-cards { grid-template-columns: 1fr; gap: 13px; margin-top: 30px; }
  .home-card { min-height: 100px; padding: 18px; gap: 14px; }
  .home-card strong { font-size: 21px; }
  .home-card .card-icon { width: 44px; height: 44px; border-radius: 13px; }
  .panel { padding: 22px; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .mood-picker { gap: 6px; }
  .mood-choice { padding: 16px 2px; font-size: 11px; min-height: 105px; gap: 11px; }
  .mood-choice[aria-pressed="true"] { padding: 15px 1px; }
  .mood-choice .emoji { font-size: 29px; }
  .entry-button, .mood-entry { padding: 20px; }
  .ai-panel h2 { font-size: 25px; }
  .safety-card summary { font-size: 21px; padding: 22px; gap: 12px; }
  .safety-body { padding: 4px 22px 22px; }
  .safety-body h3 { font-size: 19px; }
  dialog { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Interactive companion modules */
.companion-links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:22px 0}
.companion-links a{display:block;padding:20px;background:var(--band,#EDF1F6);color:inherit;border-radius:14px;text-decoration:none;font-weight:700;overflow-wrap:anywhere}
.companion-module{min-width:0;background:#fffdf9;border:1px solid var(--line,#d9dce3);border-radius:16px;padding:24px;margin:22px 0}
.companion-module h2,.companion-module h3{line-height:1.35;overflow-wrap:anywhere}
.companion-module p,.companion-module li{line-height:1.65}
.companion-module blockquote{margin:18px 0;padding:16px 20px;border-left:3px solid var(--gold,#b58645);background:var(--band,#EDF1F6)}
.companion-module textarea{display:block;width:100%;box-sizing:border-box;min-height:100px;margin:10px 0 22px;padding:12px;border:1px solid #baa6b7;border-radius:10px;background:#FFF8F0;color:inherit;font:inherit;resize:vertical}
.companion-module .companion-check{display:inline-flex;align-items:flex-start;gap:9px;margin:10px 15px 10px 0;color:inherit;font-weight:inherit;line-height:1.5}
.companion-module input[type=checkbox]{width:22px;height:22px;min-height:22px;flex:0 0 22px;margin:1px 0;accent-color:var(--plum,#1F2A44)}
.companion-table{display:grid;gap:14px}.companion-table-row{display:grid;gap:10px;padding:14px;border:1px solid var(--line,#d9dce3);border-radius:12px}
.companion-table-row label{font-size:14px;color:inherit}.companion-table-row textarea{margin:5px 0 0;min-height:72px}
.companion-save{min-height:24px;font-size:14px;color:inherit}
@media(max-width:600px){.companion-links{grid-template-columns:1fr}.companion-module{padding:20px}.companion-module h2{font-size:23px}}
