/* css/app.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --green: #22c55e;
  --green-glow: rgba(34,197,94,0.4);
  --my-status: #22c55e;
  --my-glow:   rgba(34, 197, 94, 0.4);
  --dot-off: #6b7280;
  --dot-off-border: #9ca3af;
  --accent: #6366f1;
  --error-bg: #7f1d1d;
  --error-text: #fca5a5;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; user-select: none; -webkit-user-select: none; overscroll-behavior-y: none; }

#splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text);
  font-size: 1.25rem;
  transition: opacity 0.5s;
}
#splash.fading { opacity: 0; pointer-events: none; }

.code-input, .text-input, .rename-input { user-select: text; -webkit-user-select: text; }

/* Layout */
main {
  padding: 1rem;
}

/* Dot */
.dot {
  width: 3rem; height: 3rem; border-radius: 50%;
  background: var(--dot-off); border: none;
  cursor: pointer; transition: background 0.3s, box-shadow 0.3s;
  flex-shrink: 0;
}
.dot.available {
  background: var(--my-status);
  border-color: var(--my-status);
  box-shadow: 0 0 32px var(--my-glow);
}
.status-label { font-size: 1rem; font-weight: 600; color: var(--text-muted); transition: opacity 0.2s ease, color 0.3s ease; }
.status-label.available { color: var(--my-status); }

@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 1.5px rgba(var(--call-color-rgb), 0.3), 0 0 14px rgba(var(--call-color-rgb), 0.15); }
  50%       { box-shadow: 0 0 0 1.5px rgba(var(--call-color-rgb), 1.0), 0 0 24px rgba(var(--call-color-rgb), 0.65); }
}
.call-mode { position: relative; }
.call-mode::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; animation: call-pulse 3s ease-in-out infinite;
}

/* Long-press palette adoption indicator */
.adopted-from {}

/* ── Favorites strip ─────────────────────────────────────────────── */
#favorites-strip {
  display: none; /* shown by JS when favorites exist */
}

.fav-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: #ffffff;
  /* background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='20'%3E%3Crect width='40' height='20' fill='%23fff'/%3E%3Cg fill='none' stroke='%236366f1' stroke-width='0.6' opacity='0.35'%3E%3Cpath d='M0 2Q10-1 20 2T40 2'/%3E%3Cpath d='M0 4.5Q10 1.5 20 4.5T40 4.5'/%3E%3Cpath d='M0 7Q10 4 20 7T40 7'/%3E%3Cpath d='M0 9.5Q10 6.5 20 9.5T40 9.5'/%3E%3Cpath d='M0 12Q10 9 20 12T40 12'/%3E%3Cpath d='M0 14.5Q10 11.5 20 14.5T40 14.5'/%3E%3Cpath d='M0 17Q10 14 20 17T40 17'/%3E%3Cpath d='M0 19.5Q10 16.5 20 19.5T40 19.5'/%3E%3C/g%3E%3Cg fill='none' stroke='%236366f1' stroke-width='0.5' opacity='0.25'%3E%3Cpath d='M0 1Q10 4 20 1T40 1'/%3E%3Cpath d='M0 3.5Q10 6.5 20 3.5T40 3.5'/%3E%3Cpath d='M0 6Q10 9 20 6T40 6'/%3E%3Cpath d='M0 8.5Q10 11.5 20 8.5T40 8.5'/%3E%3Cpath d='M0 11Q10 14 20 11T40 11'/%3E%3Cpath d='M0 13.5Q10 16.5 20 13.5T40 13.5'/%3E%3Cpath d='M0 16Q10 19 20 16T40 16'/%3E%3Cpath d='M0 18.5Q10 21.5 20 18.5T40 18.5'/%3E%3C/g%3E%3C/svg%3E") repeat; */
  border-bottom: 1px solid #334155;
}
.fav-strip::-webkit-scrollbar { display: none; }

.fav-pill {
  display: flex;
  height: 22px;
  min-width: 20px;
  border-radius: 11px;
  overflow: hidden;
  flex: 0 0 auto;
  cursor: pointer;
  transition: width 0.15s ease-out;
}
.fav-pill--inactive { opacity: 0.45; cursor: default; }
.fav-pill--active   { opacity: 1; }
.fav-pill--history  { opacity: 1; }

