/* ---- Design tokens ---- */
:root {
  --bg: #F4F7F4;
  --surface: #FFFFFF;
  --border: #DEE6E0;
  --border-soft: #E9EFEB;

  --text: #1E2B26;
  --text-soft: #5C6B63;
  --text-faint: #8A968F;

  --teal: #386E5D;
  --teal-dark: #274F42;
  --teal-tint: #E4EFEA;

  --amber: #B98A3E;
  --amber-tint: #FBF2E1;

  --mild: #6E9C7C;
  --moderate: #C9963E;
  --severe: #B84E3A;

  --danger: #B84E3A;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(30, 43, 38, 0.06);
  --shadow-md: 0 6px 20px rgba(30, 43, 38, 0.08);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  /* rotating "thread" colors assigned to people, in order added */
  --thread-0: #386E5D;
  --thread-1: #B98A3E;
  --thread-2: #7A5C8E;
  --thread-3: #4A7EA8;
  --thread-4: #B84E3A;
  --thread-5: #6E9C7C;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--teal-dark);
  margin: 0;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

input {
  font-family: var(--font-body);
}

a { color: var(--teal); }

::selection { background: var(--teal-tint); }

/* ---- Gate (family code entry) ---- */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 400px at 15% 10%, var(--teal-tint), transparent),
    radial-gradient(500px 350px at 85% 90%, var(--amber-tint), transparent),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  text-align: center;
}

.gate-mark {
  color: var(--teal);
  display: inline-flex;
  margin-bottom: 12px;
}

.gate-card h1 {
  font-size: 28px;
  margin-bottom: 10px;
}

.gate-sub {
  color: var(--text-soft);
  font-size: 14.5px;
  margin: 0 0 28px;
  line-height: 1.55;
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

#gate-form label {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

#gate-form input {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-size: 15px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.15s ease;
}

#gate-form input:focus-visible {
  border-color: var(--teal);
}

#gate-form button {
  margin-top: 4px;
  background: var(--teal);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s ease;
}

#gate-form button:hover { background: var(--teal-dark); }

.gate-hint {
  font-size: 12.5px;
  color: var(--text-faint);
  margin: 20px 0 0;
  line-height: 1.5;
}

.gate-error {
  margin-top: 14px;
  color: var(--danger);
  font-size: 13.5px;
}

.google-btn-wrap {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

/* ---- App shell ---- */

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--teal-dark);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  padding: 0 4px;
}

.family-chip {
  background: var(--teal-tint);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.family-chip-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal-dark);
  opacity: 0.75;
}

.family-chip-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--teal-dark);
  word-break: break-all;
}

.people-list-head {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 0 4px;
  font-weight: 600;
}

.people-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.people-list li {
  border-radius: var(--radius);
}

.people-list button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 10px;
  border-radius: var(--radius);
  font-size: 14.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.12s ease;
}

.people-list button:hover { background: var(--border-soft); }

.people-list button.active {
  background: var(--teal-tint);
  color: var(--teal-dark);
  font-weight: 600;
}

.thread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.add-person-form {
  display: flex;
  gap: 6px;
}

.add-person-form input {
  flex: 1;
  padding: 9px 10px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-size: 13.5px;
  outline: none;
}

.add-person-form input:focus-visible { border-color: var(--teal); }

.add-person-form button {
  width: 34px;
  border-radius: var(--radius);
  border: none;
  background: var(--teal);
  color: white;
  font-size: 18px;
  line-height: 1;
}

.sign-out {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 6px 4px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sign-out:hover { color: var(--text-soft); }

/* ---- Main content ---- */

.main {
  padding: 36px 44px;
  max-width: 760px;
}

.empty-state {
  margin-top: 60px;
  max-width: 420px;
}

.empty-state h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

.empty-state p {
  color: var(--text-soft);
  font-size: 14.5px;
}

.person-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.person-header h1 {
  font-size: 30px;
  border-left: 4px solid var(--current-thread, var(--teal));
  padding-left: 14px;
}

.link-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.75;
}

.link-danger:hover { opacity: 1; }

.panel {
  margin-bottom: 34px;
}

.panel-head {
  margin-bottom: 12px;
}

.panel-head h2 {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.record-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.record-main { flex: 1; min-width: 0; }

.record-title {
  font-weight: 600;
  font-size: 14.5px;
}

.record-meta {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 2px;
}

.record-notes {
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 4px;
  font-style: italic;
}

.record-delete {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12px;
  flex-shrink: 0;
  padding: 2px 6px;
}

.record-delete:hover { color: var(--danger); }

.empty-list-hint {
  font-size: 13px;
  color: var(--text-faint);
  padding: 4px 2px 8px;
  font-style: italic;
}

.severity-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
}

.severity-mild { background: rgba(110, 156, 124, 0.15); color: var(--mild); }
.severity-moderate { background: rgba(201, 150, 62, 0.15); color: var(--moderate); }
.severity-severe { background: rgba(184, 78, 58, 0.15); color: var(--severe); }

.record-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.record-form input {
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-size: 13.5px;
  outline: none;
  min-width: 0;
}

.record-form input:focus-visible { border-color: var(--teal); }

.record-form button {
  grid-column: -1;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px;
}

.record-form button:hover { background: var(--teal-dark); }

.notes-form {
  grid-template-columns: 1.5fr 1fr;
}

.severity-picker {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--text-soft);
  padding: 0 2px;
}

.severity-picker label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.share-panel {
  background: var(--amber-tint);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.share-sub {
  font-size: 13.5px;
  color: var(--text-soft);
  margin: 0 0 12px;
}

.secondary-btn {
  background: white;
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  margin-right: 8px;
}

.secondary-btn:hover { border-color: var(--amber); }

#summary-output {
  width: 100%;
  margin-top: 12px;
  min-height: 160px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--teal-dark);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.toast.error { background: var(--danger); }

/* ---- Responsive ---- */

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .people-list { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .main { padding: 24px 20px; }
  .record-form { grid-template-columns: 1fr 1fr; }
  .record-form button { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Elements set explicit `display` values above, which otherwise override the
   browser's default "hidden means display:none" behavior. This makes sure
   the `hidden` attribute always wins. */
[hidden] {
  display: none !important;
}
