:root {
  --bg: #0b1014;
  --bg-2: #101820;
  --panel: #141e27;
  --panel-2: #18242f;
  --line: #243340;
  --line-2: #2e4050;
  --text: #e6edf3;
  --muted: #8fa3b3;
  --faint: #5f7281;
  --accent: #35e0b0;
  --accent-2: #7cf0cd;
  --accent-dim: rgba(53, 224, 176, .12);
  --blue: #56a8ff;
  --amber: #ffc857;
  --red: #ff6b6b;
  --violet: #b79cff;
  --radius: 14px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(53, 224, 176, .07), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(86, 168, 255, .05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

.app { display: flex; min-height: 100vh; }

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 24, 32, .96), rgba(11, 16, 20, .96));
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 20px;
}
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #189c7a);
  color: #04120d;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 6px 22px rgba(53, 224, 176, .25);
}
.brand-title { font-weight: 700; letter-spacing: .02em; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: var(--faint); font-family: var(--mono); letter-spacing: .1em; }

.nav-group { margin-top: 14px; }
.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--faint);
  padding: 0 12px 7px;
  font-family: var(--mono);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-link.active {
  background: var(--accent-dim);
  border-color: rgba(53, 224, 176, .25);
  color: var(--accent-2);
  font-weight: 600;
}
.nav-icon { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  background: rgba(255,255,255,.05);
  padding: 1px 6px;
  border-radius: 20px;
}
.sidebar-foot {
  margin-top: 24px;
  padding: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.7;
}
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--accent); box-shadow: 0 0 8px rgba(53,224,176,.7); }
.dot.bad { background: var(--red); }

.install-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 16px);
  margin: 18px 8px 0;
  padding: 9px 10px;
  border: 1px dashed rgba(53,224,176,.35);
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent-2);
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.install-btn:hover { background: rgba(53,224,176,.18); border-style: solid; }
.install-btn.ready { border-style: solid; box-shadow: 0 0 0 3px rgba(53,224,176,.08); }
.install-btn.hidden { display: none; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3,7,10,.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: min(560px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal h3 { margin: 0 0 10px; font-size: 18px; }
.modal p, .modal li { font-size: 13.5px; color: var(--muted); line-height: 1.7; }
.modal ol { margin: 10px 0 0 20px; padding: 0; }
.modal .modal-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.modal .secure-note { border-left: 2px solid var(--amber); background: rgba(255,200,87,.05); padding: 8px 12px; border-radius: 0 8px 8px 0; color: #d8c69a; font-size: 12px; margin-top: 12px; }

/* ------------------------------------------------------------------ main */

.main { flex: 1; min-width: 0; padding: 30px 38px 60px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
h1 { font-size: 27px; margin: 0 0 6px; letter-spacing: -.01em; line-height: 1.25; }
.page-desc { color: var(--muted); margin: 0; max-width: 720px; font-size: 14px; }
.page-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 20px;
}
.chip strong { color: var(--text); font-weight: 600; }
.chip.ok { color: var(--accent); border-color: rgba(53,224,176,.3); background: rgba(53,224,176,.07); }

.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 22px; align-items: start; }
.layout.single { grid-template-columns: minmax(0, 1fr); }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.16);
}
.card + .card { margin-top: 20px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; font-size: 14px; font-weight: 650; letter-spacing: .01em; }
.card-title .hint { font-size: 11.5px; color: var(--faint); font-weight: 400; font-family: var(--mono); }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
label .req { color: var(--amber); }
.url-input {
  width: 100%;
  font-size: 16px;
  padding: 13px 14px;
  min-height: 52px;
  font-family: var(--mono);
  letter-spacing: .01em;
  line-height: 1.45;
}
input[type=text], input[type=number], input[type=url], select {
  width: 100%;
  background: #0d151b;
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=number]:focus, input[type=url]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53,224,176,.12);
}
input::placeholder { color: var(--faint); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.help { font-size: 11.5px; color: var(--faint); margin-top: 5px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text); cursor: pointer; margin-bottom: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ------------------------------------------------------------------ dropzone */

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: 12px;
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: rgba(255,255,255,.012);
  margin-bottom: 14px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-dim); }
.dropzone .dz-icon { font-size: 26px; line-height: 1; margin-bottom: 8px; opacity: .8; }
.dropzone .dz-main { font-size: 14px; color: var(--text); }
.dropzone .dz-sub { font-size: 11.5px; color: var(--faint); margin-top: 4px; font-family: var(--mono); }
.dropzone.has-files { border-style: solid; border-color: rgba(53,224,176,.35); }

