/* Core pages (/login/, /register/, /auth/callback/, /app/). Load after shared/tokens.css.
   Big touch targets (at least 48px), one column on a phone. */

[hidden] { display: none !important; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 8px 0 16px; }
h2 { font-size: 1.2rem; margin: 28px 0 12px; }

/* Top bar */
.core-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.core-brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.1rem; min-height: 48px; }
.core-bar-end { display: flex; align-items: center; gap: 8px; min-width: 0; }
.core-bar-child { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.core-bar-child img { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); }
.core-bar-child span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Page */
.core-page { max-width: var(--page-width); margin: 0 auto; padding: 16px 16px 48px; }
.core-narrow { max-width: 460px; }
.core-lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 16px; }
.core-note { color: var(--muted); font-size: .95rem; }
.core-error { color: var(--danger); font-weight: 600; background: #fdecec; border-radius: var(--radius-small); padding: 10px 12px; }
.core-switch { margin-top: 20px; text-align: center; }
.core-form > .core-note { margin: 0; }
.core-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.core-card + .core-card { margin-top: 16px; }
.core-notice { color: var(--ink); font-weight: 600; background: var(--accent-light); border-radius: var(--radius-small); padding: 10px 12px; }
.core-text-button {
  align-self: center; min-height: 48px; padding: 0 12px; border: 0; background: none;
  color: var(--accent-dark); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer;
}

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: var(--radius-small);
  border: 2px solid var(--accent); background: var(--surface); color: var(--accent-dark);
  font-weight: 700; text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--accent-light); }
.button-primary { background: var(--accent); color: var(--on-accent); }
.button-primary:hover { background: var(--accent-dark); }
.button-danger { border-color: var(--danger); color: var(--danger); }
.button-danger:hover { background: #fdecec; }
.button-small { min-height: 40px; padding: 6px 14px; font-size: .95rem; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* Forms */
.core-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="search"], .field select {
  min-height: 48px; padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius-small);
  background: var(--surface); color: var(--ink); font-weight: 400; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; min-width: 48px;
  padding: 8px 16px; border: 2px solid var(--line); border-radius: var(--radius-small); background: var(--surface); font-weight: 600;
}
.chip-square span { padding: 8px 0; }
.chip input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.chip input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
.avatar-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.avatar-choice { position: relative; cursor: pointer; }
.avatar-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.avatar-choice img { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 50%; border: 4px solid transparent; background: var(--surface-2); }
.avatar-choice input:checked + img { border-color: var(--accent); box-shadow: 0 0 0 3px var(--yellow); }
.avatar-choice input:focus-visible + img { outline: 3px solid var(--yellow); }

/* Dialogs */
.core-dialog {
  width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 20px;
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink);
}
.core-dialog::backdrop { background: rgba(18, 48, 47, .45); }
.core-dialog h2 { margin: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Mode choice */
.mode-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.mode-button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 140px; border: 3px solid var(--accent); border-radius: var(--radius); background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow); cursor: pointer;
}
.mode-button strong { font-size: 1.6rem; color: var(--accent-dark); }
.mode-button span { color: var(--muted); }
.mode-button:hover { background: var(--accent-light); }

/* Parent view */
.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.quick-link {
  display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 12px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  color: var(--accent-dark); font-weight: 700; font-size: 1.05rem; text-decoration: none; cursor: pointer;
}
.quick-link:hover { border-color: var(--accent); }
.child-list, .member-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.child-card {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.child-card img { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); flex: none; }
.child-card-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.child-card-text strong { font-size: 1.1rem; }
.child-card-text span { color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.member-list li { display: flex; flex-direction: column; padding: 10px 12px; background: var(--surface); border-radius: var(--radius-small); }
.member-list span { color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }

/* Child mode */
.child-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.child-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px;
  border: 3px solid transparent; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  color: var(--ink); font-size: 1.3rem; font-weight: 700; cursor: pointer;
}
.child-tile:hover { border-color: var(--accent); }
.child-tile img { width: 110px; height: 110px; border-radius: 50%; background: var(--surface-2); }
.child-tile span { overflow-wrap: anywhere; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.app-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 16px;
  border: 3px solid transparent; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  color: var(--ink); text-decoration: none;
}
.app-tile:hover { border-color: var(--accent); }
.app-tile img { width: 72px; height: 72px; border-radius: 50%; background: var(--surface-2); }
.app-tile strong { font-size: 1.15rem; color: var(--accent-dark); }
.app-tile span { color: var(--muted); }

@media (max-width: 420px) {
  h1 { font-size: 1.4rem; }
  .core-bar:has(.core-bar-child:not([hidden])) .core-brand span { display: none; }
  .child-tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .child-tile img { width: 88px; height: 88px; }
  .core-dialog { padding: 16px; }
  .app-tile { display: grid; grid-template-columns: 64px 1fr; column-gap: 12px; align-items: center; }
  .app-tile img { width: 64px; height: 64px; grid-row: span 2; }
}

/* Password field with the show/hide eye button */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 52px; }
.password-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 44px; height: 44px;
  display: grid; place-items: center; border: 0; border-radius: var(--radius-small); background: none; color: var(--muted); cursor: pointer; }
.password-toggle:hover { color: var(--ink); background: var(--accent-light); }
.password-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-closed, .password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }
