:root{
  --paper:#FBF7ED;
  --paper-card:#FFFDF7;
  --ink:#2B2A25;
  --ink-soft:#6B6558;
  --forest:#33493D;
  --forest-light:#4A6455;
  --ochre:#D9A441;
  --ochre-dark:#B9862F;
  --teal:#4F7A80;
  --brick:#B5563F;
  --olive:#6B8E4E;
  --plum:#7D5BA6;
  --rose:#C77DA0;
  --blue:#3D6B8C;
  --yellow:#D9A441;
  --green:#4E8B52;
  --red:#C0503A;
  --line:#E4DCC8;
  --shadow: 0 1px 2px rgba(43,42,37,.06), 0 4px 14px rgba(43,42,37,.07);
  box-sizing: border-box;
}
*{ box-sizing: border-box; }
html,body{ height:100%; margin:0; }
body{
  background:
    radial-gradient(circle at 1px 1px, rgba(43,42,37,.05) 1px, transparent 1.6px) 0 0/22px 22px,
    var(--paper);
  color: var(--ink);
  font-family: 'Karla', sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,.brand,.btn,.tile-name{ font-family:'Fredoka', sans-serif; }
a{ color: inherit; }

#app{ max-width: 860px; margin: 0 auto; padding: 24px 20px 80px; }

header.top{ margin-bottom: 28px; }
.brand{ display:flex; align-items:center; gap:10px; text-decoration:none; width:max-content; }
.brand-badge{
  width: 38px; height:38px; border-radius: 50%; background: var(--forest); color: var(--paper);
  display:flex; align-items:center; justify-content:center; font-size: 18px; flex-shrink:0;
}
.brand h1{ font-size: 21px; margin:0; font-weight:600; color: var(--forest); }
.brand p{ margin:2px 0 0; font-size: 13px; color: var(--ink-soft); font-family:'Karla',sans-serif; }

.btn{
  border:none; cursor:pointer; font-weight:600; font-size: 14.5px; text-decoration:none;
  padding: 10px 18px; border-radius: 100px; display:inline-flex; align-items:center; gap:8px;
}
.btn-primary{ background: var(--ochre); color: #2B2213; box-shadow: var(--shadow); }
.btn-ghost{ background: transparent; color: var(--forest); padding: 10px 6px; }
.btn-ghost:hover{ text-decoration: underline; }
.btn-outline{ background: var(--paper-card); color: var(--ink); border:1.5px solid var(--line); }

.action-row{ display:flex; justify-content:flex-end; margin-bottom: 22px; gap:10px; }

/* ---------- HOME ---------- */
.board{ display:grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 22px 16px; }
.tile-wrap{ position:relative; }
.tile{
  position:relative; display:flex; flex-direction:column; align-items:center; gap:8px;
  text-decoration:none; padding: 6px 2px 0; width:100%;
}
.tile-badge{
  width: 84px; height:84px; border-radius:50%; background: var(--paper-card); border: 2.5px solid var(--forest);
  display:flex; align-items:center; justify-content:center; font-size: 38px; box-shadow: var(--shadow);
  overflow:hidden; position:relative; margin: 0 auto;
}
.tile-badge::before{
  content:''; position:absolute; top:-7px; left:50%; transform:translateX(-50%);
  width:9px; height:9px; border-radius:50%; background: var(--brick); box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.badge-img{ width:100%; height:100%; object-fit:cover; border-radius:50%; display:block; }
.tile-name{ font-size: 14px; font-weight:600; color: var(--ink); text-align:center; }
.tile-edit,.tile-del{
  position:absolute; top:0px; width:22px; height:22px; border-radius:50%;
  background: var(--paper-card); border:1.5px solid var(--line); color: var(--ink-soft);
  font-size: 11px; line-height:1; display:flex; align-items:center; justify-content:center;
  text-decoration:none; opacity:.65;
}
.tile-edit{ left:6px; } .tile-del{ right:6px; font-size:12px; }
.tile-edit:hover{ color: var(--forest); border-color: var(--forest); }
.tile-del:hover{ color: var(--brick); border-color: var(--brick); }
.tile-add .tile-badge{ border-style: dashed; border-color: var(--ink-soft); background:transparent; color: var(--ochre-dark); font-size: 30px; }
.tile-add .tile-name{ color: var(--ink-soft); }

.empty{ text-align:center; padding: 60px 20px; color: var(--ink-soft); }
.empty p{ margin: 0 0 16px; font-size:15px; }

/* ---------- Sheets / forms ---------- */
.sheet{ background: var(--paper-card); border:1.5px solid var(--line); border-radius: 20px; padding: 22px; margin-top: 10px; box-shadow: var(--shadow); }
.sheet h3{ margin: 0 0 14px; font-size:17px; color:var(--forest); }
.field-label{ font-size: 13px; font-weight:600; color: var(--ink-soft); margin: 14px 0 8px; display:block; }
input[type=text], input[type=date], textarea{
  width:100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--paper); color: var(--ink); font-family:'Karla',sans-serif; font-size:15px;
}
textarea{ min-height: 90px; line-height:1.5; resize: vertical; }
.sheet-actions,.form-actions{ display:flex; gap:10px; margin-top:20px; flex-wrap:wrap; }
.form-actions{ justify-content:flex-end; }
.hint{ font-size:12.5px; color: var(--ink-soft); margin: 6px 0 0; }

/* ---------- Chips (used for symbols, tags, sentiment, participation, filters) ---------- */
.chip-label{ display:inline-block; cursor:pointer; }
.chip-label input{ position:absolute; opacity:0; width:0; height:0; }
.chip{
  display:inline-flex; align-items:center; gap:6px; border:1.5px solid var(--line); background: var(--paper-card);
  color: var(--ink); padding:7px 14px; border-radius:100px; font-size:13.5px; font-weight:600;
}
.chip-label input:checked + .chip{ background: var(--c, var(--forest)); color:#fff; border-color:transparent; }
.chip-row{ display:flex; flex-wrap:wrap; gap:8px; }

.symbol-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(46px,1fr)); gap:8px; max-width: 480px; }
.symbol-grid .chip{ width:46px; height:46px; border-radius:50%; border:2px solid transparent; background: var(--paper); font-size:22px; padding:0; justify-content:center; }
.symbol-grid .chip-label input:checked + .chip{ background:#fff; color:inherit; border-color: var(--forest); }

.custom-symbol{ display:flex; gap:14px; align-items:center; flex-wrap:wrap; margin-top:14px; padding-top:14px; border-top:1.5px dashed var(--line); }
.custom-symbol .preview{
  width:56px; height:56px; border-radius:50%; border:2.5px solid var(--forest); background: var(--paper);
  display:flex; align-items:center; justify-content:center; font-size:26px; flex-shrink:0; overflow:hidden;
}
.custom-symbol .fields{ flex:1; min-width: 220px; display:flex; flex-direction:column; gap:6px; }
.file-btn{
  display:inline-flex; align-items:center; gap:8px; cursor:pointer; background: var(--paper-card);
  border:1.5px solid var(--line); color: var(--ink); padding: 9px 16px; border-radius:100px;
  font-size:14px; font-weight:600; width:max-content;
}
.file-btn input{ display:none; }

/* Segmented single-select group (sentiment / participation / kind filter) */
.segmented{ display:inline-flex; flex-wrap:wrap; gap:0; border:1.5px solid var(--line); border-radius:100px; padding:3px; background: var(--paper-card); }
.segmented .chip{ border:none; background:transparent; color: var(--ink-soft); }

/* ---------- DETAIL / FILTERS ---------- */
.child-header{ display:flex; align-items:center; gap:16px; margin: 6px 0 22px; }
.child-badge{
  width:64px; height:64px; border-radius:50%; background: var(--paper-card); border:2.5px solid var(--forest);
  display:flex; align-items:center; justify-content:center; font-size:30px; box-shadow: var(--shadow); flex-shrink:0; overflow:hidden;
}
.child-header h2{ margin:0; font-size:22px; color:var(--forest); }

.filterbar{ background: var(--paper-card); border:1.5px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 24px; }
.filterbar-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.filterbar-title{ font-size:13px; font-weight:700; color: var(--ink-soft); }
.filter-clear{ font-size:13px; font-weight:600; color: var(--forest); text-decoration:none; }
.filter-clear:hover{ text-decoration: underline; }
.tag-count{ opacity:.65; font-weight:700; font-size:12px; }

.domain-group{ margin-bottom: 28px; }
.domain-heading{ display:flex; align-items:center; gap:8px; font-size:15px; font-weight:700; margin-bottom: 14px; font-family:'Fredoka', sans-serif; }
.domain-dot{ width:11px; height:11px; border-radius:50%; flex-shrink:0; display:inline-block; }
.domain-count{ font-family:'Karla',sans-serif; font-size:12px; font-weight:700; color: var(--ink-soft); background: var(--paper-card); border:1.5px solid var(--line); border-radius:100px; padding: 1px 9px; }

.timeline{ position:relative; padding-left: 22px; }
.timeline::before{ content:''; position:absolute; left:6px; top:6px; bottom:6px; width:2px; background: var(--line); }
.entry{ position:relative; margin-bottom: 26px; }
.entry::before{ content:''; position:absolute; left:-22px; top:5px; width:12px; height:12px; border-radius:50%; background: var(--dot, var(--ochre)); border: 2px solid var(--paper); }
.entry-head{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:6px; }
.entry-date{ font-size:13.5px; font-weight:700; color: var(--forest); }
.entry-card{ background: var(--paper-card); border:1.5px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); font-size:14.5px; line-height:1.55; position:relative; }
.entry-card :first-child{ margin-top:0; } .entry-card :last-child{ margin-bottom:0; }
.entry-actions{ display:flex; gap:2px; margin-top:10px; }
.entry-actions a{ font-size:12px; font-weight:600; color: var(--ink-soft); text-decoration:none; padding:4px 8px; border-radius:8px; }
.entry-actions a:hover{ background: var(--line); color: var(--ink); }

.kind-badge{ display:inline-flex; align-items:center; gap:5px; font-size:11.5px; font-weight:700; padding:3px 10px; border-radius:100px; background: var(--forest-light); color:#fff; }
.participation-badge{ display:inline-flex; align-items:center; font-size:11.5px; font-weight:700; padding:3px 10px; border-radius:100px; background: var(--line); color: var(--ink); }

/* ---------- Activities ---------- */
.activity-header{ margin: 6px 0 22px; }
.activity-header h2{ margin:0 0 6px; font-size:22px; color: var(--forest); }
.activity-header p{ margin:0; font-size:13.5px; color: var(--ink-soft); }

.activity-list{ display:flex; flex-direction:column; gap:10px; margin-top: 8px; }
.activity-list-item{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding: 12px 14px; border:1.5px solid var(--line); border-radius:14px; background: var(--paper); }
.activity-list-item .info strong{ display:block; font-size:14.5px; }
.activity-list-item .info span{ font-size:12.5px; color: var(--ink-soft); }

.activity-rows{ display:flex; flex-direction:column; gap:18px; margin-top:8px; }
.activity-row{ background: var(--paper-card); border:1.5px solid var(--line); border-radius:16px; padding: 14px 16px; }
.activity-row-head{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.activity-row-head .child-badge{ width:40px; height:40px; font-size:18px; }
.activity-row-head strong{ font-size:15px; }

.activity-row.logged{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding: 12px 16px; }
.activity-row.logged .info{ display:flex; align-items:center; gap:12px; }
.activity-row.logged .meta{ font-size:12.5px; color: var(--ink-soft); }
.activity-row.logged .meta strong{ color: var(--forest); font-weight:700; }

.domain-details summary.collapsible-toggle{ cursor:pointer; color: var(--forest); font-weight:600; font-size:13px; padding: 6px 0; list-style: none; }
.domain-details summary.collapsible-toggle::-webkit-details-marker{ display:none; }
.domain-details summary.collapsible-toggle::before{ content:'›'; display:inline-block; margin-right:5px; transition: transform .15s ease; }
.domain-details[open] summary.collapsible-toggle::before{ transform: rotate(90deg); }
.collapsible-body{ margin-top:10px; }

.who-strip{ display:flex; align-items:center; gap:12px; padding: 12px 16px; background: var(--paper-card); border:1.5px solid var(--line); border-radius:16px; margin-bottom: 20px; }
.who-strip .child-badge{ width:44px; height:44px; font-size:20px; }

@media (max-width: 420px){
  .tile-badge{ width:72px; height:72px; font-size:32px; }
  .board{ grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); }
}
