/* Layout: 工作机 — お題カード｜コードの黒板｜けっかの画用紙 を横にならべる。ホームはレッスンの道のり */
:root {
  --paper: #EEF4FA;
  --card: #FFFFFF;
  --ink: #1D2846;
  --ink-2: #56627F;
  --line: #D5DFEC;
  --sun: #FFC53D;
  --sun-2: #E9A400;
  --sun-soft: #FFF4D1;
  --tomato: #EC5B45;
  --tomato-soft: #FDE7E3;
  --leaf: #1F9E74;
  --leaf-2: #167A59;
  --leaf-soft: #DDF4EA;
  --sky: #2F76CC;
  --sky-soft: #E1EDFB;
  --board: #1A2240;
  --board-2: #232D52;
  --board-ink: #E7ECF7;
  --board-dim: #7D88AE;
  --hl-tag: #FF8FA8;
  --hl-attr: #FFD36B;
  --hl-str: #8FE0A0;
  --hl-sel: #7DD3FC;
  --hl-prop: #FFD36B;
  --hl-val: #8FE0A0;
  --hl-punc: #A3AED0;
  --display: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Meiryo", sans-serif;
  --body: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Meiryo", sans-serif;
  --code: "Source Code Pro", Consolas, Menlo, "MS Gothic", monospace;
  color-scheme: light;
}
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}
#app.fixed { height: 100%; min-height: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding-block: 10px; flex-wrap: wrap; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-weight: 800; font-size: 19px;
  background: none; border: 0; cursor: pointer; padding: 0; color: var(--ink);
}
.crumb { font-family: var(--display); font-weight: 500; color: var(--ink-2); font-size: 15px; min-width: 0; }
.spacer { flex: 1; }
.who {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 2px solid var(--line); border-radius: 999px;
  padding: 3px 14px 3px 4px; font-weight: 700; cursor: pointer; font-size: 15px;
}
.av {
  width: 28px; height: 28px; border-radius: 50%; background: var(--sun);
  display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 14px;
}
main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-block: 0 16px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--display); font-weight: 800; font-size: 16px; line-height: 1.3;
  border: 2px solid var(--line); border-radius: 14px; padding: 9px 18px; cursor: pointer;
  color: var(--ink); background: var(--card); box-shadow: 0 3px 0 var(--line);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--sun); border-color: var(--sun-2); box-shadow: 0 4px 0 var(--sun-2); }
