:root {
  --bg0: #f4f4f2;
  --bg1: #ecece9;
  --fg: #1c1c1e;
  --muted: #6e6e73;
  --muted2: #8e8e93;
  --line: rgba(0, 0, 0, 0.08);
  --line2: rgba(0, 0, 0, 0.05);

  --glass: rgba(255, 255, 255, 0.6);
  --glass2: rgba(255, 255, 255, 0.75);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 14px 40px rgba(0, 0, 0, 0.06);

  --green: #2cd056;
  --green2: #34c759;
  --green3: rgba(44, 208, 86, 0.12);
  --imessage-blue: #0A84FF;
  --keyboard-offset: 0px;
  --radius: 22px;
  --radius-sm: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg0);
  background-image: 
    linear-gradient(180deg, var(--bg0), var(--bg1)),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(36px + var(--keyboard-offset));
  position: relative;
  z-index: 10;
}
body {
  scroll-padding-bottom: calc(24px + var(--keyboard-offset));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}

.tabs{
  display:flex;
  gap:4px;
  margin: 4px 0 14px;
  background: rgba(118, 118, 128, 0.12);
  padding: 4px;
  border-radius: 12px;
  justify-content: center;
}
.tab{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-align:center;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.tab-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  opacity: 0.7;
  transform: scale(0.9);
}
.tab.is-active{
  background: #ffffff;
  color: var(--fg);
  border-color: transparent;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 3px 1px rgba(0,0,0,0.04);
}
.tab.is-active .tab-icon{ opacity: 1; }

.scroll-x {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding: 4px 16px 20px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
}
.scroll-x > * {
  flex: 0 0 85%;
  scroll-snap-align: center;
  min-width: 260px;
  max-width: 400px;
}
/* Hide scrollbar */
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x { -ms-overflow-style: none; scrollbar-width: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #ff5c8a;
  box-shadow: 0 4px 12px rgba(255, 92, 138, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.brand-mark:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(255, 92, 138, 0.4);
}

/* The first Edda logo is intentionally just a solid pink tile. */
.brand-mark::after {
  content: none;
}

.brand-title {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 17px;
}

.brand-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 4px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; }

