/* Memoist — Clean & Utilitarian */

:root {
  --fg:         #0d1117;
  --bg:         #f5f7fa;
  --surface:    #ffffff;
  --accent:     #1a5fa8;
  --accent-hov: #144d8c;
  --muted:      #5a6472;
  --border:     #dce1e9;
  --success:    #1a7a4a;
  --error-bg:   #fff0f0;
  --error-bdr:  #f5c0c0;
  --notice-bg:  #f0f7f0;
  --notice-bdr: #b8ddb8;
  --mono:       'JetBrains Mono', monospace;
  --sans:       'Instrument Sans', sans-serif;
  --radius:     6px;
  --max-w:      720px;
}

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

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--muted);
  gap: 1.5rem;
  flex-wrap: wrap;
}
.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
}
.footer-links a:hover { color: var(--fg); }
.footer-copy { font-size: 0.75rem; color: var(--muted); }
.main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  flex: 1;
  width: 100%;
}

/* Brand */
.brand {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--fg);
}
.brand span { color: var(--accent); }

/* Nav */
nav { display: flex; align-items: center; gap: 1rem; }
.nav-email { font-size: 0.8rem; color: var(--muted); }
.inline-form { display: inline; margin: 0; }

/* Flash */
.flash {
  max-width: var(--max-w);
  margin: 1rem auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid;
}
.flash--error  { background: var(--error-bg);  border-color: var(--error-bdr);  color: #8b1a1a; }
.flash--notice { background: var(--notice-bg); border-color: var(--notice-bdr); color: #1a5c1a; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}
.btn--primary   { background: var(--accent);  color: #fff; }
.btn--primary:hover { background: var(--accent-hov); }
.btn--secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
.btn--secondary:hover { background: var(--bg); }
.btn--success   { background: var(--success); color: #fff; }
.btn-ghost-sm {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  color: var(--fg);
  text-decoration: none;
}

/* Forms */
.form-group   { margin-bottom: 1.25rem; }
.form-label   { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.35rem; }
.form-label .optional { font-weight: 400; color: var(--muted); }
.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--fg);
}
.form-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* Labels (mono uppercase) */
.label {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* Tags */
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}
.tag--contribute { background: #e8f0fb; color: var(--accent); }
.tag--view       { background: #e8f5ee; color: var(--success); }

/* Hero */
.hero { padding: 2rem 0 1.5rem; }
.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}
.hero .lede { font-size: 1rem; color: var(--muted); max-width: 440px; margin-bottom: 1.5rem; }

/* Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 2rem;
}
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.step-num { font-family: var(--mono); font-size: 0.65rem; color: var(--accent); font-weight: 500; margin-bottom: 0.4rem; }
.step h3  { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.2rem; }
.step p   { font-size: 0.78rem; color: var(--muted); }

/* Card list */
.card-list { display: flex; flex-direction: column; gap: 0.5rem; }
.card-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  text-decoration: none;
  color: var(--fg);
}
.card-item:hover { border-color: var(--accent); }
.card-item__title { font-weight: 600; font-size: 0.9rem; }
.card-item__meta  { font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }
.card-item__badge { margin-left: auto; color: var(--muted); }

/* Share links */
.share-links { margin-bottom: 1.25rem; }
.link-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.link-url {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Clip rows (owner view) */
.clip-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.4rem;
}
.play-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.play-btn:hover { background: var(--accent-hov); }
.clip-meta__name { font-size: 0.82rem; font-weight: 600; }
.clip-meta__when { font-size: 0.68rem; color: var(--muted); font-family: var(--mono); }
.clip-dur { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }

/* Recorder */
.recorder { max-width: 480px; margin: 0 auto; }
.recorder-header { text-align: center; margin-bottom: 1.5rem; }
.recorder-header .for-who { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); margin-bottom: 0.25rem; }
.recorder-header h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }

