: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);
  --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: 
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

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

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 18px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green), var(--green2));
  box-shadow: 0 4px 12px rgba(44, 208, 86, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Simple circular logo mark */
.brand-mark::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.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-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);
}

.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: linear-gradient(135deg, var(--green), var(--green2));
  box-shadow: 0 8px 24px rgba(44, 208, 86, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}
.login-logo::after {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.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; }