.h1 {
  font-size: 28px;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.h2 {
  font-size: 17px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
  font-weight: 600;
}
.p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 15px;
}
.tiny { font-size: 13px; color: var(--muted2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.surface {
  position: relative;
  border-radius: var(--radius);
  background: var(--glass2);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
}

.card { padding: 18px; }
.card-lg { padding: 24px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 13px; color: var(--muted); font-weight: 500; }

.input {
  width: 100%;
  border-radius: 14px;
  padding: 14px 14px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #ffffff;
  color: var(--fg);
  font-size: 16px;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.input::placeholder { color: var(--muted2); }
.input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green3);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  color: var(--fg);
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #fcfcfc; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.06); }
.btn:active { transform: translateY(0px); background: #f2f2f2; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--fg); box-shadow: none; }

.btn-green {
  background: transparent;
  color: var(--green2);
  border: 1px solid var(--green2);
  box-shadow: none;
}
.btn-green:hover {
  background: var(--green3);
  box-shadow: 0 2px 8px rgba(44, 208, 86, 0.15);
  color: var(--green);
  border-color: var(--green);
}
.btn-green.is-on {
  /* This style is for the static 'Active' state button if visible, 
     but we removed it. If reused elsewhere, keep it solid. */
  background: var(--green2); 
  color: #ffffff;
  border-color: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.04);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #d1d1d6;
}
.dot.on {
  background: var(--green2);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.8);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #e5e5ea;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 11px;
}
.avatar.is-green {
  border-color: var(--green2);
  border-width: 2px;
  color: var(--green);
  background: #e6faee;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--green3);
}
.avatar-more {
  background: #f2f2f7;
  color: var(--muted2);
}
.avatar-stack {
  display: flex;
  align-items: center;
}
.avatar-stack .avatar {
  margin-left: -8px;
  border: 2px solid var(--bg0);
}
.avatar-stack .avatar:first-child {
  margin-left: 0;
}
.avatar-img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 999px;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.list-link { display: block; }

.code-pill {
  padding: 10px 14px;
  border-radius: 12px;
  background: #f2f2f7;
  color: var(--fg);
  font-size: 15px;
  letter-spacing: 0.05em;
  border: 1px solid rgba(0,0,0,0.04);
}

/* Login Page Specifics */
.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: #ff5c8a;
  box-shadow: 0 8px 24px rgba(255, 92, 138, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}
.login-logo::after {
  content: none;
}

.btn-provider{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  text-align:center;
}
.btn-provider svg{
  width:18px;
  height:18px;
  flex:0 0 auto;
}

/* Brand buttons */
.btn-provider.is-disabled{
  opacity:0.45;
  pointer-events:none;
  filter:grayscale(0.2);
}

.btn-local{
  background:var(--green2);
  color:#071b0c;
  border-color:rgba(31,170,67,0.9);
}
.btn-local:hover{ background:var(--green); }

.btn-apple{
  background:#000;
  color:#fff;
  border-color:rgba(0,0,0,0.85);
}
.btn-apple:hover{ background:#111; }

.btn-discord{
  background:#5865F2;
  color:#fff;
  border-color:rgba(88,101,242,0.9);
}
.btn-discord:hover{ background:#4f5be0; }

.btn-google{
  background:#4285F4; /* Google blue */
  color:#fff;
  border-color:rgba(66,133,244,0.95);
}
.btn-google:hover{ background:#3367D6; }

.btn-strava{
  background:#FC4C02;
  color:#fff;
  border-color:rgba(252,76,2,0.95);
}
.btn-strava:hover{ background:#e34402; }

.local-auth-card .field { width: 100%; }

.notice-banner {
  padding: 12px 14px;
  border: 1px solid rgba(31, 170, 67, 0.28);
  border-radius: 14px;
  background: var(--green3);
}

.recovery-code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.recovery-code {
  display: block;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
  text-align: center;
  user-select: all;
}

@media (max-width: 520px) {
  .recovery-code-grid { grid-template-columns: 1fr; }
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  color: var(--muted);
}
.btn-icon:hover { background: #fff; color: var(--fg); }

.invite-tooltip {
  position: absolute;
  top: 40px;
  right: 0;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.05);
  width: 200px;
  z-index: 10;
  display: none;
}
.invite-area:hover .invite-tooltip { display: block; }


@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

/* Pull to Refresh */
.pull-refresh-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    z-index: 2000;
    pointer-events: none;
}

.refresh-icon {
    color: var(--green);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.refresh-icon.spinning {
    animation: spin 0.8s linear infinite;
}

@keyframes spin { 
    to { transform: rotate(360deg); } 
}
.pull-refresh-loader { opacity: 0; }

/* Offline Banner */
.offline-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    transform: translateY(150%);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.offline-banner.visible {
    transform: translateY(0);
}

/* Notification Banner */
.notification-banner {
    background: var(--green);
    color: white;
    text-align: center;
    padding: 12px;
    font-weight: 500;
    cursor: pointer;
    margin: -18px -18px 18px; /* Offset .app padding */
    border-radius: 0 0 16px 16px;
    box-shadow: 0 4px 12px rgba(44, 208, 86, 0.3);
}
.notification-banner.hidden {
    display: none;
}

/* Group card collapse */
.group-card {
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease;
  will-change: transform, box-shadow;
  overflow: visible;
}
.group-card[open] {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
}
.group-card summary {
  list-style: none;
  cursor: pointer;
}
.group-card summary::-webkit-details-marker {
  display: none;
}
.group-card:not([open]) .group-card-actions {
  display: none;
}
details.group-card > *:not(summary) {
  display: block;
}
.group-card-summary {
  display: block;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.group-card-body {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.6s cubic-bezier(0.25, 0.9, 0.3, 1), background-color 0.25s ease;
  will-change: grid-template-rows;
}
.group-card:not([open]) .group-card-body {
  pointer-events: none;
}
.group-card-body-inner {
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  margin-top: 0;
  transition: opacity 0.4s ease, transform 0.4s ease, margin 0.35s ease;
  will-change: opacity, transform, margin;
}
.group-card[open] .group-card-body {
  grid-template-rows: 1fr;
}
.group-card[open] .group-card-body-inner {
  opacity: 1;
  transform: translateY(0);
  margin-top: 16px;
}
.group-card[open] .group-card-summary {
  transform: translateY(-2px);
}
.shake-anim {
  animation: card-shake 0.6s ease-in-out;
}
@keyframes card-shake {
  0% { transform: translateX(0); }
  15% { transform: translateX(12px); }
  30% { transform: translateX(-12px); }
  45% { transform: translateX(10px); }
  60% { transform: translateX(-10px); }
  75% { transform: translateX(6px); }
  90% { transform: translateX(-6px); }
  100% { transform: translateX(0); }
}
.nudge-inline {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.nudge-btn-small {
  padding: 8px 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
}
.nudge-menu {
  position: relative;
}
.nudge-menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #0f1412;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  z-index: 20;
  min-width: 180px;
}
.nudge-menu-panel.open {
  display: block;
}
.green-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--green2);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(44, 208, 86, 0.28);
}

@media (prefers-reduced-motion: reduce) {
  .group-card, .group-card-summary { transition: none; }
  .group-card-body { transition: none; }
  .group-card-body-inner { transition: none; }
}
@media (max-width: 360px) { .brand-title { display: none; } }
@media (max-width: 480px) { .chip-text { display: none; } .chip { padding: 0 !important; background: transparent !important; box-shadow: none !important; } }

/* Wave Loader */
.wave-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  position: absolute; /* Overlay or position it where needed */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.htmx-request .wave-loader {
  opacity: 1;
}
/* If using htmx-indicator class explicitly */
.htmx-indicator.wave-loader {
    opacity: 0;
}
.htmx-request .htmx-indicator.wave-loader, .htmx-request.htmx-indicator.wave-loader {
    opacity: 1; 
}

.wave-bar {
  width: 4px;
  height: 12px;
  background: var(--muted2);
  border-radius: 99px;
  animation: wave 1.2s ease-in-out infinite;
}
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 12px; opacity: 0.5; }
  50% { height: 24px; opacity: 1; }
}

/* Suggestion Box */
.suggestion-box {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