.rec-zone {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
[data-state="recording"] .rec-zone { border-color: #e53935; background: #fff5f5; }
[data-state="preview"]   .rec-zone { display: none; }

[data-state="idle"]      .state-recording,
[data-state="idle"]      .state-preview   { display: none; }
[data-state="recording"] .state-idle,
[data-state="recording"] .state-preview   { display: none; }
[data-state="preview"]   .state-idle,
[data-state="preview"]   .state-recording { display: none; }

.rec-button {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #e53935;
  border: 3px solid white;
  box-shadow: 0 0 0 2px #e53935;
  cursor: pointer;
  transition: transform 0.1s;
}
.rec-button:hover { transform: scale(1.05); }
.rec-button--stop {
  background: #333;
  box-shadow: 0 0 0 2px #333;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px #333; }
  50%       { box-shadow: 0 0 0 6px rgba(51,51,51,0.2); }
}
.rec-timer { font-family: var(--mono); font-size: 1rem; color: #e53935; }
.rec-hint  { font-size: 0.78rem; color: var(--muted); }

.preview-panel {
  background: #e8f0fb;
  border: 1px solid #bdd0f0;
  border-radius: 8px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}
[data-state="preview"]   .preview-panel { display: block; }
[data-state="idle"]      .preview-panel,
[data-state="recording"] .preview-panel { display: none; }

.preview-panel h3     { font-size: 0.85rem; font-weight: 600; color: var(--accent); margin-bottom: 0.6rem; }
.preview-panel audio  { width: 100%; margin-bottom: 0.75rem; }
.preview-actions      { display: flex; gap: 0.5rem; }
.preview-actions .btn { flex: 1; justify-content: center; }

.rec-success { text-align: center; padding: 2rem 1rem; }
.rec-success h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.rec-success p  { font-size: 0.85rem; color: var(--muted); }

/* View page */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.view-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.03em; }
.view-header .sub { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }
.view-clip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
}
.view-clip__top  { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.view-clip__name { font-size: 0.85rem; font-weight: 600; flex: 1; }
.view-clip audio { width: 100%; }

/* Dev login banner */
.dev-banner {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  color: #7c5a00;
  margin-bottom: 1.5rem;
  font-family: var(--mono);
}

/* Page titles */
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 1.5rem; }

/* Utilities */
.muted { color: var(--muted); }
.mono  { font-family: var(--mono); }
.row   { display: flex; align-items: center; gap: 0.75rem; }
.row--between { justify-content: space-between; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.stack > * + * { margin-top: 0.75rem; }

/* ── Nav user block ─────────────────────────────────────────────────────── */

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.nav-avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #bdd0f0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Dashboard grid ─────────────────────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 640px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-section + .dashboard-section {
  margin-top: 1.5rem;
}

.dashboard-empty {
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ── Stacked contributor avatars ────────────────────────────────────────── */

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar-stack .av {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid white;
  margin-left: -5px;
  object-fit: cover;
}

.avatar-stack .av:first-child {
  margin-left: 0;
}

.avatar-stack .av--fallback {
  background: #bdd0f0;
  color: var(--accent);
  font-size: 0.55rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Invitation rows (cards/show) ───────────────────────────────────────── */

.inv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.inv-row:last-of-type {
  border-bottom: none;
}

.inv-email {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--fg);
}

/* ── Clip avatar (card show + view pages) ───────────────────────────────── */

.clip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.clip-avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #bdd0f0;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

/* ── Status pills ────────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
}

.pill-contrib  { background: #e8f5ee; color: var(--success); }
.pill-invited  { background: #fff8e6; color: #7c5a00; border: 1px solid #ffe58f; }
.pill-failed   { background: #fdecec; color: #a4232c; border: 1px solid #f0b7b7; cursor: help; }

.inv-error {
  font-size: 0.72rem;
  margin: 0.15rem 0 0.4rem 0;
  padding: 0.25rem 0.5rem;
  background: #fdecec;
  border-left: 3px solid #a4232c;
  color: #7a1c25;
  font-family: var(--mono);
  word-break: break-word;
}
