:root{
  --canvas:#e8eaed;
  --chrome:#ffffff;
  --border:#dadce0;
  --text:#202124;
  --text-muted:#5f6368;
  --text-faint:#80868b;
  --blue:#1a73e8;
  --blue-bg:#e8f0fe;
  --hover:#f1f3f4;
  --red:#d93025;
  --red-bg:#fce8e6;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--canvas);
  color:var(--text);
  font-family:'Noto Sans JP', Arial, sans-serif;
  display:flex;
  flex-direction:column;
  min-height:100vh;
}

/* ---------- header (docs chrome) ---------- */
.docs-header{
  background:var(--chrome);
  border-bottom:1px solid var(--border);
  flex:0 0 auto;
}
.title-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 20px 4px;
}
.doc-icon{
  width:34px;height:34px;
  display:flex;align-items:center;justify-content:center;
  color:var(--blue);
  flex:0 0 auto;
}
#docTitle{
  font-size:18px;
  font-weight:500;
  color:var(--text);
  padding:4px 8px;
  border-radius:4px;
  outline:none;
  max-width:60%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
#docTitle:hover{background:var(--hover);}
#docTitle:focus{background:var(--chrome); box-shadow:inset 0 0 0 1.5px var(--blue);}
.save-status{
  margin-left:6px;
  display:flex;
  align-items:center;
  gap:7px;
  font-size:12.5px;
  color:var(--text-faint);
}
.save-status .dot{
  width:8px;height:8px;border-radius:50%;
  background:var(--text-faint);
  transition:background .2s ease;
}
.save-status.listening .dot{
  background:var(--red);
  animation:pulseDot 1.3s ease-in-out infinite;
}
.save-status.listening{color:var(--red);}
@keyframes pulseDot{
  0%,100%{transform:scale(1); opacity:1;}
  50%{transform:scale(1.3); opacity:.55;}
}

.toolbar-row{
  display:flex;
  align-items:center;
  gap:4px;
  padding:6px 16px 10px;
  flex-wrap:wrap;
}
.tb-divider{
  width:1px;height:26px;
  background:var(--border);
  margin:0 8px;
}
button.tb-btn{
  display:flex;
  align-items:center;
  gap:6px;
  background:transparent;
  border:none;
  color:var(--text-muted);
  padding:7px 12px;
  border-radius:6px;
  cursor:pointer;
  font-family:inherit;
  font-size:13.5px;
  font-weight:500;
  transition:background .12s ease, color .12s ease;
}
button.tb-btn:hover{background:var(--hover);}
button.tb-btn:focus-visible{outline:2px solid var(--blue); outline-offset:1px;}
button.tb-btn svg{width:19px;height:19px; flex:0 0 auto;}
button.tb-btn.icon-only{padding:7px;}
button.tb-btn:disabled{opacity:.35; cursor:not-allowed;}

button#toggleBtn{
  background:var(--blue-bg);
  color:var(--blue);
}
button#toggleBtn.recording{
  background:var(--red-bg);
  color:var(--red);
}
button#toggleBtn .icon-mic{display:inline-flex;}
button#toggleBtn .icon-stop{display:none;}
button#toggleBtn.recording .icon-mic{display:none;}
button#toggleBtn.recording .icon-stop{display:inline-flex;}

select#langSelect{
  background:var(--chrome);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:6px;
  padding:7px 10px;
  font-family:inherit;
  font-size:13px;
  cursor:pointer;
}
select#langSelect:hover{background:var(--hover);}
select#langSelect:focus-visible{outline:2px solid var(--blue); outline-offset:1px;}

/* ---------- canvas + page ---------- */
.docs-canvas{
  flex:1;
  overflow-y:auto;
  display:flex;
  justify-content:center;
  padding:28px 20px 80px;
}
.page{
  background:#ffffff;
  width:100%;
  max-width:816px;
  min-height:600px;
  padding:88px 96px;
  box-shadow:0 1px 2px 0 rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15);
  border-radius:1px;
}
#placeholder{
  color:var(--text-faint);
  font-size:14.5px;
  line-height:1.9;
  font-style:italic;
  max-width:52ch;
  margin:0;
}

.para{
  font-size:15.5px;
  line-height:1.85;
  color:var(--text);
  margin:0 0 4px;
  position:relative;
  padding-left:52px;
}
.para .ts{
  position:absolute;
  left:0;
  top:2px;
  width:42px;
  font-size:11px;
  color:var(--text-faint);
  font-variant-numeric:tabular-nums;
  user-select:none;
}
.para .body{
  outline:none;
  border-radius:3px;
  padding:1px 4px;
  margin:0 -4px;
  white-space:pre-wrap;
  word-break:break-word;
  transition:background .15s ease;
}
.para .body[contenteditable="true"]:hover{
  background:var(--hover);
}
.para .body[contenteditable="true"]:focus{
  background:var(--blue-bg);
  box-shadow:0 0 0 1.5px var(--blue);
}
.para .body.edited{
  animation:editFlash 1s ease-out;
}
@keyframes editFlash{
  0%{background:#fff3cd; box-shadow:0 0 0 1.5px #f2c94c;}
  100%{background:transparent; box-shadow:0 0 0 0 transparent;}
}

.para.interim .ts{color:var(--text-faint);}
.para.interim .body{
  color:var(--text-faint);
  font-style:italic;
}

#toast{
  position:fixed;
  bottom:28px;
  left:50%;
  transform:translateX(-50%) translateY(8px);
  background:#323232;
  color:#fff;
  padding:10px 18px;
  border-radius:6px;
  font-size:13px;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease, transform .2s ease;
  z-index:50;
  box-shadow:0 2px 6px rgba(0,0,0,.3);
}
#toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

#unsupported{
  margin:auto;
  max-width:480px;
  text-align:center;
  padding:32px;
  color:var(--text-muted);
  font-size:14px;
  line-height:1.8;
}

@media (max-width: 680px){
  .title-row{padding:8px 12px 2px;}
  #docTitle{font-size:15px; max-width:45%;}
  .toolbar-row{padding:6px 8px 8px;}
  .docs-canvas{padding:14px 8px 60px;}
  .page{padding:40px 22px; min-height:0;}
  .para{padding-left:0;}
  .para .ts{position:static; display:block; margin-bottom:2px;}
}

@media (prefers-reduced-motion: reduce){
  .save-status.listening .dot{animation:none;}
  .para .body.edited{animation:none;}
}
