/* 蕩音（tou-on。旧「いと」v2）— 画面の文法は「蕩」と同じ：灰の地＋砂目、温めた白の細い線、名前は文字でなくアイコン。
   蕩の緑に対して、蕩音の差し色は朱（いと v1 から引き継ぎ、灰の地で沈まない明るさに上げた）。面では使わず、鳴っている所にだけ置く */
:root{
  --ground:#585657;
  --ink:#F1F0EC;
  --ink-2:rgba(241,240,236,.66);
  --ink-3:rgba(241,240,236,.38);
  --rule:rgba(241,240,236,.18);
  --aka:#F0875A;
  --f:"Hiragino Sans","Noto Sans JP",system-ui,sans-serif;
  --sat:env(safe-area-inset-top); --sab:env(safe-area-inset-bottom);
  color-scheme:dark;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
html,body{margin:0; height:100%; overflow:hidden; overscroll-behavior:none}
body{
  background:var(--ground) url(grain-soft.png) 0 0 / 256px 256px repeat;
  color:var(--ink); font-family:var(--f); font-weight:300; letter-spacing:.08em;
  -webkit-font-smoothing:antialiased; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
}
button{appearance:none; border:0; background:none; color:inherit; font:inherit; letter-spacing:inherit; padding:0; cursor:pointer}
svg{display:block; fill:none; stroke:currentColor; stroke-width:1.25; stroke-linecap:round; stroke-linejoin:round}
svg circle{fill:currentColor; stroke:none}
svg circle.line{fill:none; stroke:currentColor}
svg circle.knob{fill:var(--ground); stroke:currentColor}
:focus-visible{outline:1px solid var(--ink-3); outline-offset:3px; border-radius:8px}

#field{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none}

.mark{position:fixed; z-index:2; top:calc(var(--sat) + 20px); left:24px; margin:0;
  font-weight:200; font-size:20px; line-height:1; letter-spacing:.5em; pointer-events:none}

.top{position:fixed; z-index:3; top:calc(var(--sat) + 8px); right:10px; display:flex; gap:2px}
.top button{padding:8px; color:var(--ink-2); transition:color .6s ease}
.top button:hover{color:var(--ink)}
.top svg{width:28px; height:28px}
#play .stop{display:none}
#play[aria-pressed="true"] .stop{display:inline}
#play[aria-pressed="true"] .go{display:none}

/* 案内は蕩と同じく上に。拍の輪や奏の棒など、道具が自分で描くものと重ならない位置 */
.hint{position:fixed; z-index:1; left:0; right:0; top:calc(var(--sat) + 62px); margin:0; padding:0 16px; text-align:center; white-space:nowrap;
  font-size:13px; line-height:2; letter-spacing:.2em; color:var(--ink-2);
  opacity:0; transition:opacity 1.6s ease; pointer-events:none}
.hint.show{opacity:1}

/* 下の帯：上の段が持っている道具の中身（型・音色）、下の段が道具 */
.bar{position:fixed; z-index:2; left:0; right:0; bottom:0; display:grid; justify-items:center; gap:2px;
  padding:26px 12px calc(14px + var(--sab));
  background:linear-gradient(to top, rgba(88,86,87,.94) 55%, rgba(88,86,87,0)); pointer-events:none}
.bar > *{pointer-events:auto}
.row{display:flex; align-items:center; justify-content:center; max-width:100%}
.row--sub .icons + .icons{margin-left:10px; padding-left:10px; border-left:1px solid var(--rule)}
.row--sub .icons[hidden] + .icons{margin-left:0; padding-left:0; border-left:0}
.icons{display:flex; justify-content:center}
.icons[hidden]{display:none}
.icons button{position:relative; padding:7px 5px 9px; color:var(--ink-3); transition:color .6s ease}
.icons button:hover{color:var(--ink-2)}
.icons svg{width:26px; height:26px}
.icons button::after{content:""; position:absolute; left:50%; bottom:2px; width:0; height:1px; background:var(--aka);
  transition:width .6s ease, left .6s ease}
.icons button[aria-checked="true"]{color:var(--ink)}
.icons button[aria-checked="true"]::after{left:5px; width:calc(100% - 10px)}
.icons--tools{gap:clamp(8px, 5vw, 30px); margin-top:4px}
.icons--tools button{padding:8px 6px 11px}
.icons--tools svg{width:34px; height:34px}
/* 層に中身がある道具には、右上に朱の点 */
.icons--tools i{position:absolute; top:5px; right:1px; width:4px; height:4px; border-radius:50%; background:var(--aka); opacity:0; transition:opacity .6s ease}
.icons--tools .has i{opacity:1}
.icons--tools .muted i{background:var(--ink-3)}

/* 設定。蕩と同じく画面いっぱいの面 */
.sheet{position:fixed; inset:0; z-index:6; overflow-y:auto; -webkit-overflow-scrolling:touch;
  background:var(--ground) url(grain-soft.png) 0 0 / 256px 256px repeat;
  padding:calc(var(--sat) + 8px) 24px calc(var(--sab) + 32px)}
.sheet[hidden]{display:none}
.sheet-hd,.sheet-in{max-width:30rem; margin:0 auto}
.sheet-hd{position:sticky; top:0; z-index:1; display:flex; align-items:center; justify-content:space-between; padding:14px 0 10px;
  background:var(--ground) url(grain-soft.png) 0 0 / 256px 256px repeat}
.sheet-hd h2{margin:0; font-weight:300; font-size:17px; letter-spacing:.5em}
.sheet-hd button{padding:6px; margin-right:-6px}
.sheet-hd svg{width:32px; height:32px}
.sheet section{border-top:1px solid var(--rule); padding:20px 0 24px}
.sheet h3{margin:0 0 14px; font-size:12px; font-weight:300; color:var(--ink-2); letter-spacing:.3em}
.sheet h3 output{margin-left:.8em; color:var(--ink); font-variant-numeric:tabular-nums; letter-spacing:.08em}
.sheet label{display:block}
.sheet label + label{margin-top:18px}

.seg{display:flex; flex-wrap:wrap; gap:8px}
.seg button{padding:9px 16px; border:1px solid var(--rule); border-radius:999px; font-size:13px; color:var(--ink-2);
  transition:color .4s, border-color .4s, background .4s}
.seg button[aria-checked="true"]{color:var(--ink); border-color:var(--aka); background:rgba(240,135,90,.12)}
.seg--root{display:grid; grid-template-columns:repeat(6, 1fr)}
.seg--root button{padding:9px 0; text-align:center; letter-spacing:.04em}

input[type="range"]{-webkit-appearance:none; appearance:none; width:100%; height:28px; margin:0; background:transparent; font-size:16px}
input[type="range"]::-webkit-slider-runnable-track{height:1px; background:var(--ink-3)}
input[type="range"]::-moz-range-track{height:1px; background:var(--ink-3)}
input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none; width:18px; height:18px; margin-top:-9px; border-radius:50%; background:var(--ground); border:1.25px solid var(--ink)}
input[type="range"]::-moz-range-thumb{width:16px; height:16px; border-radius:50%; background:var(--ground); border:1.25px solid var(--ink)}

.layer{display:flex; align-items:center; gap:14px; padding:6px 0}
.layer + .layer{border-top:1px solid var(--rule)}
.layer svg{width:30px; height:30px}
.layer output{flex:1; font-size:13px; color:var(--ink-2); font-variant-numeric:tabular-nums}
.layer button{padding:7px; color:var(--ink-2); transition:color .4s, opacity .4s}
.layer button:disabled{opacity:.3; cursor:default}
.layer .cut{display:none}
.layer .m[aria-pressed="true"]{color:var(--aka)}
.layer .m[aria-pressed="true"] .cut{display:inline}
.layer .m[aria-pressed="true"] .wave{display:none}

/* 狭い画面：型3つ＋音色6つが1段に収まるよう、上の段だけ詰める */
@media (max-width:380px){
  .row--sub .icons button{padding:7px 3px 9px}
  .row--sub .icons svg{width:23px; height:23px}
  .row--sub .icons + .icons{margin-left:6px; padding-left:6px}
  .icons button[aria-checked="true"]::after{left:3px; width:calc(100% - 6px)}
  .icons--tools button[aria-checked="true"]::after{left:5px; width:calc(100% - 10px)}
}
@media (prefers-reduced-motion:reduce){ *{transition-duration:.01s !important} }
