/* ============================================================
   Ippa — grayscale, mobile-native, Snapchat-ish.
   Light by default, dark via prefers-color-scheme.
   ============================================================ */

:root {
  --bg:        #ffffff;
  --bg-soft:   #f2f2f7;
  --bg-soft-2: #e9e9ee;
  --line:      #e5e5ea;
  --line-2:    #d1d1d6;
  --text:      #000000;
  --text-2:    #3c3c43;
  --text-3:    #86868b;
  --text-4:    #aeaeb2;
  --accent:    #000000;
  --accent-fg: #ffffff;
  --danger:    #1d1d1f;
  --shadow:    0 10px 40px rgba(0,0,0,0.15);
  --radius:    16px;
  --radius-lg: 22px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap:       0.12s cubic-bezier(.4,0,.2,1);
  --sheet:     0.35s cubic-bezier(.32,.72,0,1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #000000;
    --bg-soft:   #1c1c1e;
    --bg-soft-2: #2c2c2e;
    --line:      #2c2c2e;
    --line-2:    #38383a;
    --text:      #ffffff;
    --text-2:    #ebebf5;
    --text-3:    #98989f;
    --text-4:    #636366;
    --accent:    #ffffff;
    --accent-fg: #000000;
    --danger:    #ffffff;
    --shadow:    0 10px 40px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  user-select: none;
}
input, textarea { user-select: text; }
button { font: inherit; cursor: pointer; color: inherit; border: none; background: none; padding: 0; }
input, textarea {
  font: inherit; color: var(--text);
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 16px;
  width: 100%;
  outline: none;
  transition: border-color var(--tap), background var(--tap);
}
input:focus, textarea:focus { border-color: var(--line-2); background: var(--bg); }
textarea { resize: none; font-family: inherit; }

.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
}

/* ---------------- Auth ---------------- */
#auth { justify-content: center; align-items: center; padding: 32px; }
.auth-inner {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 16px;
  align-items: stretch;
}
.wordmark {
  font-size: 56px; font-weight: 900; letter-spacing: -0.04em;
  text-align: center; margin-bottom: 8px;
}
#auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-error { color: var(--text-3); text-align: center; font-size: 14px; min-height: 1.2em; }

/* ---------------- Buttons ---------------- */
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  padding: 16px;
  border-radius: 14px;
  width: 100%;
  transition: transform var(--tap), opacity var(--tap);
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.35; }
.btn-pill { border-radius: 999px; }
.btn-text {
  color: var(--text-2);
  font-weight: 500;
  padding: 10px;
  font-size: 15px;
}
.btn-text:active { opacity: 0.5; }

.iconbtn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  border-radius: 50%;
  position: relative;
  transition: background var(--tap);
}
.iconbtn:active { background: var(--bg-soft); }

.badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* ---------------- Avatar ---------------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-soft-2);
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  font-size: 16px;
  text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 48px; height: 48px; font-size: 18px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; }

.avatar-edit { position: relative; display: inline-block; }
.avatar-edit-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 10px; text-align: center;
  padding: 4px 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------------- App bar ---------------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
  border-bottom: 0.5px solid var(--line);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.appbar-title {
  font-weight: 700; font-size: 17px; letter-spacing: -0.02em;
  text-transform: lowercase;
}
.appbar-right { display: flex; gap: 2px; }

/* ---------------- Friend list ---------------- */
.list { display: flex; flex-direction: column; padding: 0; }
.list.compact { gap: 0; padding-top: 8px; }

.row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--line);
  transition: background var(--tap);
}
.row.tappable { cursor: pointer; }
.row.tappable:active { background: var(--bg-soft); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; font-size: 16px; }
.row-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.row-actions { display: flex; gap: 8px; }
.row-actions button { font-size: 14px; padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.row-actions .accept { background: var(--accent); color: var(--accent-fg); }
.row-actions .decline { background: var(--bg-soft); color: var(--text-2); }
.row-actions .accept:active, .row-actions .decline:active { transform: scale(0.95); }

.row-note {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-2);
  width: 100%;
}