.btn.go { background: var(--leaf); border-color: var(--leaf-2); color: #fff; box-shadow: 0 4px 0 var(--leaf-2); }
.btn.small { font-size: 14px; padding: 5px 12px; border-radius: 10px; }
.btn.dark { background: var(--board); color: var(--board-ink); border-color: var(--board-dim); box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- home ---------- */
.home { max-width: 1080px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 28px; padding-top: 6px; }
.hello {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center;
  background: var(--card); border-radius: 26px; padding: 24px; border: 2px solid var(--line);
}
.hello h1 {
  font-family: var(--display); font-weight: 800; font-size: clamp(25px, 3.6vw, 38px);
  line-height: 1.3; margin: 0 0 6px; text-wrap: balance;
}
.hello p { margin: 0; color: var(--ink-2); font-size: 16px; }
.users { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.users-label { font-family: var(--display); font-weight: 800; font-size: 14px; margin-right: 4px; }
.uchip {
  border: 2px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 3px 14px; cursor: pointer; font-weight: 700; font-size: 15px;
}
.uchip[aria-pressed="true"] { background: var(--sun); border-color: var(--sun-2); }
.adduser { display: flex; gap: 6px; align-items: center; }
input[type="text"] {
  font-family: var(--body); font-size: 16px; padding: 6px 12px; border-radius: 12px;
  border: 2px solid var(--line); width: 10em; min-width: 0; background: var(--card); color: var(--ink);
}
.sec-h { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 0 0 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sec-h small { font-family: var(--body); font-weight: 500; font-size: 14px; color: var(--ink-2); }
.lessons { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 14px; }
.lcard {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 2px 14px; align-content: start;
  text-align: left; width: 100%; height: 100%; box-sizing: border-box;
  background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 16px;
  cursor: pointer; box-shadow: 0 4px 0 var(--line); transition: border-color .15s, transform .15s;
}
.lcard:hover { border-color: var(--sun-2); transform: translateY(-2px); }
.lnum {
  grid-row: span 3; width: 56px; height: 56px; border-radius: 18px; background: var(--sun-soft);
  display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 26px;
}
.lcard.done .lnum { background: var(--leaf); color: #fff; }
.ltitle { font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.4; }
.ldesc { font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.lmeta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tagchip { font-family: var(--code); font-size: 13px; background: var(--sky-soft); color: var(--sky); border-radius: 6px; padding: 0 7px; }
.stars { margin-left: auto; font-size: 15px; color: var(--sun-2); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--line); }
.freecard {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center;
  background: var(--board); color: var(--board-ink); border-radius: 22px; padding: 18px 22px; border: 0;
  cursor: pointer; text-align: left; width: 100%; box-sizing: border-box;
}
.freecard .ltitle { color: #fff; }
.freecard .ldesc { color: var(--board-dim); }
.freecard .fc-icon { font-family: var(--code); font-size: 26px; color: var(--hl-tag); }
.teacher { font-size: 14px; color: var(--ink-2); background: var(--card); border: 2px dashed var(--line); border-radius: 18px; padding: 14px 18px; }
.teacher b { font-family: var(--display); color: var(--ink); }

/* ---------- slides ---------- */
.slides {
  max-width: 1000px; margin: 0 auto; width: 100%; box-sizing: border-box;
  background: var(--card); border-radius: 26px; border: 2px solid var(--line);
  padding: 26px; display: flex; flex-direction: column; gap: 22px;
}
.sl-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sl-kicker { font-family: var(--display); font-weight: 800; font-size: 14px; color: var(--sun-2); letter-spacing: .06em; }
.dots { display: flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--sun-2); }
.sl-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.sl-grid.single { grid-template-columns: minmax(0, 1fr); }
.sl-text h2 { font-family: var(--display); font-weight: 800; font-size: clamp(24px, 3vw, 32px); margin: 0 0 14px; line-height: 1.35; text-wrap: balance; }
.sl-text p { font-size: 18px; line-height: 2; margin: 0; max-width: 34em; }
.sl-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sl-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.label { font-family: var(--display); font-weight: 800; font-size: 12.5px; letter-spacing: .06em; color: var(--ink-2); }
code.c {
  font-family: var(--code); background: var(--sun-soft); color: var(--ink);
  border-radius: 6px; padding: 1px 6px; font-size: .92em; overflow-wrap: anywhere;
}
pre.code {
  margin: 0; background: var(--board); color: var(--board-ink); border-radius: 14px;
  padding: 14px 16px; font: 15px/1.65 var(--code); overflow-x: auto; white-space: pre; tab-size: 2;
}
.demo { border: 2px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.demo iframe { width: 100%; height: 160px; border: 0; display: block; }
.anat {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-start;
  background: var(--board); border-radius: 14px; padding: 20px 18px;
  font: 26px/1.2 var(--code); color: var(--board-ink);
}
.anat span { display: flex; flex-direction: column; align-items: center; }
.anat em {
  font-style: normal; font-family: var(--body); font-weight: 700; font-size: 12.5px;
  color: var(--board-ink); background: var(--board-2); border-radius: 8px; padding: 3px 8px;
  margin-top: 8px; text-align: center; line-height: 1.35;
}
.gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.gallery figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gallery img { width: 100%; border-radius: 12px; border: 2px solid var(--line); }
.gallery figcaption { font-family: var(--code); font-size: 13px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; font-family: var(--code); font-size: 14px; background: var(--paper); border-radius: 10px; padding: 6px 8px; }
.swatch i { width: 22px; height: 22px; border-radius: 6px; flex: none; border: 1px solid var(--line); }

/* ---------- work area ---------- */
.work {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1.05fr) minmax(0, 1fr); gap: 14px;
}
.pane {
  background: var(--card); border: 2px solid var(--line); border-radius: 20px;
  display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
}
.task { padding: 18px; overflow: auto; gap: 14px; }
.task-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--display); font-weight: 800; font-size: 13px; color: var(--ink-2); }
.exdots { display: flex; gap: 5px; }
.exdots button {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: var(--card);
  font-family: var(--display); font-weight: 800; font-size: 12px; cursor: pointer; color: var(--ink-2); padding: 0;
}
.exdots button.done { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.exdots button.cur { border-color: var(--sun-2); box-shadow: 0 0 0 3px var(--sun); }
.task h2 { font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1.4; margin: 0; text-wrap: balance; }
.ch {
  display: inline-block; vertical-align: middle; background: var(--tomato-soft); color: var(--tomato);
  font-size: 12px; border-radius: 999px; padding: 0 9px; font-family: var(--display); font-weight: 800; margin-left: 4px;
}
.task-body { font-size: 16.5px; line-height: 1.9; }
.hintbox { background: var(--sky-soft); border-radius: 14px; padding: 12px 14px; font-size: 15px; line-height: 1.8; }
.ansbox { display: flex; flex-direction: column; gap: 6px; }
.ansbox pre.code { font-size: 13.5px; }
.ansnote { font-size: 13px; color: var(--ink-2); }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }

.editor-pane { background: var(--board); border-color: var(--board); }
.edtabs { display: flex; align-items: flex-end; gap: 4px; background: var(--board-2); padding: 8px 10px 0; }
.edtab {
  font-family: var(--code); font-size: 14px; color: var(--board-dim); background: transparent;
  border: 0; border-radius: 10px 10px 0 0; padding: 7px 14px; cursor: pointer;
}
.edtab[aria-selected="true"] { background: var(--board); color: var(--board-ink); }
.edtabs .btn { margin-bottom: 6px; }
.ed { flex: 1; min-height: 0; display: flex; background: var(--board); }
.gutter { width: 40px; flex: none; overflow: hidden; color: var(--board-dim); font: 16px/1.65 var(--code); text-align: right; user-select: none; }
.gutter .nums { padding-top: 14px; white-space: pre; }
.ed-body { position: relative; flex: 1; min-width: 0; }
.hl, .ed textarea {
  position: absolute; inset: 0; margin: 0; box-sizing: border-box;
  padding: 14px 16px 14px 14px; font: 16px/1.65 var(--code); letter-spacing: 0;
  white-space: pre; overflow-wrap: normal; tab-size: 2; -moz-tab-size: 2; border: 0;
}
.hl { overflow: hidden; pointer-events: none; color: var(--board-ink); }
.ed textarea {
  background: transparent; color: transparent; caret-color: var(--sun);
  resize: none; outline: none; overflow: auto; width: 100%; height: 100%;
}
.ed textarea::selection { background: rgba(255, 197, 61, .32); }
.ed.composing textarea { color: var(--board-ink); }
.ed.composing .hl { visibility: hidden; }
.t-tag { color: var(--hl-tag); }
.t-attr { color: var(--hl-attr); }
.t-str { color: var(--hl-str); }
.t-sel { color: var(--hl-sel); }
.t-prop { color: var(--hl-prop); }
.t-val { color: var(--hl-val); }
.t-punc { color: var(--hl-punc); }
.t-com { color: var(--board-dim); }
.zen { background: rgba(236, 91, 69, .6); border-radius: 3px; box-shadow: 0 0 0 1px var(--tomato); }
.edfoot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--board-2); }
.bubble {
  flex: 1; min-width: 0; background: var(--card); color: var(--ink); border: 2px solid var(--card);
  border-radius: 14px; padding: 7px 12px; font-size: 14.5px; line-height: 1.6;
}
.bubble.ng { background: var(--tomato-soft); border-color: var(--tomato); }
.bubble.ok { background: var(--leaf-soft); border-color: var(--leaf); }
.bubble.ng.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.pv-col { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; min-height: 0; min-width: 0; }
.pv-col.one { grid-template-rows: minmax(0, 1fr); }
.pvhead {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 2px solid var(--line);
  font-family: var(--display); font-weight: 800; font-size: 14px; background: var(--paper);
}
.pvhead small { font-family: var(--body); font-weight: 700; font-size: 12.5px; color: var(--ink-2); margin-left: auto; }
.bdots { display: flex; gap: 5px; }
.bdots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.bdots i:nth-child(1) { background: var(--tomato); }
.bdots i:nth-child(2) { background: var(--sun); }
.bdots i:nth-child(3) { background: var(--leaf); }
.answer-pane { border-style: dashed; border-color: var(--sun-2); }
.answer-pane .pvhead { background: var(--sun-soft); border-bottom: 2px dashed var(--sun-2); }
.pvframe { flex: 1; min-height: 0; position: relative; background: #fff; }
.pvframe iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.refgrid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; font-size: 14px; align-items: baseline; }
.refgrid code { font-family: var(--code); font-size: 13px; color: var(--sky); white-space: nowrap; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(29, 40, 70, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal {
  background: var(--card); border-radius: 28px; padding: 28px 24px; max-width: 440px; width: 100%; box-sizing: border-box;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop .35s ease-out;
}
.modal h2 { font-family: var(--display); font-weight: 800; font-size: 34px; margin: 0; color: var(--leaf); line-height: 1.3; }
.modal p { margin: 0; color: var(--ink-2); }
.modal .bigstars { font-size: 30px; color: var(--sun-2); letter-spacing: 4px; }
.modal .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }
.mascot { flex: none; display: block; }
.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }

@media (max-width: 900px) {
  #app.fixed { height: auto; min-height: 100%; }
  .work { display: flex; flex-direction: column; }
  .task { overflow: visible; }
  .editor-pane { height: 400px; flex: none; }
  .pv-col { display: flex; flex-direction: column; }
  .pv-col .pane { height: 280px; flex: none; }
  .sl-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .hello { grid-template-columns: minmax(0, 1fr); justify-items: start; padding: 18px; }
  .slides { padding: 18px; }
  .sl-text p { font-size: 16.5px; }
  .freecard { grid-template-columns: minmax(0, 1fr); }
  .crumb { flex-basis: 100%; order: 3; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
