/* ---------- Settings sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 17, 19, 0.28);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  animation: fade 0.2s ease;
}
.sheet {
  width: min(560px, 100%);
  height: calc(100% - 44px - env(safe-area-inset-top));
  background: #f5f5f7;
  border-radius: 28px 28px 0 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheet-up 0.32s cubic-bezier(0.3, 0.8, 0.25, 1);
}

/* Settings is a destination in the iPhone app, not a translucent preview over the conversation.
   Give both settings levels their own opaque, edge-to-edge surface and account for the safe area. */
html.native #sheet,
html.native #subsheet {
  align-items: stretch;
  background: #f5f5f7;
}
html.native #sheet > .sheet,
html.native #subsheet > .sheet {
  width: 100%;
  height: 100%;
  border-radius: 0;
}
html.native #sheet .sheet-bar,
html.native #subsheet .sheet-bar {
  padding-top: calc(16px + env(safe-area-inset-top));
}
html.native #sheet .sheet-scroll,
html.native #subsheet .sheet-scroll {
  padding-top: calc(84px + env(safe-area-inset-top));
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { height: min(820px, calc(100% - 64px)); border-radius: 28px; }
}

.sheet-bar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: 16px 16px 14px;
  transition: background 0.2s, box-shadow 0.2s;
}
.sheet-bar.solid {
  background: rgba(245, 245, 247, 0.86);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 var(--border);
}
.sheet-back { grid-column: 1; }
.sheet-close { grid-column: 3; }
.sheet-title {
  grid-column: 2;
  text-align: center;
  font-size: 1.0625rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
}
.sheet-bar.solid .sheet-title, .sheet-bar.sub .sheet-title { opacity: 1; }

.sheet-scroll { flex: 1; overflow-y: auto; padding: 84px 16px calc(48px + env(safe-area-inset-bottom)); scrollbar-width: none; }
.sheet-scroll::-webkit-scrollbar { display: none; }
.sheet-page { display: flex; flex-direction: column; gap: 22px; animation: page-in 0.24s ease; }
@keyframes page-in { from { opacity: 0; transform: translateX(12px); } }

.sheet-h1 {
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 2.125rem;
  font-weight: 700;
  letter-spacing: -0.8px;
  padding: 6px 6px 2px;
}

.group {
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 60px;
  padding: 0 20px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1.0625rem;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  position: relative;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: var(--border);
}
.row:hover { background: #fafafa; }
.row > svg { width: 26px; height: 26px; flex: none; }
.row > span:not(.row-avatar) { flex: 1; }
.row::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-3);
  border-top: 2px solid var(--text-3);
  transform: rotate(45deg);
  flex: none;
  margin-right: 4px;
}
.row-danger { color: var(--error); }
.row-danger::after { display: none; }
.row-tall { min-height: 76px; }
.row-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  flex: none;
}
.row-text { display: flex; flex-direction: column; gap: 2px; }
.row-text small { font-size: 0.875rem; color: var(--text-2); }

.group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 22px 0;
  margin-bottom: -12px;
  font-size: 0.9375rem;
  color: var(--text-2);
}
.group-label img { height: 18px; }

.group-note { padding: 0 22px; margin-top: -12px; font-size: 0.875rem; line-height: 1.5; color: var(--text-2); }
.group-note.top { margin-top: 0; }

/* Plan card */
.plan { padding: 22px 22px 6px; }
.plan-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.plan-row + .bar { margin-top: 14px; }
.bar + .plan-row { margin-top: 22px; }
.plan-name { font-size: 1.125rem; font-weight: 500; }
.plan-sub { margin-top: 4px; font-size: 0.9375rem; color: var(--text-2); }
.plan-used { font-size: 0.9375rem; color: var(--text-2); white-space: nowrap; }
.bar { height: 8px; border-radius: 999px; background: #efeff1; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.5s ease; }
.plan-rule { height: 1px; background: var(--border); margin: 20px 0 0; }
.plan-upgrade {
  border: 0;
  background: none;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--accent);
  padding: 16px 0 14px;
  cursor: pointer;
}

/* Field rows inside settings groups */
.fields .frow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 8px 20px;
  font-size: 1.0625rem;
  position: relative;
}
.fields .frow + .frow::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: var(--border);
}
.fields input:not([type="checkbox"]), .fields select {
  flex: 1;
  min-width: 0;
  max-width: 62%;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 1.0625rem;
  text-align: right;
  color: var(--text-2);
  padding: 6px 0;
}
.fields select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  text-align-last: right;
  padding-right: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m8 10 4 4 4-4'/%3E%3C/svg%3E") no-repeat right center / 16px;
}
.fields input:focus, .fields select:focus { color: var(--text); }
.fields input:disabled { -webkit-text-fill-color: var(--text-3); color: var(--text-3); }
.fields .static .muted { font-size: 1rem; }

.switch { position: relative; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i {
  display: block;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #e0e0e4;
  position: relative;
  transition: background 0.2s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s;
}
.switch input:checked + i { background: #34c759; }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.channel-status { font-size: 0.9375rem; color: var(--text-2); }

.delete-form { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.delete-form strong { color: var(--error); font-weight: 600; }
.delete-form p { font-size: 0.9375rem; line-height: 1.5; }
.delete-form .btn { align-self: flex-start; }

/* Wallet + credentials pages */
.vault-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 8px 18px 4px; }
.vault-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 12px rgba(16, 17, 19, 0.06);
}
.vault-icon svg { width: 32px; height: 32px; }
.vault-hero h2 { font-size: 1.25rem; font-weight: 600; }
.vault-hero p { font-size: 0.9375rem; line-height: 1.5; max-width: 380px; }
.empty-row { color: var(--text-3); justify-content: center !important; }
.row-add { color: var(--accent); }
.row-add::after { display: none; }

/* ---------- Stacked sub-page sheet ---------- */

.sub-backdrop { z-index: 31; background: rgba(16, 17, 19, 0.12); }
.sub-backdrop .sheet { box-shadow: 0 -8px 40px rgba(16, 17, 19, 0.12); }
.sheet-bar.sub { grid-template-columns: 48px 1fr 48px; }
.sheet-bar.sub .sheet-back { grid-column: 1; grid-row: 1; }
.sheet-bar.sub .sheet-title { grid-column: 2; grid-row: 1; opacity: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }

/* Slide down + fade when a sheet closes */
.sheet-backdrop.closing { animation: fade-out 0.24s ease forwards; }
.sheet-backdrop.closing .sheet { animation: sheet-down 0.26s cubic-bezier(0.4, 0, 1, 1) forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@media (min-width: 700px) {
  @keyframes sheet-down { to { transform: translateY(40px); opacity: 0; } }
}