.fav-pill-left,
.fav-pill-right { flex: 1; }

.fav-collapse-btn {
  background: none;
  border: none;
  color: #475569;
  font-size: 10px;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.fav-collapsed {
  width: 100%;
  cursor: pointer;
  padding-bottom: 48px;
  margin-bottom: -44px;
}
.fav-collapsed-line {
  height: 3px;
  width: 100%;
}

/* Following tab */
.person-list { list-style: none; width: 100%; }
.person-list li {
  background: var(--surface); border-radius: 10px; padding: 0.75rem 0.875rem;
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.5rem; list-style: none;
  border-left: 3px solid transparent;
  touch-action: pan-y;
}
.person-dot {
  width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
  background: var(--dot-off); border: none;
}
.person-dot.available { background: var(--green); border-color: var(--green); box-shadow: 0 0 10px var(--green-glow); }
.person-info { flex: 1; }
.person-label { font-size: 1rem; line-height: 1.4; height: 1.4rem; color: var(--text); cursor: pointer; width: fit-content; }
.person-status { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.remove-btn {
  background: var(--error-bg); color: var(--error-text); border: none;
  padding: 5px 10px; border-radius: 6px; font-size: 11px; cursor: pointer;
}

/* Add person area */
#add-person-area {
  background: var(--surface2);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.25rem;
}
#add-person-area.has-list {
  margin-top: 0.5rem;
}

/* Add person drawer */
#add-person-form {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
#add-person-form.open {
  max-height: 22rem;
}

/* Offline banner */
.offline-banner {
  background: var(--surface2); color: var(--text-muted); font-size: 12px;
  text-align: center; padding: 6px; border-radius: 6px; width: 100%; margin-bottom: 4px;
}

/* Add person form */
.add-btn {
  width: 100%; background: transparent; color: var(--text);
  border: none; padding: 0.625rem 0.875rem;
  font-size: 0.8125rem; cursor: pointer; text-align: left;
}
.add-form { width: 100%; display: flex; flex-direction: column; gap: 10px; padding: 0 0.875rem 0.875rem; }
.field-label { font-size: 11px; letter-spacing: 1px; color: var(--text-muted); text-transform: uppercase; }
.code-input, .text-input {
  background: var(--surface); color: var(--text); border: 1px solid var(--surface2);
  border-radius: 8px; padding: 12px; font-size: 16px; width: 100%; outline: none;
}
.code-input { text-align: center; letter-spacing: 4px; text-transform: uppercase; }
.code-input:focus, .text-input:focus { border-color: var(--accent); }
.primary-btn {
  background: var(--accent); color: white; border: none; padding: 13px;
  border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ghost-btn {
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--surface2);
  padding: 10px; border-radius: 10px; font-size: 13px; cursor: pointer;
}
.error-msg {
  background: var(--error-bg); color: var(--error-text); font-size: 13px;
  padding: 10px 12px; border-radius: 8px;
}

/* Code drawer inner content */
.drawer-inner {
  background: var(--surface2);
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
}
.code-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}
.code-display { font-size: 1.5rem; font-weight: 700; letter-spacing: 0.375rem; color: var(--text); transition: opacity 0.5s; }
.code-display.fading { opacity: 0; }
.rotate-btn {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted); padding: 4px;
  transition: color 0.15s;
}
.rotate-btn:hover:not(:disabled) { color: var(--text); }
.rotate-btn:disabled { opacity: 0.4; cursor: default; }
#copy-code-btn { min-width: 5rem; text-align: center; margin-left: auto; }
.hint { font-size: 12px; color: var(--text-muted); }
.new-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05rem;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
  margin-left: 0.375rem;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.person-follower-name { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }

/* Utilities */
.hidden { display: none !important; }
.rename-input {
  display: block;
  font: inherit;
  font-size: 1rem; /* prevent iOS Safari zoom (triggers when font-size < 16px) */
  line-height: 1.4;
  height: 100%; /* fill .person-label's locked 1.4rem height */
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

/* Unfollow button (icon-only × on followee rows) */
.unfollow-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-start;
  transition: color 0.15s;
}
.unfollow-btn:hover { color: var(--error-text); }

