
:root{
  --pink:#7c3aed;
  --blue:#0b57d0;
  --soft-pink:#f5f3ff;
  --soft-blue:#eef7ff;
  --ink:#1f2937;
  --muted:#667085;
  --card:#ffffff;
  --line:#e5e7eb;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  background:linear-gradient(135deg,#fff8fb,#f6fbff);
  color:var(--ink);
}
.hero{
  margin:16px;
  padding:22px;
  border-radius:24px;
  background:linear-gradient(135deg,#ede9fe,#ffffff 60%,#edf7ff);
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:center;
  box-shadow:0 16px 35px rgba(214,51,132,.12);
  border:1px solid #ddd6fe;
}
.eyebrow{margin:0;color:var(--pink);font-weight:800;letter-spacing:.08em;text-transform:uppercase}
h1{margin:4px 0;font-size:clamp(28px,4vw,52px);color:var(--pink)}
.subtitle{margin:0;color:var(--muted);font-size:16px;max-width:850px}
.hero-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
button,select,input{
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px 14px;
  font-size:15px;
  background:white;
}
button{
  cursor:pointer;
  font-weight:700;
  color:var(--blue);
  box-shadow:0 6px 14px rgba(0,0,0,.06);
}
button:hover{transform:translateY(-1px)}
.app{
  display:grid;
  grid-template-columns:1.15fr .85fr;
  gap:16px;
  padding:0 16px 16px;
}
.panel{
  background:rgba(255,255,255,.88);
  border:1px solid var(--line);
  border-radius:24px;
  padding:18px;
  box-shadow:0 12px 28px rgba(16,24,40,.08);
}
.cards-window,.writing-lab,.quiz-lab{grid-column:1 / -1}
.panel-title{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:12px;
}
h2{margin:0;color:#333;font-size:24px}
#countBox{font-size:14px;color:var(--muted)}
#searchInput{min-width:260px}
.kanji-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(72px,1fr));
  gap:10px;
  max-height:480px;
  overflow:auto;
  padding:4px;
}
.kanji-btn{
  height:78px;
  border-radius:18px;
  display:grid;
  place-items:center;
  font-size:38px;
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
  background:white;
  border:2px solid #ddd6fe;
  color:#111;
  cursor:pointer;
  transition:.2s;
}
.kanji-btn.active{
  background:var(--soft-pink);
  border-color:var(--pink);
  color:var(--pink);
  transform:scale(1.03);
}
.selected-kanji{
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
  font-size:130px;
  text-align:center;
  line-height:1;
  background:var(--soft-pink);
  border:2px solid #ffd1e4;
  border-radius:24px;
  padding:18px;
  margin:12px 0;
  color:#111;
}
.meanings{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
  margin:12px 0;
}
.meaning-pill{
  background:#fff;
  border:1px solid #ffd1e4;
  color:var(--pink);
  padding:8px 12px;
  border-radius:999px;
  font-weight:800;
}
.reading-cards{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
.read-card{
  background:var(--soft-blue);
  border:1px solid #cae6ff;
  border-radius:18px;
  padding:14px;
}
.read-card h3{margin:0 0 8px;font-size:18px;color:#0b57d0}
.read-card h3 span{font-size:12px;color:var(--muted)}
.read-card p{margin:0;font-size:24px;font-weight:800}
.nav-buttons{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:10px;
  margin-top:14px;
}
.word-cards{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(230px,1fr));
  gap:14px;
}
.word-card{
  background:white;
  border:1px solid var(--line);
  border-radius:20px;
  padding:16px;
  box-shadow:0 8px 20px rgba(0,0,0,.06);
  position:relative;
  overflow:hidden;
}
.word-card:before{
  content:"";
  position:absolute;
  right:-30px;top:-30px;
  width:90px;height:90px;
  border-radius:50%;
  background:var(--soft-pink);
}
.word-jp{
  font-size:32px;
  font-weight:900;
  color:#111;
  margin:0;
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
}
.word-reading{
  color:var(--blue);
  font-weight:800;
  font-size:18px;
  margin:4px 0 10px;
}
.word-meaning{margin:4px 0;color:#111}
.word-ar{margin:4px 0;color:#6b4f00;direction:rtl;text-align:left}
.word-card button{margin-top:10px;font-size:13px;padding:8px 10px}
.writing-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
}
.stroke-card,.practice-card{
  background:linear-gradient(180deg,#ffffff,#fff9fc);
  border:1px solid #f2d7e5;
  border-radius:22px;
  padding:16px;
}
.stroke-card h3,.practice-card h3{
  margin:0 0 12px;
  color:var(--pink);
}
.stroke-box{
  min-height:420px;
  border-radius:20px;
  border:2px dashed #f2bfd8;
  background:
    linear-gradient(90deg, rgba(214,51,132,.08) 1px, transparent 1px),
    linear-gradient(rgba(214,51,132,.08) 1px, transparent 1px),
    #fff;
  background-size:70px 70px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.stroke-svg text{
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
}
.hint{
  color:var(--muted);
  font-size:14px;
  margin:10px 0 0;
}
.canvas-wrap{
  position:relative;
  width:min(420px,100%);
  aspect-ratio:1;
  margin:auto;
  border-radius:20px;
  border:2px solid #dcecff;
  background:
    linear-gradient(90deg, rgba(11,87,208,.10) 1px, transparent 1px),
    linear-gradient(rgba(11,87,208,.10) 1px, transparent 1px),
    #fff;
  background-size:70px 70px;
  overflow:hidden;
}
.practice-guide{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
  font-size:260px;
  color:rgba(0,0,0,.10);
  pointer-events:none;
  line-height:1;
}
#practiceCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  touch-action:none;
}
.feedback{
  background:var(--soft-blue);
  border:1px solid #cae6ff;
  border-radius:14px;
  padding:10px 12px;
  color:#1f4f8f;
  font-weight:700;
}
footer{
  text-align:center;
  padding:18px;
  color:var(--muted);
  font-size:14px;
}
@media(max-width:850px){
  .hero{flex-direction:column;align-items:flex-start}
  .app{grid-template-columns:1fr}
  .reading-cards,.writing-grid{grid-template-columns:1fr}
  #searchInput{min-width:0;width:100%}
  .panel-title{flex-direction:column;align-items:stretch}
  .selected-kanji{font-size:100px}
  .nav-buttons{grid-template-columns:1fr}
  .practice-guide{font-size:210px}
}


.practice-actions-top,.practice-actions,.quiz-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.stroke-box,.canvas-wrap{
  width:100%;
  max-width:440px;
  height:440px;
  margin:auto;
}
.stroke-box{
  min-height:440px;
}
.stroke-number{
  fill:#7c3aed;
  font-weight:900;
}
.stroke-arrow{
  stroke:#0b57d0;
  stroke-width:5;
  marker-end:url(#arrowHead);
}
.stroke-path{
  stroke:#111827;
  stroke-width:22;
  stroke-linecap:round;
  stroke-linejoin:round;
  fill:none;
}
.stroke-start{
  fill:#e11d48;
}
.stroke-guide-kanji{
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
  fill:rgba(0,0,0,.08);
}
.practice-actions{
  margin-top:10px;
}
.quiz-summary{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:12px;
  margin-bottom:14px;
}
.quiz-summary div{
  background:linear-gradient(135deg,#f5f3ff,#eef7ff);
  border:1px solid #f1d7e5;
  border-radius:16px;
  padding:12px;
  text-align:center;
}
.quiz-box{
  background:white;
  border:1px solid var(--line);
  border-radius:22px;
  padding:18px;
  min-height:210px;
}
.quiz-kanji{
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
  font-size:90px;
  text-align:center;
  margin:0;
}
.quiz-question{
  font-size:20px;
  font-weight:800;
  text-align:center;
  color:#333;
}
.quiz-options{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:12px;
  margin-top:16px;
}
.quiz-options button{
  background:#fff;
  color:#1f2937;
  border:2px solid #e5e7eb;
  min-height:58px;
}
.quiz-options button.correct{
  border-color:#22c55e;
  background:#ecfdf5;
}
.quiz-options button.wrong{
  border-color:#ef4444;
  background:#fef2f2;
}
.quiz-review{
  margin-top:14px;
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:10px;
}
.review-card{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background:#fff;
}
.pass{
  color:#16a34a;
  font-weight:900;
}
.fail{
  color:#dc2626;
  font-weight:900;
}
.quiz-placeholder{
  color:var(--muted);
  text-align:center;
  font-size:18px;
}
@media(max-width:850px){
  .stroke-box,.canvas-wrap{
    height:360px;
  }
  .quiz-summary{
    grid-template-columns:1fr;
  }
}


.top-sections{
  margin:0 16px 16px;
  padding:12px;
  border-radius:20px;
  background:rgba(255,255,255,.9);
  border:1px solid var(--line);
  box-shadow:0 10px 24px rgba(16,24,40,.06);
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:center;
  position:sticky;
  top:8px;
  z-index:20;
  backdrop-filter:blur(10px);
}
.top-sections a{
  color:var(--pink);
  text-decoration:none;
  font-weight:800;
  padding:10px 14px;
  border-radius:999px;
  background:#f5f3ff;
  border:1px solid #ddd6fe;
}
.top-sections a:hover{
  background:var(--pink);
  color:white;
}
.source-buttons{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:10px;
}
.source-buttons a{
  display:inline-block;
  text-decoration:none;
  color:#0b57d0;
  background:#eef7ff;
  border:1px solid #cae6ff;
  padding:9px 12px;
  border-radius:12px;
  font-weight:800;
}
.stroke-real-svg svg{
  max-width:100%;
  max-height:100%;
}
.stroke-real-svg path{
  stroke:#111827 !important;
  stroke-width:4 !important;
  fill:none !important;
}
.stroke-step-label{
  fill:#7c3aed;
  font-size:18px;
  font-weight:900;
}
.stroke-step-dot{
  fill:#e11d48;
}
.quiz-type-badge{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  background:#f5f3ff;
  color:#7c3aed;
  font-weight:900;
  margin-bottom:8px;
}
.fill-blank{
  font-size:24px;
  font-weight:900;
  text-align:center;
  color:#1f2937;
  margin:16px 0;
}


/* Clean professional KanjiVG stroke section */
.stroke-box{
  background:
    linear-gradient(90deg, rgba(214,51,132,.07) 1px, transparent 1px),
    linear-gradient(rgba(214,51,132,.07) 1px, transparent 1px),
    #fff;
  background-size:55px 55px;
  overflow:hidden;
}
.stroke-real-svg{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:22px;
}
.professional-kanjivg{
  width:100%;
  height:100%;
}
.professional-kanjivg path{
  stroke:#111827 !important;
  stroke-width:3.8 !important;
  stroke-linecap:round !important;
  stroke-linejoin:round !important;
  fill:none !important;
}
.professional-kanjivg .guide-bg{
  fill:rgba(0,0,0,.055);
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
}
.professional-kanjivg .stroke-num-bg{
  fill:#ffffff;
  stroke:#7c3aed;
  stroke-width:.9;
}
.professional-kanjivg .stroke-num{
  fill:#7c3aed;
  font-size:5px;
  font-weight:900;
  font-family:Arial, sans-serif;
}
.professional-kanjivg .start-dot{
  fill:#e11d48;
}
.stroke-info{
  margin-top:12px;
  padding:12px;
  border-radius:16px;
  background:linear-gradient(135deg,#f5f3ff,#eef7ff);
  border:1px solid #f1d7e5;
  color:#374151;
  font-size:14px;
  font-weight:700;
}
.loading-stroke{
  text-align:center;
  color:#667085;
  line-height:1.7;
}
.stroke-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:10px;
}
.stroke-actions button, .stroke-actions a{
  display:inline-block;
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px 14px;
  background:white;
  text-decoration:none;
  color:#0b57d0;
  font-weight:800;
  box-shadow:0 6px 14px rgba(0,0,0,.06);
}


/* Stroke numbers cleaned: small labels, no large circles */
.professional-kanjivg .stroke-num-bg{
  display:none !important;
}
.professional-kanjivg .stroke-num{
  fill:#7c3aed;
  font-size:3.4px !important;
  font-weight:900;
  font-family:Arial, sans-serif;
  paint-order:stroke;
  stroke:white;
  stroke-width:.55px;
}
.professional-kanjivg .start-dot{
  fill:#e11d48;
  opacity:.85;
}

/* Three professional stroke windows */
.writing-grid{
  grid-template-columns:repeat(3,1fr) !important;
  align-items:start;
}
.animation-card{
  background:linear-gradient(180deg,#ffffff,#f7fbff);
  border:1px solid #cae6ff;
  border-radius:22px;
  padding:16px;
}
.animation-card h3{
  margin:0 0 12px;
  color:#0b57d0;
}
.animation-box{
  width:100%;
  max-width:440px;
  height:440px;
  margin:auto;
  border-radius:20px;
  border:2px dashed #cae6ff;
  background:
    linear-gradient(90deg, rgba(11,87,208,.07) 1px, transparent 1px),
    linear-gradient(rgba(11,87,208,.07) 1px, transparent 1px),
    #fff;
  background-size:55px 55px;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
}
.animation-box svg{
  width:100%;
  height:100%;
}
.animation-box path{
  fill:none !important;
  stroke:#111827 !important;
  stroke-width:3.8 !important;
  stroke-linecap:round !important;
  stroke-linejoin:round !important;
}
.animated-stroke{
  stroke-dasharray:1000;
  stroke-dashoffset:1000;
  animation-fill-mode:forwards;
  animation-timing-function:ease-in-out;
}
@keyframes drawStroke{
  to{stroke-dashoffset:0;}
}
@media(max-width:1100px){
  .writing-grid{
    grid-template-columns:1fr !important;
  }
  .animation-box,.stroke-box,.canvas-wrap{
    height:380px;
  }
}


#jpVoiceSelect,
#enVoiceSelect{
  min-width:170px;
  background:white;
  border:1px solid #e5e7eb;
  color:#374151;
  font-weight:700;
}

.hero-actions{
  align-items:center;
}

