/* MSSIngleCore.css — v0.6 CLEAN
   Goals:
   - Single coherent visual system (no duplicate blocks)
   - Desktop feed: stable single-line grid
   - Identity: subtle "You are anonymous" + Personalize/Register
   - Recording: Record/Stop + Progress + Submit + Cancel
   - CEFR filter: single slider over gradient (cefrFilter / cefrCenter)
   - iPhone: no weird padding + sane control layout
*/

:root{
  --border:#e5e7eb;
  --text:#111827;
  --sub:#6b7280;
  --bg:#f8fafc;
  --card:#ffffff;
  --chip:#f3f4f6;

  --shadow: 0 1px 8px rgba(17,24,39,.08);
  --danger:#ef4444;
  --ok:#22c55e;

  --radius:16px;
  --pad:16px;
  --hairline: rgba(0,0,0,.08);
}

/* ---------- Global reset ---------- */
html, body{
  margin:0;
  padding:0;
}
body{
  background:var(--bg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
}

/* ---------- Outer page card ---------- */
#mss-widget-root.ingle{
  max-width: 980px;
  margin: 14px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow:hidden;
  box-sizing: border-box;
}

/* Remove double-padding: the root owns padding, inner sections do not */
.ingle-main{
  padding: 0;
  margin: 0;
}

/* ---------- Header ---------- */
.ingle-header{
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 14px var(--pad);
  border-bottom:1px solid var(--border);
  background:#fff;
}
.ingle-header-left{ display:flex; flex-direction:column; }
.ingle-logo{ font-weight: 900; font-size: 18px; letter-spacing:.2px; }
.ingle-tagline{ font-size: 12px; color: var(--sub); margin-top:2px; }

.ingle-header-right{
  display:flex;
  align-items:center;
  gap: 14px;
  justify-content:flex-end;
}
.ingleDateWrap{ display:flex; align-items:center; gap:10px; }
.ingle-date{ font-size: 12px; color: var(--sub); }

/* Subtle teacher CTA */
.teacherLink{
  font-size: 12px;
  color: rgba(0,0,0,0.40);
  text-decoration: none;
  white-space: nowrap;
}
.teacherLink:hover{
  color: rgba(0,0,0,0.65);
  text-decoration: underline;
}

/* ---------- Identity strip/card (under header) ---------- */
.identityCard{
  padding: 12px var(--pad);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.60);
  backdrop-filter: blur(6px);
}
.identityRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.identityLeft{ display:flex; align-items:baseline; gap:10px; min-width:0; }
.identityLabel{
  font-size: 12px;
  color: rgba(0,0,0,0.45);
}
.identityWho{ display:flex; align-items:center; gap:8px; min-width:0; }
.identityHandle{
  font-size: 13px;
  font-weight: 650;
  color: rgba(0,0,0,0.72);
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.pillBadge{
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.10);
  color: rgba(0,0,0,0.50);
  background: rgba(255,255,255,0.55);
  white-space: nowrap;
}

.identityActions{ display:flex; gap: 10px; align-items:center; }

/* Jony-ish pills */
.btnPill{
  appearance:none;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.65);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  color: rgba(0,0,0,0.75);
  cursor:pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.btnPill:hover{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.18);
}
.btnPill:active{ transform: translateY(1px); }

.btnPillPrimary{
  background: rgba(0,0,0,0.84);
  border-color: rgba(0,0,0,0.84);
  color: rgba(255,255,255,0.92);
}
.btnPillPrimary:hover{ background: rgba(0,0,0,0.94); }

/* Personalize panel */
.personalizePanel{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0,0,0,0.10);
  display:flex;
  align-items:center;
  gap:8px;
}
.isHidden{ display:none !important; }

.personalizeInput{
  flex: 1;
  min-width: 220px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  background: rgba(255,255,255,0.78);
  outline: none;
}
.personalizeInput:focus{
  border-color: rgba(0,0,0,0.22);
  background: rgba(255,255,255,0.95);
}

.iconBtn{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.65);
  cursor:pointer;
  font-size: 14px;
  line-height: 1;
}
.iconBtn:hover{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.18);
}
.iconBtnOk{
  background: rgba(0,0,0,0.84);
  border-color: rgba(0,0,0,0.84);
  color: rgba(255,255,255,0.92);
}
.iconBtnOk:hover{ background: rgba(0,0,0,0.94); }