.file-list { list-style: none; padding: 0; margin: 0 0 4px; }
.file-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  background: #0d151b;
  font-size: 13px;
}
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.file-list .fsize { color: var(--faint); font-size: 11px; font-family: var(--mono); }
.file-list .fdel { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; padding: 0 2px; }
.file-list .fdel:hover { color: var(--red); }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--sans);
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { background: #1d2b38; border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #22b98e); border-color: transparent; color: #04120d; }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: rgba(255,107,107,.3); background: rgba(255,107,107,.06); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

/* ------------------------------------------------------------------ progress */

.progress { height: 6px; border-radius: 6px; background: #0a1116; overflow: hidden; margin: 12px 0 4px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--blue)); transition: width .2s; }
.upload-state { font-size: 11.5px; color: var(--faint); font-family: var(--mono); display: flex; justify-content: space-between; }

/* ------------------------------------------------------------------ status */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.queued { color: var(--amber); background: rgba(255,200,87,.09); border-color: rgba(255,200,87,.25); }
.badge.running { color: var(--blue); background: rgba(86,168,255,.1); border-color: rgba(86,168,255,.28); }
.badge.succeeded { color: var(--accent); background: rgba(53,224,176,.1); border-color: rgba(53,224,176,.28); }
.badge.failed { color: var(--red); background: rgba(255,107,107,.1); border-color: rgba(255,107,107,.28); }
.badge.canceled { color: var(--muted); background: rgba(143,163,179,.1); border-color: rgba(143,163,179,.25); }
.badge.running::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ------------------------------------------------------------------ console */

.console {
  background: #070c10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  height: 320px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: #b9cbd8;
  white-space: pre-wrap;
  word-break: break-all;
  scrollbar-width: thin;
}
.console:empty::before { content: "ログはまだありません。"; color: var(--faint); }
.console .ln { display: block; }
.console .ln .t { color: #44596a; margin-right: 8px; user-select: none; }
.console .ln.err { color: #ff9a9a; }
.console .ln.sys { color: var(--accent); }
.console.tall { height: 430px; }

/* ------------------------------------------------------------------ jobs */

.job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.job-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.job-sub { color: var(--faint); font-size: 11.5px; font-family: var(--mono); margin-top: 3px; }
.empty { color: var(--faint); font-size: 13px; padding: 22px 0; text-align: center; }

.outputs { list-style: none; padding: 0; margin: 12px 0 0; }
.outputs li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.outputs .oname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.outputs a.oname:hover { color: var(--accent); text-decoration: underline; }
.outputs a.oname::after { content: "  ↓"; color: var(--faint); font-family: var(--mono); }
.outputs .osize { color: var(--faint); font-size: 11px; font-family: var(--mono); }

/* ------------------------------------------------------------------ dashboard */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-family: var(--mono); }
.stat .v { font-size: 30px; font-weight: 700; margin-top: 4px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--faint); font-weight: 500; margin-left: 3px; }
.stat.accent .v { color: var(--accent); }
.stat.amber .v { color: var(--amber); }
.stat.blue .v { color: var(--blue); }

.worker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.worker {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: var(--panel); position: relative; overflow: hidden;
}
.worker.busy { border-color: rgba(86,168,255,.35); background: linear-gradient(180deg, rgba(86,168,255,.07), var(--panel)); }
.worker .wtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.worker .wname { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .1em; text-transform: uppercase; }
.worker .wjob { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker .wmeta { font-size: 11px; color: var(--faint); font-family: var(--mono); margin-top: 3px; }
.worker .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); }
.worker.busy .bar { background: linear-gradient(90deg, var(--blue), transparent); animation: slide 2s linear infinite; }
@keyframes slide { from { transform: translateX(-100%);} to { transform: translateX(100%);} }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-family: var(--mono); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid rgba(36,51,64,.6); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody tr.selected { background: rgba(53,224,176,.06); }
td.mono { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
td .jtitle { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.dim { color: var(--faint); font-family: var(--mono); font-size: 11px; white-space: nowrap; }

.image-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.image-chip { display: flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0e161d; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.image-chip .st { font-size: 10px; }
.image-chip.ready { color: var(--text); border-color: rgba(53,224,176,.25); }

.note { border-left: 2px solid var(--amber); background: rgba(255,200,87,.05); padding: 10px 14px; border-radius: 0 8px 8px 0; color: #d8c69a; font-size: 12.5px; margin-top: 14px; }
.note strong { color: var(--amber); }

/* ------------------------------------------------------------------ misc */

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast .t { background: #1b2833; border: 1px solid var(--line-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.4); max-width: 380px; animation: in .18s ease-out; }
.toast .t.bad { border-left-color: var(--red); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.hidden { display: none !important; }

@media (max-width: 1280px) {
  .worker-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 24px 22px 50px; }
}
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px; }
  .brand { padding-bottom: 12px; }
  .nav-group { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
  .nav-label { width: 100%; padding: 4px 6px; }
  .nav-link { padding: 7px 10px; margin: 0; }
  .nav-badge { display: none; }
  .sidebar-foot { display: none; }
  .worker-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 24px; }
}
