/* ============================================================================
 * MindLink — visual language
 * A calm, high-legibility care companion. Warm parchment ground, ink-navy
 * type, and a generous touch target scale — designed to be read easily and
 * used confidently by people at very different levels of tech comfort.
 * ==========================================================================*/
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --paper: #faf5ea;
  --paper-dim: #f2ead9;
  --card: #fffdf7;
  --ink: #2a2721;
  --ink-soft: #5c574c;
  --line: #e4d9c1;
  --navy: #1f3a5f;
  --navy-deep: #142944;
  --blue: #2f6fb0;
  --blue-soft: #e4edf6;
  --green: #2e7d5b;
  --green-soft: #e3f2ea;
  --amber: #b5721c;
  --amber-soft: #faf0dc;
  --rose: #b0415f;
  --rose-soft: #fbe9ee;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(42,39,33,.05), 0 10px 30px -12px rgba(42,39,33,.16);
  --shadow-pop: 0 20px 60px -20px rgba(20,41,68,.35);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Atkinson Hyperlegible', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 12% -10%, #fffaf0 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #f6ecd8 0%, transparent 55%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--navy-deep); margin: 0 0 .3em; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
h3 span { flex: 1; }
p { margin: 0 0 1em; }
a { color: var(--blue); }
button { font-family: inherit; }
::selection { background: #d7e6f5; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 28px; }
.band { padding: 40px 0 64px; }
.lead-muted { color: var(--ink-soft); font-size: 1.02rem; }

/* ---- logo / brand -------------------------------------------------------- */
.logo { display: block; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; padding: 0; }
.name { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; color: var(--navy-deep); }
.name .lk { color: var(--amber); }

/* ---- header / nav --------------------------------------------------------*/
header.site {
  position: sticky; top: 0; z-index: 40;
  background: rgba(250,245,234,.86); backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
header.site .nav { max-width: 1080px; margin: 0 auto; padding: 14px 28px; display: flex; align-items: center; gap: 22px; }
nav.main { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.navlink {
  border: none; background: none; cursor: pointer; font: inherit; font-weight: 600;
  color: var(--ink-soft); padding: 9px 14px; border-radius: 999px; transition: background .15s, color .15s;
}
.navlink:hover { background: var(--paper-dim); color: var(--ink); }
.navlink[aria-current="page"] { background: var(--navy); color: #fdf9ef; }
.patientsel, .langsel {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
}
footer.site { padding: 40px 0 60px; text-align: center; color: var(--ink-soft); font-size: .92rem; }

/* ---- buttons ---------------------------------------------------------------*/
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: .98rem; cursor: pointer;
  border-radius: 999px; border: 1px solid transparent; padding: 12px 22px;
  background: var(--card); color: var(--navy); border-color: var(--line);
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn.primary { background: var(--navy); color: #fdf9ef; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-deep); }
.btn.ghost { background: transparent; }
.btn.green { background: var(--green); color: #fbfff9; border-color: var(--green); }
.btn.danger { background: var(--rose-soft); color: var(--rose); border-color: #eecdd7; }
.btn.sm { padding: 7px 14px; font-size: .88rem; }
.btn.big { padding: 16px 26px; font-size: 1.08rem; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: none; color: var(--blue); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.iconbtn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem;
}
.iconbtn.del:hover { background: var(--rose-soft); border-color: #eecdd7; }

/* ---- auth shell ------------------------------------------------------------*/
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 38px 34px; box-shadow: var(--shadow-pop);
  animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-card .brand { justify-content: center; margin-bottom: 22px; }
.auth-card h1 { text-align: center; font-size: 1.7rem; }
.auth-sub { text-align: center; margin-top: -6px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--ink-soft); }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 16px; }
.notice.err { background: var(--rose-soft); color: #8a2f45; }
.notice.ok { background: var(--green-soft); color: #1f5c40; }
.notice.warn { background: var(--amber-soft); color: #7a4c10; }

/* ---- forms -------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: .88rem; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus, button:focus-visible, .navlink:focus-visible {
  outline: 3px solid #bcd6ee; outline-offset: 1px; border-color: var(--blue);
}
.field textarea { min-height: 88px; resize: vertical; }
.field .hint { display: block; font-size: .82rem; color: var(--ink-soft); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 16px; }

/* ---- modal ---------------------------------------------------------------*/
.modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,25,32,.45); backdrop-filter: blur(2px); animation: fadeIn .18s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  position: relative; z-index: 1; max-width: 460px; width: calc(100% - 40px); margin: 6vh auto 0;
  background: var(--card); border-radius: var(--radius-lg); padding: 28px 26px; box-shadow: var(--shadow-pop);
  max-height: 86vh; overflow: auto; animation: pop .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 1.3rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---- toast -----------------------------------------------------------------*/
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--navy-deep); color: #fdf9ef; padding: 13px 22px; border-radius: 999px;
  font-weight: 600; font-size: .95rem; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  box-shadow: var(--shadow-pop); z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #6b2436; }

/* ---- today view ------------------------------------------------------------*/
.pt-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.greet { color: var(--ink-soft); margin-bottom: 2px; font-size: 1rem; }
.who { font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--navy-deep); margin: 0; }

.rem {
  display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow-card);
}
.rem.done-row { opacity: .6; }
.rem .ic { font-size: 1.6rem; width: 44px; text-align: center; }
.rem .txt { flex: 1; display: flex; flex-direction: column; }
.rem .t { font-weight: 700; font-size: 1.08rem; }
.rem .time { color: var(--ink-soft); }
.bigdone {
  border: none; border-radius: 999px; padding: 12px 20px; font-weight: 700; cursor: pointer; font-size: .95rem;
  transition: transform .12s;
}
.bigdone:hover { transform: translateY(-1px); }
.bigdone.todo { background: var(--blue-soft); color: var(--navy); }
.bigdone.ok { background: var(--green-soft); color: var(--green); }
.status { font-size: .85rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.status.done { background: var(--green-soft); color: var(--green); }
.status.up { background: var(--blue-soft); color: var(--blue); }

.pt-actions { display: flex; gap: 14px; margin: 26px 0 8px; flex-wrap: wrap; }
.readaloud, .sos {
  border: none; border-radius: 999px; padding: 16px 26px; font-weight: 700; font-size: 1.05rem; cursor: pointer;
  box-shadow: var(--shadow-card);
}
.readaloud { background: var(--blue-soft); color: var(--navy); }
.sos { background: var(--rose); color: #fff6f7; }
.sos:hover, .readaloud:hover { transform: translateY(-1px); }

.grid.cols-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
.fam-card, .mem-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 18px;
  box-shadow: var(--shadow-card); text-align: center;
}
.fam-card .avatar, .avatar {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center;
  justify-content: center; font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; color: #fff; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.fam-card .nm { font-weight: 700; font-size: 1.05rem; }
.fam-card .rel { color: var(--ink-soft); font-size: .9rem; }
.fam-card .note { font-size: .88rem; color: var(--ink-soft); margin-top: 6px; }

.mem-card { padding: 0; overflow: hidden; cursor: pointer; text-align: left; }
.mem-card img { width: 100%; height: 190px; object-fit: cover; display: block; }
.mem-card .cap { padding: 14px 16px 4px; font-weight: 700; }
.mem-card .by { padding: 0 16px 14px; color: var(--ink-soft); font-size: .85rem; }
.mem-card:hover { box-shadow: var(--shadow-pop); }

.empty { text-align: center; padding: 46px 20px; border: 1.5px dashed var(--line); border-radius: var(--radius-md); background: var(--paper-dim); }
.empty .ic { font-size: 2.4rem; margin-bottom: 8px; }
.empty h3 { justify-content: center; }

/* ---- manage view -----------------------------------------------------------*/
.spread { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.badge { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; padding: 4px 10px; border-radius: 999px; }
.badge.owner { background: var(--amber-soft); color: var(--amber); }
.badge.caregiver { background: var(--blue-soft); color: var(--blue); }
.badge.view { background: var(--paper-dim); color: var(--ink-soft); }

.fstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.fstat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; text-align: center; }
.fstat b { display: block; font-family: var(--font-display); font-size: 1.7rem; color: var(--navy-deep); }
.fstat span { color: var(--ink-soft); font-size: .85rem; }
.fstat.c b { color: var(--green); }
.fstat.u b { color: var(--blue); }
@media (max-width: 620px) { .fstats { grid-template-columns: repeat(2, 1fr); } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 22px 8px; margin-top: 20px; box-shadow: var(--shadow-card); }
.lrow { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--paper-dim); }
.lrow:last-child { border-bottom: none; }
.lrow .ic { width: 34px; text-align: center; font-size: 1.2rem; }
.lrow .info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lrow .t { font-weight: 700; }
.lrow .s { color: var(--ink-soft); font-size: .88rem; }

/* ---- account view ------------------------------------------------------------*/
.loading-full { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--ink-soft); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--navy); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .wrap { padding: 0 18px; }
  header.site .nav { padding: 12px 18px; gap: 12px; }
  nav.main { gap: 4px; }
  h1 { font-size: 1.7rem; }
  .who { font-size: 1.6rem; }
}