.microMsg{
  font-size: 12px;
  color: rgba(0,0,0,0.45);
  margin-left: 6px;
  white-space: nowrap;
}

/* ---------- Hero (question) ---------- */
.ingle-hero{
  padding: 14px var(--pad) 12px;
}
.ingle-hero-top{
  display:flex;
  justify-content: space-between;
  gap:10px;
  align-items:center;
}
.ingle-badge{
  font-size:12px;
  padding:4px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:var(--chip);
  font-weight:700;
}
.ingle-rule{ font-size:12px; color:var(--sub); }

.ingle-qcard{
  margin-top:10px;
  padding: 12px;
  border:1px solid var(--border);
  border-radius: 12px;
  background:#fbfdff;
}
.ingle-question{ margin:0; font-size: 16px; font-weight: 750; }
.ingle-preview{ margin-top:10px; font-size: 13px; color: var(--sub); }

/* ---------- Controls ---------- */
.ingle-controls{
  padding: 0 var(--pad) 14px;
}

.ingle-record-row-3{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.ingle-record-left{
  display:flex;
  align-items:center;
  gap:10px;
}

.ingle-submit-actions{
  display:flex;
  align-items:center;
  gap:10px;
  margin-left:auto;
}

/* Buttons */
.ingle-btn{
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-weight:700;
  transition: transform .06s ease, box-shadow .12s ease, opacity .12s ease;
}
.ingle-btn.primary{
  background:#111827;
  color:#fff;
  border-color:#111827;
}
.ingle-btn:active{ transform: translateY(1px); }
.ingle-btn:hover{ box-shadow: var(--shadow); }
.ingle-btn:disabled{
  opacity:.5;
  cursor:not-allowed;
  box-shadow:none;
  transform:none;
}

/* Cancel icon button */
.ingle-btn.icon{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items:center;
  justify-content:center;
}

/* Recording progress (single definitive implementation) */
.recProgWrap{
  flex: 1 1 auto;
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 160px;
  margin: 0 14px;
}
.recProgTrack{
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
}
.recProgFill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: rgba(0,0,0,0.72);
  transition: width 80ms linear;
}
.recProgSec{
  width: 42px;
  text-align: right;
  font-size: 12px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* Timer row */
.ingle-timer-row{
  display:flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: var(--sub);
}
.ingle-rec-dot{
  display:inline-block;
  width:10px;
  height:10px;
  border-radius:999px;
  background:var(--danger);
  opacity:.2;
  margin-right:6px;
}

/* Player */
.ingle-player{
  margin-top: 10px;
  padding: 10px;
  border:1px solid var(--border);
  border-radius: 12px;
  background:#fbfdff;
}
.ingle-player audio{ width:100%; }
.ingle-hint{ font-size: 12px; color: var(--sub); margin-top: 6px; }

.ingle-status{ margin-top: 10px; font-size: 13px; color: var(--sub); }

/* ---------- Feed ---------- */
.ingle-feed{
  margin: 14px var(--pad) 16px;
  border:1px solid var(--border);
  border-radius: 14px;
  overflow:hidden;
  background:#fff;
}
.ingle-feed-header{
  padding: 12px;
  border-bottom:1px solid var(--border);
}
.ingle-feed-title{ font-weight: 900; }
.ingle-feed-sub{ font-size: 12px; color: var(--sub); margin-top:3px; }
.ingle-feed-list{ display:flex; flex-direction: column; }

/* ---------- CEFR Filter (single slider over gradient) ---------- */
.cefrFilter { margin-top: 10px; }

.cefrTrackWrap{
  position: relative;
  height: 18px;
  margin-top: 8px;
  margin-bottom: 6px;
}

.cefrBar{
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 10px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    #d94b4b 0%,
    #f39c12 20%,
    #f1c40f 40%,
    #2ecc71 60%,
    #3498db 80%,
    #9b59b6 100%
  );
  border: 1px solid rgba(0,0,0,0.06);
}

/* Slider overlays the bar */
.cefrCenter{
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  width: 100%;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  z-index: 2;
}

/* Transparent track */
.cefrCenter::-webkit-slider-runnable-track{
  height: 10px;
  background: transparent;
  border-radius: 8px;
}
.cefrCenter::-moz-range-track{
  height: 10px;
  background: transparent;
  border-radius: 8px;
}

