:root {
  --bg: #f6f6f7; --card: #fff; --text: #111; --muted: #6b6b76; --line: #e3e3e8;
  --accent: #111; --accent-text: #fff; --danger: #c62828; --ok: #1b7f3b; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e10; --card: #17171a; --text: #eee; --muted: #8b8b96; --line: #2a2a30;
    --accent: #eee; --accent-text: #111; --danger: #ff6b6b; --ok: #5fd38a;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e10; --card: #17171a; --text: #eee; --muted: #8b8b96; --line: #2a2a30;
  --accent: #eee; --accent-text: #111; --danger: #ff6b6b; --ok: #5fd38a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.box { max-width: 720px; margin: 0 auto; padding: 16px; }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; gap: 12px; flex-wrap: wrap; }
header.top h1 { font-size: 18px; margin: 0; }
header.top nav { display: flex; gap: 12px; font-size: 14px; }
a { color: var(--text); }
h2 { font-size: 15px; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.msg { font-size: 14px; margin: 8px 0 0; min-height: 1em; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=url], input[type=search] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
button, .btn {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-decoration: none;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.small { padding: 4px 8px; font-size: 13px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.stack > * + * { margin-top: 10px; }
.drop {
  display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 40px 16px;
  text-align: center; color: var(--muted); cursor: pointer;
}
.drop.on { border-color: var(--accent); color: var(--text); }
.drop.locked { opacity: .5; cursor: not-allowed; }
.drop input { display: none; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1; min-width: 160px; }
.crumbs { font-size: 14px; margin-bottom: 12px; color: var(--muted); }
.crumbs a { color: var(--text); }
.item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.item .folder { cursor: pointer; font-weight: 600; }
.item .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; word-break: break-all; white-space: pre-wrap; }
.result { margin-top: 12px; }
.result .code { margin-bottom: 6px; }
.step { display: none; }
.step.active { display: block; }
details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details[open] summary { margin-bottom: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
dialog {
  width: min(92vw, 380px); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); padding: 18px; box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin-bottom: 4px; }
dialog p { margin: 0; }
dialog .row-actions button[value=ok] { order: 0; }
.badge { font-size: 11px; padding: 1px 7px; margin-left: 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-weight: 400; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--accent); color: var(--accent-text); padding: 9px 14px; border-radius: 999px; font-size: 14px;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { }
@media (max-width: 480px) {
  .box { padding: 16px; }
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; justify-content: flex-start; }
}
.tag {
  display: inline-block; font-size: 11px; line-height: 1.4; padding: 1px 8px; margin-bottom: 4px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted); align-self: flex-start;
}
.tag.mcp { color: var(--text); border-color: var(--text); }
.radio { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 6px 0 0; }
.radio input { width: auto; margin: 0; }
.item .main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.item .main > .name { max-width: 100%; }

.folder-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; margin: 8px 0; }
.folder-pick {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  text-align: left; border: 1px solid transparent; background: transparent; padding: 8px 12px;
}
.folder-pick:hover:not(:disabled) { border-color: var(--line); background: var(--bg); }
.folder-pick:disabled { opacity: 1; cursor: default; color: var(--muted); }