/* Status text: available portion */
.status-available { color: var(--green); font-weight: 500; }

/* Confirm overlay (unfollow sheet) */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding-bottom: 2rem;
}
.confirm-sheet {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.25rem;
  width: calc(100% - 2rem);
  max-width: 380px;
  text-align: center;
}
.confirm-sheet h4 { font-size: 1rem; margin-bottom: 0.35rem; }
.confirm-sheet p  { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 1rem; }
.confirm-btns { display: flex; gap: 0.6rem; }
.confirm-btns button {
  flex: 1;
  padding: 0.65rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.confirm-btn-cancel { background: var(--surface2); color: var(--text-muted); }
.confirm-btn-remove { background: var(--error-bg); color: var(--error-text); }
.confirm-btn-generate { background: var(--accent); color: white; }

/* Stale identity recovery screen */
.stale-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 2rem;
}
.stale-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 2rem 1.5rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.stale-msg {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* App header */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  padding: 1rem;
  border-bottom: 1px solid var(--surface2);
}

#header-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

#header-text {
  flex: 1;
  display: grid;
}

#header-status-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 1rem;
  grid-row: 1;
}

#time-remaining {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: opacity 0.25s ease;
}

/* Chips */
#header-chips {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  grid-row: 2;
  grid-column: 1;
  align-self: start;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.25rem 0.875rem;
  font-size: 0.8125rem;
  cursor: pointer;
}
.chip.active {
  border-color: var(--accent);
  color: var(--accent);
}
.time-chip {
  min-width: 9.25rem;
  text-align: center;
}
.time-chip:active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Code drawer */
#code-drawer {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, margin-top 0.3s ease;
  margin-top: 0;
}
#code-drawer.open {
  max-height: 12.5rem;
  margin-top: 0.75rem;
}

/* List section labels */
.person-list .list-section-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  color: var(--text-muted);
  padding: 0.25rem 0 0.25rem;
  list-style: none;
  background: transparent;
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none;
}

/* Follower-only row */
.person-list li.follower-only {
  opacity: 0.6;
}

/* Follow-back button */
.follow-back-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

/* --- Swatch row --- */

#swatch-row {
  display: flex;
  gap: 6px;
  margin-top: 0.5rem;
  grid-row: 2;
  grid-column: 1;
  align-self: start;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#swatch-row.visible {
  opacity: 1;
  pointer-events: auto;
}
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.swatch.selected {
  border-color: rgba(255, 255, 255, 0.9);
  border-width: 3px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.set-toggle-btn {
  width: 22px; height: 22px; background: none; border: none;
  cursor: pointer; color: var(--text-muted); padding: 0;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 5px; transition: color 0.15s, background 0.15s;
  margin-right: 0.4em;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
@media (hover: hover) {
  .set-toggle-btn:hover { color: var(--text); background: rgba(255,255,255,0.07); }
}
.set-toggle-btn svg { width: 22px; height: 22px; }
.swatch.key-swatch {
  border-color: transparent;
  position: relative;
}
.swatch.key-swatch.selected {
  border-color: rgba(255, 255, 255, 0.9);
}
.swatch.key-swatch::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 1.5px dashed rgba(255,255,255,0.65);
  animation: key-spin 5s ease-out 1 forwards; pointer-events: none;
}
@keyframes key-spin { from { transform: rotate(0deg); } to { transform: rotate(720deg); } }

/* Knock animations */
@keyframes knock-deferred {
  0%   { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--knock-color) 55%, transparent); }
  20%  { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--knock-color) 27%, transparent); }
  40%  { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--knock-color) 55%, transparent); }
  60%  { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--knock-color) 27%, transparent); }
  80%  { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--knock-color) 55%, transparent); }
  100% { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--knock-color) 0%,  transparent); }
}
@keyframes knock-sender {
  0%   { background-color: var(--knock-color); }
  100% { background-color: transparent; }
}
.knock-deferred { animation: knock-deferred 5s ease-in-out; }
.knock-sender   { animation: knock-sender   0.2s ease-out; }
