:root {
  --bg:      #0a0a0a;
  --surface: #141414;
  --card:    #1c1c1c;
  --border:  #2a2a2a;
  --text:    #f0f0f0;
  --muted:   #888;
  --accent:  #A855F7;
  --accent-soft: rgba(168, 85, 247, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  min-height: 100vh;
  font-size: 16px;
}

/* ── Profile Screen ───────────────────────────────────────── */

#profile-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.profile-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.profile-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

.profile-header p {
  color: var(--muted);
  font-size: 1rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 720px;
}

.profile-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem 1rem;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-size: 0.95rem;
  font-weight: 600;
}

.profile-card:hover {
  transform: translateY(-2px);
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

/* ── Main App ─────────────────────────────────────────────── */

#main-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

#header-name {
  font-weight: 600;
  font-size: 0.95rem;
}

#signout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

#signout-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Login page ───────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.login-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  width: 100%;
}

.google-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 10px;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  margin-top: 0.5rem;
  transition: box-shadow 0.15s;
}

.google-btn:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.login-security-link {
  display: block;
  text-align: center;
  margin-top: 1.2rem;
  color: var(--muted);
  font-size: 0.83rem;
  text-decoration: none;
}
.login-security-link:hover { color: var(--text); }

/* ── Tab Bar ──────────────────────────────────────────────── */

#tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 1rem;
  position: sticky;
  top: 57px;
  z-index: 9;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Content ──────────────────────────────────────────────── */

#content {
  flex: 1;
  padding: 1.5rem 1.25rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.tab-content { display: flex; flex-direction: column; gap: 1rem; }

.section-header {
  margin-bottom: 0.25rem;
}

.section-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.section-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

/* ── Items ────────────────────────────────────────────────── */

.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.item-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.item-text { flex: 1; font-size: 0.95rem; line-height: 1.4; }

.item-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.delete-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ── Add Form ─────────────────────────────────────────────── */

.add-form {
  display: flex;
  gap: 0.5rem;
}

.add-form input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.add-form input::placeholder { color: var(--muted); }

.add-form input:focus { border-color: var(--accent); }

.add-btn {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  padding: 0.7rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.add-btn:hover { opacity: 0.85; }

/* ── Board Tab ────────────────────────────────────────────── */

.board-pane { display: flex; flex-direction: column; gap: 1rem; }

.board-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.board-form input,
.board-form textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}

.board-form input::placeholder,
.board-form textarea::placeholder { color: var(--muted); }

.board-form input:focus,
.board-form textarea:focus { border-color: var(--accent); }

.board-form .add-btn { align-self: flex-end; }

.topic-link {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.topic-link:hover { color: var(--accent); }

.post-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  line-height: 1.5;
}

.topic-title { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }

.board-replies { margin-top: 0.5rem; }

/* ── Lists Tab ────────────────────────────────────────────── */

.list-user-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.list-user-picker select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.list-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.list-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.list-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.delete-list-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.delete-list-btn:hover { color: #ef4444; }

/* ── Calendar Placeholder ─────────────────────────────────── */

.placeholder-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.placeholder-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.placeholder-card p {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 280px;
  line-height: 1.5;
}

.placeholder-note {
  font-size: 0.8rem !important;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

/* ── Empty State ──────────────────────────────────────────── */

.empty-state {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.75rem 0;
  text-align: center;
}

/* ── Modal ────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); }

.modal-form {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.modal-form > label,
.modal-form > div > label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-form input[type="text"],
.modal-form input[type="date"],
.modal-form input[type="time"] {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
}

.modal-form input:focus { border-color: var(--accent); }

.checkbox-label {
  flex-direction: row !important;
  align-items: center !important;
  color: var(--text) !important;
  gap: 0.5rem !important;
  font-size: 0.9rem !important;
  cursor: pointer;
}

#time-fields {
  display: flex;
  gap: 0.75rem;
}

#time-fields label { flex: 1; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-top: 0.25rem;
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.15s, border-color 0.15s;
}
.btn-cancel:hover { color: var(--text); border-color: var(--muted); }

.event-error {
  color: #ef4444;
  font-size: 0.83rem;
  padding: 0.5rem 0.75rem;
  background: rgba(239,68,68,0.08);
  border-radius: 8px;
}

/* ── Calendar header ──────────────────────────────────────── */

.cal-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.add-event-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  margin-top: 0.1rem;
}
.add-event-btn:hover { opacity: 0.85; }

.connect-btn {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  margin-top: 0.3rem;
  display: inline-block;
}
.connect-btn:hover { text-decoration: underline; }

/* ── Calendar ─────────────────────────────────────────────── */

#calendar-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cal-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.cal-today { border-color: var(--accent); }

.cal-day-header {
  padding: 0.55rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.cal-today .cal-day-header {
  color: var(--accent);
  background: var(--accent-soft);
}

.cal-events { padding: 0.35rem 0; }

.cal-event {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.cal-time {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  min-width: 58px;
  flex-shrink: 0;
}

.cal-title { flex: 1; }

.cal-loc {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  width: 100%;
  padding-left: calc(58px + 0.75rem);
  margin-top: -0.2rem;
}

/* ── Security Page ───────────────────────────────────────── */

.security-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--bg);
}

.security-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 680px;
  width: 100%;
}

.security-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.security-intro {
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.security-section {
  border-top: 1px solid var(--border);
  padding: 1.4rem 0;
}

.security-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent, #A855F7);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.security-section p,
.security-section li {
  color: #ccc;
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: 0.5rem;
}

.security-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0 0.8rem;
}

.security-table th,
.security-table td {
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 0.6rem 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.security-table th {
  font-weight: 600;
}

.security-section ul {
  padding-left: 1.4rem;
  margin: 0.4rem 0 0.5rem;
}

.security-section code {
  font-size: 0.82rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: #e0e0e0;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}
.back-link:hover { color: var(--text); }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 480px) {
  .profile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .profile-header h1 { font-size: 1.6rem; }
  #content { padding: 1rem; }
  /* Five tabs must fit on a phone without scrolling sideways. */
  #tab-bar { padding: 0 0.25rem; }
  .tab-btn { padding: 0.75rem 0.55rem; font-size: 0.85rem; }
}

/* ── Groups ───────────────────────────────────────────────── */

.header-names { display: flex; flex-direction: column; line-height: 1.2; }
.header-group { color: var(--muted); font-size: 0.8rem; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.group-switch, .role-select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.4rem 0.5rem; font-size: 0.9rem;
}
.group-gap { margin-top: 2rem; }
.admin-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin: 0.75rem 0; }
.color-input { width: 3rem; min-width: 3rem; padding: 0; border: none; background: none; }
.invite-result { margin: 0.75rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.invite-result input {
  width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem; font-size: 0.85rem;
}
.invite-result p { color: var(--muted); font-size: 0.9rem; }
.welcome-form { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.5rem 0; }
.welcome-form input {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.7rem; font-size: 1rem;
}
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 0.7rem 1.1rem; border-radius: 10px; z-index: 100; max-width: 90vw;
}
.add-form .color-input { flex: 0 0 3rem; height: 2.6rem; cursor: pointer; }
.header-link { color: var(--muted); font-size: 0.85rem; text-decoration: none; }

