:root {
  --bg: #fbf3e9;
  --card: #ffffff;
  --text: #4a4160;
  --muted: #6e6484;
  --faint: #8a8099;
  --line: #efe7da;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  padding: 24px; text-align: center; color: var(--muted); font-size: 17px;
}
#app { max-width: 430px; margin: 0 auto; padding: 22px 16px 44px; position: relative; }
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; padding: 0 4px; }
.app-title { font-size: 22px; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 12px; }
.refresh { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px; font-family: inherit; }
.link { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px; font-family: inherit; }

.card {
  background: var(--card); border-radius: 22px; padding: 15px 15px; margin-bottom: 12px;
  box-shadow: 0 2px 0 rgba(74, 65, 96, 0.05), 0 6px 16px rgba(74, 65, 96, 0.04);
  --ring: var(--accent);
  --soft: color-mix(in srgb, var(--accent) 60%, #ffffff);
  --avatar-bg: color-mix(in srgb, var(--accent) 16%, #ffffff);
  --ink: color-mix(in srgb, var(--accent) 62%, #3a2f5c);
  --btn-bg: color-mix(in srgb, var(--accent) 55%, #ffffff);
  --btn-ink: color-mix(in srgb, var(--accent) 70%, #241a3a);
  --minus-bg: color-mix(in srgb, var(--accent) 12%, #ffffff);
}
.card-top { display: flex; align-items: center; gap: 14px; }
.avatar {
  position: relative; overflow: hidden; width: 56px; height: 56px; border-radius: 50%;
  background: var(--avatar-bg); border: 3px solid var(--ring);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: 18px; font-weight: 500; flex: none;
}
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.middle { flex: 1; min-width: 0; }
.name-row { display: flex; align-items: center; gap: 6px; }
.name { font-size: 16px; font-weight: 500; }
.crown { font-size: 16px; line-height: 1; }
.note { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note.empty { color: var(--faint); font-style: italic; }
.total { color: var(--ink); font-size: 28px; font-weight: 500; flex: none; }

.ctas { display: flex; gap: 16px; margin-top: 12px; padding-left: 2px; }
.cta { font-size: 12px; cursor: pointer; background: none; border: none; padding: 0; font-family: inherit; }
.cta.more { color: var(--ink); }
.cta.history { color: var(--muted); }
.cta.collapse { color: var(--muted); align-self: flex-start; margin-top: 2px; }
.cta:disabled { color: var(--faint); cursor: default; }

.actions { display: flex; gap: 8px; margin-top: 10px; }
.plus {
  flex: 1; border: none; border-radius: 14px; background: var(--btn-bg); color: var(--btn-ink);
  font-size: 15px; font-weight: 500; padding: 12px 0; cursor: pointer; font-family: inherit;
}
.minus {
  width: 52px; border-radius: 14px; border: none; background: var(--minus-bg); color: var(--ink);
  font-size: 15px; cursor: pointer; font-family: inherit;
}

.noteform { display: flex; gap: 8px; margin-top: 10px; }
.noteform input {
  flex: 1; background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  color: var(--text); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.noteform input::placeholder { color: var(--faint); }

.expanded { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 9px; display: flex; flex-direction: column; gap: 6px; }
.logline { font-size: 12px; color: var(--muted); line-height: 1.4; }
.logline .d { color: var(--ink); font-weight: 500; }
.logline .meta { color: var(--faint); }

.whoami-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 260px; }
.whoami-buttons button {
  padding: 15px; border-radius: 16px; border: none; background: #fff; color: var(--text);
  font-size: 16px; font-weight: 500; cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 0 rgba(74, 65, 96, 0.05), 0 6px 16px rgba(74, 65, 96, 0.04);
}

.modal { min-height: 100vh; position: absolute; inset: 0; background: rgba(74, 65, 96, 0.35); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { background: #fff; border-radius: 20px; padding: 22px 20px; max-width: 300px; width: 100%; text-align: center; box-shadow: 0 10px 30px rgba(74, 65, 96, 0.2); }
.modal-card p { margin: 0 0 18px; font-size: 16px; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn { flex: 1; padding: 12px 0; border-radius: 14px; border: none; background: #f0eaf6; color: var(--text); font-size: 15px; font-weight: 500; cursor: pointer; font-family: inherit; }
.modal-btn.confirm { background: #f58aa0; color: #4a1526; }