/* Thumb */
.cefrCenter::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #0b5fff;
  border: 2px solid #ffffff;
  margin-top: -3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.cefrCenter::-moz-range-thumb{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #0b5fff;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.cefrLabel{
  margin-top: 6px;
  font-size: 12px;
  color: rgba(0,0,0,0.55);
}

/* ---------- Signature Ingle row (desktop: single line grid) ---------- */
.ingle-row{
  display:grid;
  grid-template-columns: 140px 44px minmax(260px,1fr) 140px 92px;
  gap: 10px;
  align-items:center;
  padding: 10px 12px;
  border-top:1px solid #f1f5f9;
  font-size: 14px;
  overflow:hidden; /* guards against wrap glitches */
}

.ingle-user{
  font-weight: 900;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Play button cell */
.ingle-playcell{
  display:flex;
  justify-content:center;
  gap:8px;
}
.ingle-play{
  height: 34px;
  width: 34px;
  border-radius: 12px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-weight:900;
  line-height: 1;
  transition: box-shadow .12s ease, transform .06s ease, opacity .12s ease;
}
.ingle-play:hover{ box-shadow: var(--shadow); }
.ingle-play:active{ transform: translateY(1px); }
.ingle-play:disabled{
  opacity:.35;
  cursor:not-allowed;
  box-shadow:none;
  transform:none;
}

/* Score bar + marker + pill */
.ingle-bar-wrap{
  position: relative;
  padding-top: 20px; /* room for pill */
  min-width: 260px;
}
.ingle-bar{
  position: relative;
  height: 10px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: linear-gradient(
    90deg,
    #e74c3c 0%,
    #f39c12 30%,
    #f1c40f 45%,
    #2ecc71 65%,
    #27ae60 80%,
    #145a32 100%
  );
}
.ingle-marker{
  position:absolute;
  top:-5px;
  width: 2px;
  height: 20px;
  background:#111;
  border-radius: 1px;
  box-shadow: 0 0 0 2px #fff;
}
.ingle-cefr-pill{
  position:absolute;
  top:0px;
  transform: translateX(-50%);
  background:#111;
  color:#fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events:none;
}

/* Meta + actions */
.ingle-meta{
  font-size: 12px;
  color: var(--sub);
  display:flex;
  justify-content:flex-end;
  gap:10px;
  white-space: nowrap;
}
.ingle-meta strong{ color: var(--text); }

.ingle-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
}
.ingle-act{
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-weight:900;
  transition: box-shadow .12s ease, transform .06s ease, opacity .12s ease, color .12s ease, border-color .12s ease;
}
.ingle-act:hover{ box-shadow: var(--shadow); }
.ingle-act:active{ transform: translateY(1px); }

/* Toggle states (optional) */
.ingle-act.liked{
  color: var(--danger);
  border-color: rgba(239,68,68,.35);
  box-shadow: 0 1px 10px rgba(239,68,68,.12);
}
.ingle-act.following{
  color: var(--ok);
  border-color: rgba(34,197,94,.35);
  box-shadow: 0 1px 10px rgba(34,197,94,.12);
}

/* New-row pop */
.ingle-row-new{ animation: popIn .35s ease-out; }
@keyframes popIn{
  from{ opacity:0; transform: translateY(6px); }
  to{ opacity:1; transform: translateY(0); }
}

/* ---------- Dev nav (only shown by JS on localhost) ---------- */
.ingle-dev-nav{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px;
}
.ingle-dev-btn{
  height:28px;
  min-width:34px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-weight:900;
}
.ingle-dev-date{
  font-size:12px;
  color:var(--sub);
  font-weight:800;
}

/* ---------- Submit toast ---------- */
.ingle-progress{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background:#111827;
  color:#fff;
  padding: 10px 14px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  gap:10px;
  z-index: 9999;
  box-shadow: 0 10px 25px rgba(0,0,0,0.20);
}
.ingle-progress.hidden{ display:none; }
.ingle-progress-bar{
  width: 26px;
  height: 8px;
  border-radius:999px;
  background:#fff;
  opacity:.35;
}
.ingle-progress-text{ font-size: 13px; font-weight: 800; }

/* ---------- TEMP: hide monetization/score until ready ---------- */
.ingle-upsell { display: none !important; }
#scoreWrap { display: none !important; }