.stars-inline {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text-3);
}
.stars-inline::before {
  content: "★"; color: var(--text); font-size: 12px;
}

.tag {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------------- Empty state ---------------- */
.empty {
  flex: 1;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  padding: 32px;
  color: var(--text-3);
}
.empty-title { font-size: 18px; font-weight: 600; color: var(--text-2); }

/* ---------------- Backdrop & sheets ---------------- */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0);
  pointer-events: none;
  transition: background 0.25s ease;
  z-index: 50;
}
.backdrop.open { background: rgba(0,0,0,0.4); pointer-events: auto; }
@media (prefers-color-scheme: dark) {
  .backdrop.open { background: rgba(0,0,0,0.6); }
}

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding-bottom: calc(var(--safe-bottom) + 16px);
  transform: translateY(100%);
  transition: transform var(--sheet);
  z-index: 60;
  box-shadow: var(--shadow);
  max-height: calc(100dvh - 56px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sheet.open { transform: none; }
.sheet-tall { max-height: calc(100dvh - 20px); }
.sheet-handle {
  width: 36px; height: 5px;
  background: var(--line-2);
  border-radius: 3px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 4px;
  flex-shrink: 0;
}
.sheet-title { font-weight: 700; font-size: 17px; }
.sheet-close { padding: 8px 12px; }
.sheet-body {
  padding: 12px 20px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------------- Profile sheet ---------------- */
.profile-head {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 8px 0 16px;
}
.profile-name { font-size: 22px; font-weight: 700; }
.profile-rating { color: var(--text-3); font-size: 14px; }

.profile-list {
  display: flex; flex-direction: column;
  background: var(--bg-soft);
  border-radius: 14px;
  overflow: hidden;
}
.profile-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text);
  width: 100%;
  text-align: left;
  border-bottom: 0.5px solid var(--line);
  background: var(--bg-soft);
}
.profile-row:last-child { border-bottom: none; }
.profile-row.tappable { cursor: pointer; transition: background var(--tap); }
.profile-row.tappable:active { background: var(--bg-soft-2); }
.profile-row-val { color: var(--text-3); font-size: 14px; }
.profile-row.danger { color: var(--text-2); }

/* ---------------- Send ippa sheet ---------------- */
.send-head { display: flex; align-items: center; gap: 14px; padding: 8px 4px; }
.send-head.center { flex-direction: column; align-items: center; gap: 10px; }
.send-to { font-weight: 700; font-size: 20px; }
.send-sub { font-size: 13px; color: var(--text-3); }

.choice-row { display: flex; gap: 10px; }
.choice {
  flex: 1;
  background: var(--bg-soft);
  border: 2px solid transparent;
  padding: 18px 14px;
  border-radius: 16px;
  text-align: center;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform var(--tap), border-color var(--tap), background var(--tap);
}
.choice:active { transform: scale(0.97); }
.choice.selected {
  border-color: var(--accent);
  background: var(--bg);
}
.choice-title { font-weight: 700; font-size: 18px; }
.choice-sub { font-size: 12px; color: var(--text-3); }

/* ---------------- Review sheet ---------------- */
.review-title { font-size: 20px; font-weight: 700; text-align: center; }
.stars-picker {
  display: flex; gap: 6px; justify-content: center;
  padding: 12px 0;
}
.stars-picker button {
  font-size: 44px;
  color: var(--line-2);
  padding: 4px 6px;
  transition: color var(--tap), transform var(--tap);
}
.stars-picker button:active { transform: scale(0.85); }
.stars-picker button.lit { color: var(--accent); }

/* ---------------- Activity sheet ---------------- */
.section-label {
  font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 4px 4px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 20px);
  bottom: calc(var(--safe-bottom) + 24px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Misc ---------------- */
.input-soft {
  background: var(--bg-soft);
  border-radius: 12px;
}
