:root{
  color-scheme:dark light;
  --bg:#121315;
  --surface:#191b1e;
  --surface-2:#212429;
  --surface-hover:#272b31;
  --border:#2d3138;
  --border-strong:#3f454f;
  --text:#ecebe8;
  --text-muted:#9ca2ab;
  --accent:#2f8a6e;
  --accent-hover:#379f7f;
  --accent-soft:rgba(47,138,110,.16);
  --accent-border:rgba(55,159,127,.55);
  --accent-text:#ffffff;
  --focus:#e6a23c;
  --radius-lg:14px;
  --radius-md:10px;
  --radius-sm:8px;
  --font-sans:system-ui,-apple-system,"Segoe UI","Hiragino Sans","Yu Gothic UI","Meiryo",sans-serif;
  --font-mono:ui-monospace,"Cascadia Mono","SFMono-Regular",Consolas,"Yu Gothic UI",monospace;
}
@media (prefers-color-scheme:light){
  :root{
    --bg:#f2f2ef;
    --surface:#ffffff;
    --surface-2:#f6f6f3;
    --surface-hover:#efefeb;
    --border:#dcdcd6;
    --border-strong:#bdbdb5;
    --text:#1b1d1c;
    --text-muted:#575c59;
    --accent:#1f654e;
    --accent-hover:#18523f;
    --accent-soft:rgba(31,101,78,.09);
    --accent-border:rgba(31,101,78,.45);
    --accent-text:#ffffff;
    --focus:#c77710;
  }
}
*,*::before,*::after{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:400 15px/1.6 var(--font-sans);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
main{
  max-width:1080px;
  margin:0 auto;
  padding:clamp(24px,4.5vw,48px) clamp(16px,3.5vw,32px) clamp(40px,6vw,64px);
  display:grid;
  grid-template-columns:minmax(0,1fr);
  gap:20px;
}
.app-header{
  padding-bottom:18px;
  border-bottom:1px solid var(--border);
}
h1{
  margin:0;
  font-size:clamp(24px,3.2vw,34px);
  font-weight:700;
  letter-spacing:-.025em;
  line-height:1.15;
}
.lead{
  margin:8px 0 0;
  color:var(--text-muted);
  font-size:14px;
  line-height:1.75;
}
.workbench{
  display:grid;
  grid-template-columns:minmax(0,1fr);
  gap:20px;
  align-items:start;
}
@media (min-width:860px){
  .workbench{
    grid-template-columns:minmax(320px,390px) minmax(0,1fr);
    gap:24px;
  }
}
section{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:clamp(18px,2.8vw,26px);
}
fieldset{
  border:0;
  margin:0;
  padding:0;
  min-width:0;
}
fieldset:disabled{
  opacity:.65;
}
legend,h2{
  display:block;
  width:100%;
  margin:0 0 16px;
  padding:0;
  font-size:13px;
  font-weight:700;
  letter-spacing:.06em;
  color:var(--text-muted);
}
.mode-group{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
  margin-bottom:16px;
}
.mode-group label{
  display:flex;
  align-items:center;
  gap:9px;
  min-height:44px;
  padding:10px 12px;
  margin:0;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:border-color .15s ease,background-color .15s ease;
}
.mode-group label:hover{
  border-color:var(--border-strong);
  background:var(--surface-hover);
}
.mode-group label:has(input:checked){
  border-color:var(--accent-border);
  background:var(--accent-soft);
}
.mode-group label:has(input:focus-visible){
  outline:2px solid var(--focus);
  outline-offset:2px;
}
.mode-group label:has(input:disabled){
  cursor:default;
}
input[type="radio"],
input[type="checkbox"]{
  width:16px;
  height:16px;
  margin:0;
  accent-color:var(--accent);
  flex-shrink:0;
  cursor:pointer;
}
input:disabled{
  cursor:default;
}
#naming{
  display:grid;
  gap:12px;
  padding:14px;
  margin-bottom:16px;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--surface-2);
}
#naming label{
  display:flex;
  align-items:center;
  gap:9px;
  margin:0;
  font-size:14px;
  cursor:pointer;
}
.suffix-field{
  display:grid!important;
  gap:6px;
  font-size:13px!important;
  color:var(--text-muted);
  cursor:default!important;
}
#suffix{
  width:100%;
  min-height:40px;
  padding:8px 12px;
  border-radius:var(--radius-sm);
  border:1px solid var(--border-strong);
  background:var(--surface);
  color:var(--text);
  font:500 14px/1.4 var(--font-mono);
  transition:border-color .15s ease;
}
#suffix:hover:not(:disabled){
  border-color:var(--text-muted);
}
#suffix:disabled{
  opacity:.5;
}
#preview{
  margin:0;
  padding:8px 10px;
  border-radius:var(--radius-sm);
  background:var(--surface);
  border:1px solid var(--border);
  color:var(--text-muted);
  font:400 12.5px/1.5 var(--font-mono);
  overflow-wrap:anywhere;
}
#preview:empty,
#hint:empty{
  display:none;
}
#hint{
  margin:0 0 16px;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  border-left:3px solid var(--border-strong);
  background:var(--surface-2);
  color:var(--text-muted);
  font-size:13px;
  line-height:1.55;
}
.source-actions{
  display:grid;
  gap:10px;
}
button{
  appearance:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  padding:10px 16px;
  border-radius:var(--radius-md);
  border:1px solid var(--border-strong);
  background:var(--surface-2);
  color:var(--text);
  font:600 14px/1.3 var(--font-sans);
  cursor:pointer;
  transition:background-color .15s ease,border-color .15s ease,color .15s ease,opacity .15s ease;
}
button:hover:not(:disabled){
  background:var(--surface-hover);
  border-color:var(--text-muted);
}
button:active:not(:disabled){
  transform:translateY(1px);
}
button:disabled{
  opacity:.42;
  cursor:default;
}
#pick{
  width:100%;
  background:var(--surface-hover);
  border-color:var(--border-strong);
}
#downloadMode{
  width:100%;
  background:transparent;
  border-color:var(--border);
  color:var(--text-muted);
  font-weight:500;
}
#downloadMode:hover:not(:disabled){
  color:var(--text);
  background:var(--surface-2);
  border-color:var(--border-strong);
}
.queue-panel{
  display:flex;
  flex-direction:column;
  min-height:260px;
}
#list{
  max-height:52vh;
  overflow:auto;
  margin:0 0 16px;
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  background:var(--surface-2);
}
#list:empty{
  display:none;
}
#list article{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:8px 16px;
  flex-wrap:wrap;
  padding:11px 14px;
  border-top:1px solid var(--border);
  transition:background-color .12s ease;
}
#list article:first-child{
  border-top:0;
}
#list article:hover{
  background:var(--surface-hover);
}
#list article label{
  flex:1 1 220px;
  display:inline-flex;
  align-items:flex-start;
  gap:10px;
  margin:0;
  font-size:14px;
  line-height:1.45;
  overflow-wrap:anywhere;
  cursor:pointer;
}
#list article label input[type="checkbox"]{
  margin-top:2px;
}
#list article small{
  flex-shrink:0;
  color:var(--text-muted);
  font:400 12.5px/1.4 var(--font-mono);
  font-variant-numeric:tabular-nums;
}
a{
  color:var(--accent-hover);
  font:600 13.5px/1.4 var(--font-sans);
  text-decoration:underline;
  text-underline-offset:3px;
}
a:hover{
  color:var(--text);
}
.queue-footer{
  margin-top:auto;
  display:grid;
  gap:12px;
}
#status{
  display:block;
  margin:0;
  padding:12px 14px;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text-muted);
  font-size:13.5px;
  line-height:1.5;
  overflow-wrap:anywhere;
}
#progress{
  appearance:none;
  width:100%;
  height:8px;
  border:0;
  border-radius:999px;
  overflow:hidden;
  background:var(--surface-2);
  accent-color:var(--accent);
}
#progress::-webkit-progress-bar{
  background:var(--surface-2);
  border-radius:999px;
}
#progress::-webkit-progress-value{
  background:var(--accent);
  border-radius:999px;
  transition:width .18s ease;
}
#progress::-moz-progress-bar{
  background:var(--accent);
  border-radius:999px;
}
#run{
  width:100%;
  min-height:48px;
  background:var(--accent);
  border-color:var(--accent);
  color:var(--accent-text);
  font-size:15px;
  font-weight:700;
  letter-spacing:.02em;
}
#run:hover:not(:disabled){
  background:var(--accent-hover);
  border-color:var(--accent-hover);
}
@media (min-width:640px){
  .queue-footer{
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
  }
  #progress{
    grid-column:1 / -1;
  }
  #run{
    width:auto;
    min-width:176px;
    padding:10px 24px;
  }
}
button:focus-visible,
input:focus-visible,
a:focus-visible{
  outline:2px solid var(--focus);
  outline-offset:2px;
}
.mode-group input:focus-visible{
  outline:none;
}
@media (prefers-reduced-motion:reduce){
  *{transition:none!important}
  button:active:not(:disabled){transform:none}
}


#dropZone{padding:20px 16px;margin-bottom:18px;border:2px dashed var(--border-strong);border-radius:12px;text-align:center;background:var(--surface-2)}
#dropZone.active{border-color:var(--accent);background:var(--accent-soft)}
#dropZone p{margin:0 0 12px}
#dropZone .source-actions{display:flex;justify-content:center;flex-wrap:wrap}
#dropZone button{width:auto}


#status{margin-bottom:14px}
#status[data-state]{border-inline-start:5px solid var(--accent)}
#status[data-state="saved"]{background:var(--accent);border-color:var(--accent);color:#09100d}
#status[data-state="saved"] strong{color:inherit}
#status[data-state="saved"] strong::before{content:"✓";margin-inline-end:.45em}
@media (prefers-color-scheme:light){#status[data-state="saved"]{color:white}}
#status[data-state="warning"]{border-inline-start-color:#d29940}
#status strong,#status span{display:block}
#status strong{font:700 1.2rem/1.5 var(--font-sans);color:var(--text)}
#status span{margin-top:3px;overflow-wrap:anywhere}
