/* Idea Box — chassis styles.
   Brand tokens are rewritten by `appfactory new`; everything else is structure. */

/* >>> tokens */
:root {
  --bg: #1A1F2E;
  --surface: #232838;
  --surface-2: #2a3144;
  --text: #f2f2f7;
  --dim: #9a9aa8;
  --accent: #FF6B4A;
  --accent-glow: rgba(255, 107, 74, 0.35);
  --radius: 16px;
  --pad: 16px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* <<< tokens */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 107, 74, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(100, 120, 200, 0.08), transparent);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#appBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pad);
  padding: var(--pad);
  flex: 0 0 auto;
}

#appTitle {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 60%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.screen { flex: 1 1 auto; overflow-y: auto; padding: 0 var(--pad) var(--pad); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--pad);
}
.card h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.card p { margin: 0 0 .75rem; }
.dim { color: var(--dim); }
code { background: rgba(255,255,255,.07); padding: .1em .4em; border-radius: 6px; font-size: .9em; }

.icon-btn {
  appearance: none;
  border: 0;
  background: rgba(255,255,255,.06);
  color: inherit;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  line-height: 0;
  transition: background 0.2s var(--ease-out), transform 0.15s var(--ease-out);
}
.icon-btn:active { background: rgba(255,255,255,.12); transform: scale(0.94); }

/* --- sheets --------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  z-index: 40;
  animation: fadeIn 0.25s var(--ease-out);
}
.sheet-backdrop[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  background: var(--surface);
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  max-height: 85%;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-out);
  border-top: 1px solid rgba(255,255,255,.08);
}
.sheet.is-open,
.sheet-backdrop:not([hidden]) .sheet {
  transform: translateY(0);
}

.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.sheet-foot { margin-top: var(--pad); display: flex; gap: .5rem; align-items: center; font-size: .85rem; }
.sheet-foot a { color: var(--dim); transition: color 0.2s; }
.sheet-foot a:hover { color: var(--text); }
#appVersion { margin-left: auto; font-variant-numeric: tabular-nums; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.row:last-of-type { border-bottom: 0; }

/* --- floating pills ------------------------------------------------------- */
.pill {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  animation: pillIn 0.4s var(--ease-spring);
}
.pill[hidden] { display: none; }

@keyframes pillIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.update-toast { bottom: calc(18px + env(safe-area-inset-bottom)); background: var(--accent); color: #fff; }
.install-hint { bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--text); }

#toast, #syncStatus {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(12px + env(safe-area-inset-top));
  background: rgba(0,0,0,.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .9rem;
  z-index: 70;
  pointer-events: none;
  animation: toastIn 0.3s var(--ease-spring);
}
#toast[hidden], #syncStatus[hidden] { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Idea Box app --------------------------------------------------------- */

.tagline { margin: 0 0 14px; font-size: .95rem; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,.1);
  color: var(--text);
  transition: transform 0.15s var(--ease-out), opacity 0.15s, background 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.96); opacity: .9; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 8px 14px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-quiet { background: rgba(255,255,255,.08); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 16px var(--accent-glow); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: #c0392b; color: #fff; }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: var(--dim);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
}
.chip:active { transform: scale(0.95); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.featured-band {
  background: linear-gradient(135deg, rgba(255,107,74,.22), rgba(255,107,74,.06));
  border: 1px solid rgba(255,107,74,.3);
  border-radius: var(--radius);
  padding: 16px var(--pad);
  margin-bottom: 14px;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
  animation: cardIn 0.4s var(--ease-out);
}
.featured-band:active { transform: scale(0.98); }
.featured-band:hover { box-shadow: 0 4px 20px rgba(255,107,74,.15); }
.featured-band h3 { margin: 0 0 4px; font-size: 1.02rem; }
.featured-band p { margin: 0; font-size: .9rem; color: var(--dim); }
.featured-label {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.idea-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 90px; }

.idea-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.06);
  transition: transform 0.2s var(--ease-out), border-color 0.2s, box-shadow 0.2s;
  animation: cardIn 0.45s var(--ease-out) both;
  animation-delay: var(--stagger, 0ms);
}
.idea-card:active { transform: scale(0.98); background: var(--surface-2); }
.idea-card:hover { border-color: rgba(255,255,255,.1); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.vote-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--dim);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
}
.vote-btn:active { transform: scale(0.9); }
.vote-btn.is-voted {
  background: rgba(255,107,74,.2);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.vote-btn.vote-pop {
  animation: votePop 0.3s var(--ease-spring);
}

@keyframes votePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.vote-count { font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.idea-main h3 { margin: 0 0 4px; font-size: 1rem; line-height: 1.35; font-weight: 650; }
.idea-excerpt { margin: 0 0 8px; font-size: .9rem; color: var(--dim); line-height: 1.45; }
.idea-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: .78rem;
  color: var(--dim);
}
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  font-weight: 600;
  font-size: .75rem;
}
.status-pill.is-building { background: rgba(255,107,74,.2); color: var(--accent); }
.status-pill.is-built { background: rgba(80,200,120,.15); color: #6dd99a; }
.pin-mark { color: var(--accent); font-weight: 700; }

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--dim);
  animation: cardIn 0.5s var(--ease-out);
}
.empty p { margin: 0 0 16px; }

/* --- tab bar with center FAB ---------------------------------------------- */

#tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  background: rgba(26, 31, 46, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 4px 12px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
#tabbar[hidden] { display: none; }

