/* =====================================
   Variables
===================================== */
:root {
  --color-bg: #f6f4ef;
  --color-surface: #ffffff;
  --color-ink: #1f1f1f;
  --color-muted: #5c5c5c;
  --color-accent: #147a6e;
  --color-accent-strong: #0f5a52;
  --color-border: #e5e0d8;
  --color-highlight: #f0e7d9;
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.08);
  --shadow-tight: 0 6px 16px rgba(0, 0, 0, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --max-width: 1100px;
  --bottom-nav-height: 64px;
}

/* =====================================
   Reset
===================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
h4,
p,
ul,
ol {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fffdf9;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th,
.table td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.table th {
  font-weight: 700;
  color: var(--color-muted);
}

.detail-list {
  display: grid;
  gap: var(--space-3);
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.detail-row dt {
  font-weight: 700;
  color: var(--color-muted);
}

.detail-row dd {
  margin: 0;
}

/* =====================================
   Layout
===================================== */
body {
  min-height: 100vh;
  color: var(--color-ink);
  background: linear-gradient(160deg, #f8f6f1 0%, #f1ebe1 40%, #f7f0e4 100%);
  font-family: ui-sans-serif, "Segoe UI", "Noto Sans", "Liberation Sans", sans-serif;
  line-height: 1.6;
}

.content-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.site-main {
  padding: var(--space-7) 0 var(--space-8);
}

/* =====================================
   Header (desktop)
===================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 244, 239, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
}

.logo {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.logo-mark {
  width: 28px;
  height: 28px;
  display: inline-block;
}

/* =====================================
   Bottom Navigation (mobile)
===================================== */
.site-nav {
  margin-left: auto;
}

.nav-list {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: var(--color-muted);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: color 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.emoji-icon {
  font-size: 0.95rem;
  margin-right: var(--space-2);
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-link.is-active {
  color: var(--color-ink);
  background: var(--color-highlight);
}

.nav-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* =====================================
   Components
===================================== */
.page-header {
  margin-bottom: var(--space-6);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

h1 {
  font-size: clamp(2rem, 2.8vw, 3rem);
  line-height: 1.1;
  margin-bottom: var(--space-3);
  font-family: ui-serif, Georgia, "Times New Roman", serif;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-size: 1.05rem;
  color: var(--color-muted);
  max-width: 700px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-soft);
}

.alert {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  font-weight: 600;
}

.alert-error {
  background: #fff2f0;
  border-color: #f2b8b5;
  color: #8b1a10;
}

.is-hidden {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
}

.stack {
  display: grid;
  gap: var(--space-4);
}

.tight-stack {
  gap: var(--space-1);
}

.list {
  margin-top: var(--space-3);
  padding-left: var(--space-4);
  list-style: disc;
}

.action-list {
  display: grid;
  gap: var(--space-2);
  padding-left: var(--space-4);
  list-style: disc;
}

.action-list a {
  display: inline-block;
}

.action-list .is-highlight {
  background: #d9f3d8;
  border: 1px solid #7cbf7a;
  color: #1f5b2a;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--color-highlight);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}



.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-5);
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-small {
  padding: var(--space-1) var(--space-3);
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: var(--shadow-tight);
}

.btn-primary:hover {
  background: var(--color-accent-strong);
}

.btn-secondary {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-highlight);
}

.btn-register {
  background: #d9f3d8;
  color: #1f5b2a;
  border-color: #b7e4b6;
}

.btn-register:hover {
  background: #c6edc4;
}

.btn-wide {
  min-width: 220px;
  text-align: center;
}

.btn-danger {
  background: #f7d7d3;
  color: #7a1f15;
  border-color: #f2b8b5;
}

.btn-danger:hover {
  background: #f3c2bd;
}

.link {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.link:hover {
  text-decoration: underline;
}

/* =====================================
   Forms
===================================== */
.form {
  display: grid;
  gap: var(--space-4);
}

.form-field {
  display: grid;
  gap: var(--space-2);
}

.field-required {
  color: var(--color-accent-strong);
  font-weight: 600;
  font-size: 0.85rem;
}

.field-optional {
  color: var(--color-muted);
  font-weight: 500;
  font-size: 0.85rem;
}

label {
  font-weight: 600;
}

input {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fffdf9;
}

input:disabled {
  background: #ece7df;
  color: #8b857c;
}

.field-error input,
.field-error textarea {
  border-color: #f2b8b5;
  background: #fff7f6;
}

textarea {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fffdf9;
  resize: vertical;
}

input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
}

.when-no-invite {
  display: none;
}

.when-invite {
  display: inline;
}

.no-invite-active .when-no-invite {
  display: inline;
}

.no-invite-active .when-invite {
  display: none;
}

.form-hint {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* =====================================
   Utilities
===================================== */
.muted {
  color: var(--color-muted);
}

/* =====================================
   Toast Notifications
===================================== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: min(420px, calc(100vw - var(--space-6)));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-content {
  flex: 1;
  font-size: 0.95rem;
  color: var(--color-ink);
  line-height: 1.4;
}

.toast-undo {
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-accent);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.toast-undo:hover {
  background: var(--color-accent);
  color: #ffffff;
}

.toast-undo:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .toast-container {
    top: auto;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + var(--space-3));
    left: var(--space-3);
    right: var(--space-3);
    max-width: none;
  }

  .toast {
    width: 100%;
  }
}

/* =====================================
   Footer
===================================== */
.site-footer {
  padding: var(--space-6) 0 var(--space-7);
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
}

.table td .stack.tight-stack {
  justify-items: start;
}

.table td .stack.tight-stack > .btn {
  justify-self: start;
  width: fit-content;
}

/* =====================================
   Responsive
===================================== */
@media (max-width: 768px) {
  /* Keep header in DOM so the nav inside it can still be fixed-bottom */
  .site-header {
    position: static;          /* don’t need sticky on mobile */
    border-bottom: 0;
    background: transparent;
    backdrop-filter: none;
  }
  /* Optionally hide the header’s inner row (logo area)
  .header-inner {
    display: none;
  } */
  .site-main {
    padding-top: var(--space-5);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + var(--space-5));
  }
  .header-inner {
    justify-content: center;
  }

  .logo-mark {
    width: 24px;
    height: 24px;
  }
  .site-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f2f2f2;
    border-top: 1px solid #d8d8d8;
    padding: var(--space-2) var(--space-4)
      calc(env(safe-area-inset-bottom, 0px) + var(--space-2));
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.12);
    z-index: 20;
  }

  .nav-list {
    justify-content: space-between;
    width: 100%;
  }

  .nav-link {
    font-size: 0.9rem;
    padding: var(--space-2) var(--space-2);
    flex-direction: column;
    gap: 6px;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }

  .site-footer {
    display: none;
  }


  .profile-actions {
    display: flex;
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-4);
  }

  .profile-actions > .card {
    width: min(92%, 420px);     /* readable width, not full screen */
    margin-right: 0;            /* snap to right */
    margin-left: auto;          /* push right */
  }  

  .learning-actions {
    display: flex;
    justify-content: flex-end;
  }

  .learning-actions > .card {
    width: min(92%, 420px);     /* readable width, not full screen */
    margin-right: 0;            /* snap to right */
    margin-left: auto;          /* push right */
  }
  .action-list {
    padding-left: 0;
    list-style: none;
    gap: var(--space-3);
  }

  .action-list a {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-highlight);
    text-align: center;
  }

  .action-list .is-highlight {
    background: #d9f3d8;
    border: 1px solid #7cbf7a;
    color: #1f5b2a;
  }

  .btn {
    width: 100%;
  }

  .btn.btn-small {
    width: auto;
  }

}

@media (min-width: 769px) {
  .nav-link {
    font-size: 1rem;
  }

  .nav-icon {
    width: 18px;
    height: 18px;
  }
}