/* Submit-in-progress: re-use record progress bar */
.recProgWrap.is-submitting .recProgFill{
  width: 35% !important;                /* base width for the moving stripe */
  animation: recSubmitSweep 1.1s linear infinite;
  opacity: 0.9;
  filter: saturate(1.2);
}

/* Optional: make it visually distinct from recording */
.recProgWrap.is-submitting .recProgFill{
  /* if your fill already has a color, this is the simplest way to differentiate */
  background: repeating-linear-gradient(
    45deg,
    rgba(0,0,0,0.18) 0px,
    rgba(0,0,0,0.18) 8px,
    rgba(0,0,0,0.06) 8px,
    rgba(0,0,0,0.06) 16px
  );
}

/* Animate the fill across */
@keyframes recSubmitSweep{
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* Disable submit while submitting (visual feedback) */
#submitBtn[disabled]{
  opacity: .55;
  cursor: not-allowed;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px){
  #mss-widget-root.ingle{
    margin: 10px;
  }
}

/* iPhone / narrow screens */
@media (max-width: 520px){
  .ingle-header{
    padding: 14px var(--pad);
    border-bottom: 1px solid var(--hairline);
  }
  .ingle-tagline{ display:none; } /* quieter */
  .ingle-date{
    font-size: 13px;
    color: rgba(0,0,0,.55);
  }

  /* Identity becomes a calm single row strip */
  .identityCard{
    padding: 10px var(--pad);
    background: transparent;
    backdrop-filter: none;
  }
  .pillBadge{
    font-size: 12px;
    padding: 4px 10px;
  }

  /* Hero: question is the star */
  .ingle-hero{
    padding: 14px var(--pad) 10px;
  }
  .ingle-qcard{
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 14px 14px;
    background: rgba(255,255,255,.70);
  }
  .ingle-question{
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: .1px;
  }
  .ingle-preview{
    margin-top: 10px;
    font-size: 13px;
    color: rgba(0,0,0,.55);
  }

  /* Controls: single clean column with a “record row” that wraps */
  .ingle-controls{
    padding: 0 var(--pad) calc(16px + env(safe-area-inset-bottom));
  }

  .ingle-record-row-3{
    display:grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }
  .ingle-record-left{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .ingle-submit-actions{
    display:grid;
    grid-template-columns: 1fr 44px;
    gap: 10px;
    margin-left: 0;
  }

  /* Buttons are tappable + consistent */
  .ingle-btn{
    min-height: 44px;
    border-radius: 14px;
    font-size: 14px;
    padding: 10px 12px;
  }
  .ingle-btn.icon{
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  /* Progress becomes its own row on mobile */
  .recProgWrap{
    margin: 0;
    min-width: 0;
    padding: 0;
  }
  .recProgSec{
    width: 44px;
  }

  /* Feed stacks */
  .ingle-feed{
    margin: 14px var(--pad) 16px;
  }
  .ingle-row{
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
  }
  .ingle-playcell{ justify-content:flex-start; }
  .ingle-meta,
  .ingle-actions{ justify-content:flex-start; }
}
.topic-rating{
  margin-left: 8px;
  opacity: .85;
  font-weight: 600;
}
/* Submit progress container */
#submitProgress.hidden,
#submitProgress.mss-hidden {
  display: none !important;
}

/* Indeterminate animated bar */
#submitProgress .ingle-progress-bar{
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  background: rgba(0,0,0,0.08);
}

/* moving “pill” */
#submitProgress .ingle-progress-bar::before{
  content:"";
  position:absolute;
  top:0;
  left:-40%;
  width:40%;
  height:100%;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  animation: submitSweep 1.05s ease-in-out infinite;
}

@keyframes submitSweep{
  0%   { transform: translateX(0); }
  100% { transform: translateX(350%); }
}

/* Optional: when submitting, dim the submit button */
#submitBtn[disabled]{
  opacity: .55;
  cursor: not-allowed;
}
/* default already exists for recording */
#recProgWrap.is-submitting .ingle-progress-bar,
.recProgWrap.is-submitting .ingle-progress-bar {
  /* pick whatever matches your system */
  filter: saturate(1.2);
  opacity: 0.95;
}

/* If your bar is a child like .recProgFill, style that instead */
#recProgWrap.is-submitting .recProgFill,
.recProgWrap.is-submitting .recProgFill {
  /* new “submission” look */
  background: linear-gradient(90deg, #2d7bdc, #8e44ad);
}