.tab {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  font: inherit;
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 12px;
  transition: color 0.2s, transform 0.15s var(--ease-out);
}
.tab:active:not(.tab-fab) { transform: scale(0.92); }
.tab.is-active { color: var(--accent); }

.tab-fab {
  position: relative;
  margin-top: -22px;
  color: #fff;
}
.tab-fab .tab-label { color: var(--accent); font-weight: 600; }

.fab-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff8866);
  box-shadow: 0 4px 20px var(--accent-glow), 0 0 0 4px rgba(26, 31, 46, 0.95);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}
.tab-fab:active .fab-ring {
  transform: scale(0.92);
  box-shadow: 0 2px 12px var(--accent-glow), 0 0 0 4px rgba(26, 31, 46, 0.95);
}
.tab-fab:hover .fab-ring {
  box-shadow: 0 6px 28px var(--accent-glow), 0 0 0 4px rgba(26, 31, 46, 0.95);
}

.tab-label { line-height: 1; }

/* --- admin screen --------------------------------------------------------- */

.admin-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.admin-head h2 { margin: 0; font-size: 1.1rem; }

.admin-settings { margin-top: 8px; }
.admin-open-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: .85rem; color: var(--dim); margin-bottom: 6px; }
.text-input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.25);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.idea-input { min-height: 100px; }

.sheet-hint { margin: 0 0 12px; font-size: .9rem; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.sheet-tall { max-height: 92%; }
.sheet-voice { max-height: 88%; }

/* --- voice-first submit --------------------------------------------------- */

.voice-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 16px;
  gap: 16px;
}

.voice-mic {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  width: 120px;
  height: 120px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

.voice-mic-icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff8866);
  color: #fff;
  box-shadow: 0 8px 32px var(--accent-glow);
  transition: transform 0.2s var(--ease-spring);
}

.voice-mic-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  transform: scale(0.8);
}
.voice-mic-ring--2 { animation-delay: 0.6s; }

.voice-mic.is-listening .voice-mic-icon {
  transform: scale(1.08);
  box-shadow: 0 8px 40px rgba(255, 107, 74, 0.5);
}

.voice-mic.is-listening .voice-mic-ring {
  animation: micPulse 1.8s var(--ease-out) infinite;
}

@keyframes micPulse {
  0% { opacity: 0.6; transform: scale(0.85); }
  100% { opacity: 0; transform: scale(1.4); }
}

.voice-mic:active .voice-mic-icon { transform: scale(0.95); }
.voice-mic:disabled { opacity: 0.4; cursor: not-allowed; }
.voice-mic:disabled .voice-mic-icon { background: rgba(255,255,255,.15); box-shadow: none; }

.voice-status {
  font-size: .92rem;
  color: var(--dim);
  text-align: center;
  min-height: 1.4em;
  max-width: 280px;
  line-height: 1.4;
  transition: color 0.2s;
}
.voice-mic.is-listening ~ .voice-status,
.voice-hero:has(.voice-mic.is-listening) .voice-status {
  color: var(--accent);
}

.type-fallback {
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
  padding-top: 12px;
}
.type-fallback summary {
  cursor: pointer;
  font-size: .88rem;
  color: var(--dim);
  padding: 6px 0;
  list-style: none;
  transition: color 0.2s;
}
.type-fallback summary::-webkit-details-marker { display: none; }
.type-fallback summary::before { content: '▸ '; }
.type-fallback[open] summary::before { content: '▾ '; }
.type-fallback summary:hover { color: var(--text); }
.type-fallback .field { margin-top: 10px; margin-bottom: 0; }

.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-size: .85rem; color: var(--dim); }
.detail-body {
  white-space: pre-wrap;
  line-height: 1.55;
  margin-bottom: 16px;
  padding: 14px;
  background: rgba(0,0,0,.2);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
}

.prompt-card {
  background: rgba(255,107,74,.1);
  border: 1px solid rgba(255,107,74,.25);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  animation: cardIn 0.35s var(--ease-out);
}
.prompt-card h4 { margin: 0 0 6px; font-size: .95rem; }
.prompt-card p { margin: 0 0 10px; font-size: .85rem; color: var(--dim); }

.admin-panel {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(255,255,255,.03);
}
.admin-panel h3 { margin: 0 0 10px; font-size: .95rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

.section-title { margin: 0 0 10px; font-size: .95rem; }
.comment-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.comment {
  background: rgba(0,0,0,.2);
  border-radius: 12px;
  padding: 10px 14px;
  animation: cardIn 0.3s var(--ease-out);
}
.comment.is-admin { border-left: 3px solid var(--accent); }
.comment.is-reply { margin-left: 16px; }
.comment-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; font-size: .8rem; }
.comment-author { font-weight: 700; }
.comment-badge { color: var(--accent); font-weight: 600; }
.comment-body { margin: 0; white-space: pre-wrap; line-height: 1.45; font-size: .92rem; }
.comment-reply { margin-top: 8px; }

.row-btn { cursor: default; }
.row-btn small { display: block; margin-top: 2px; }
.inline-field { display: flex; gap: 8px; }
.inline-field .text-input { flex: 1; }

.admin-list .idea-card { grid-template-columns: 1fr; }

@media (min-width: 640px) {
  .idea-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  #adminList.idea-list { grid-template-columns: 1fr; }
}

/* >>> addon-styles */
/* <<< addon-styles */
