:root {
  --blue: #0b57d0;
  --blue-dark: #0842a0;
  --blue-soft: #e8f0fe;
  --ink: #1f1f1f;
  --ink-2: #444746;
  --ink-3: #747775;
  --line: #e1e3e1;
  --bg: #ffffff;
  --bg-soft: #f8fafd;
  --danger: #b3261e;
  --danger-soft: #f9dedc;
  --ok: #146c2e;
  --ok-soft: #ceead6;
  --thumb-bg: #eef1f4;
  --drop-bg: rgba(232,240,254,.92);
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60,64,67,.15), 0 4px 16px rgba(60,64,67,.12);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --blue: #a8c7fa;
  --blue-dark: #c2d9fb;
  --blue-soft: #004a77;
  --ink: #e3e3e3;
  --ink-2: #c4c7c5;
  --ink-3: #9aa0a6;
  --line: #444746;
  --bg: #131314;
  --bg-soft: #1e1f20;
  --danger: #f2b8b5;
  --danger-soft: #5f1a15;
  --ok: #7ddb92;
  --ok-soft: #0d3b1e;
  --thumb-bg: #28292a;
  --drop-bg: rgba(19,19,20,.92);
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 4px 16px rgba(0,0,0,.45);
  color-scheme: dark;
}
:root[data-theme="solarized-light"] {
  --blue: #268bd2;
  --blue-dark: #1a6cae;
  --blue-soft: #eee8d5;
  --ink: #586e75;
  --ink-2: #657b83;
  --ink-3: #93a1a1;
  --line: #ded6bf;
  --bg: #fdf6e3;
  --bg-soft: #f7efdb;
  --danger: #dc322f;
  --danger-soft: #f8dcc9;
  --ok: #859900;
  --ok-soft: #e9eecb;
  --thumb-bg: #eee8d5;
  --drop-bg: rgba(253,246,227,.93);
  --shadow: 0 1px 2px rgba(88,110,117,.18), 0 4px 16px rgba(88,110,117,.14);
  color-scheme: light;
}
:root[data-theme="solarized-dark"] {
  --blue: #6db3e8;
  --blue-dark: #9ccbf2;
  --blue-soft: #073642;
  --ink: #93a1a1;
  --ink-2: #839496;
  --ink-3: #657b83;
  --line: #0e4353;
  --bg: #002b36;
  --bg-soft: #073642;
  --danger: #f08a87;
  --danger-soft: #571f1c;
  --ok: #a9c234;
  --ok-soft: #274217;
  --thumb-bg: #073642;
  --drop-bg: rgba(0,43,54,.93);
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 4px 16px rgba(0,0,0,.4);
  color-scheme: dark;
}
.btn.primary { color: #fff; }
:root[data-theme="dark"] .btn.primary,
:root[data-theme="solarized-dark"] .btn.primary { color: #0b2a4a; }
.theme-select {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px;
  background: var(--bg); color: var(--ink-2); max-width: 170px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: var(--blue); }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; white-space: nowrap; }
.logo svg { width: 26px; height: 26px; }
.search-pill {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-soft); border: 1px solid transparent; border-radius: 999px; padding: 8px 16px;
}
.search-pill:focus-within { background: var(--bg); border-color: var(--line); box-shadow: var(--shadow); }
.search-pill input { border: none; outline: none; background: transparent; flex: 1; font-size: 14px; }
.search-pill svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bucket-chip { color: var(--ink-2); font-size: 13px; background: var(--bg-soft); border-radius: 999px; padding: 6px 12px; }

.btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 999px; padding: 8px 16px; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-soft); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  border: none; background: transparent; border-radius: 999px; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2);
}
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.active { background: var(--blue-soft); color: var(--blue); }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 4px;
}
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 15px; padding: 8px 20px 0; }
.crumb { border: none; background: none; padding: 4px 8px; border-radius: 8px; color: var(--ink-2); }
.crumb:hover { background: var(--bg-soft); }
.crumb.current { color: var(--ink); font-weight: 600; }
.crumb-sep { color: var(--ink-3); }
.toolbar .spacer { flex: 1; }
.sort-select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); color: var(--ink-2); }

.content { padding: 12px 20px 90px; }
.empty-note { color: var(--ink-3); text-align: center; padding: 60px 0; font-size: 14px; }
.loading-note { color: var(--ink-3); text-align: center; padding: 60px 0; }

/* ---------- grid / list ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft);
  overflow: hidden; cursor: pointer; position: relative;
}
.card:hover { box-shadow: var(--shadow); }
.card .thumb {
  height: 104px; display: flex; align-items: center; justify-content: center; background: var(--thumb-bg);
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb svg { width: 44px; height: 44px; }
.card .meta { padding: 8px 10px 10px; background: var(--bg); }
.card .name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.type-folder { color: #f9ab00; }
.type-image { color: #188038; }
.type-video { color: #9334e6; }
.type-audio { color: #e37400; }
.type-pdf { color: #d93025; }
.type-text { color: #0b57d0; }
.type-file { color: #747775; }

.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px; cursor: pointer;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-soft); }
.row svg { width: 22px; height: 22px; flex: none; }
.row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row .col { width: 130px; color: var(--ink-3); font-size: 12px; flex: none; }
.row .col.size { width: 90px; text-align: right; }

/* context menu */
.menu {
  position: fixed; z-index: 60; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 6px; min-width: 210px;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: none; background: none; padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.menu button:hover { background: var(--bg-soft); }
.menu button svg { width: 16px; height: 16px; color: var(--ink-2); }
.menu button.danger { color: var(--danger); }
.menu button.danger svg { color: var(--danger); }

/* ---------- connection screen ---------- */
.connect-wrap { max-width: 640px; margin: 0 auto; padding: 36px 20px 60px; }
.connect-wrap h1 { font-size: 22px; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.connect-wrap h1 svg { width: 30px; height: 30px; }
.lead { color: var(--ink-2); margin: 0 0 22px; line-height: 1.7; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; background: var(--bg); }
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.6; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; background: var(--bg);
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.field input[readonly] { background: var(--bg-soft); color: var(--ink-2); }
.checkcode { font-family: ui-monospace, monospace; background: var(--bg-soft); border-radius: 6px; padding: 1px 7px; }
.msg { border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.6; margin: 12px 0; display: none; }
.msg.show { display: block; }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.info { background: var(--blue-soft); color: var(--blue-dark); }
.codebox {
  background: #202124; color: #e8eaed; border-radius: 10px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55;
  white-space: pre; overflow-x: auto; margin: 8px 0;
}
.origin-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.origin-line code { background: var(--bg-soft); padding: 3px 8px; border-radius: 6px; font-size: 12px; word-break: break-all; }
.small-note { font-size: 12px; color: var(--ink-3); line-height: 1.7; }

/* ---------- modal / toast ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(32,33,36,.55); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: var(--bg); border-radius: 20px; max-width: 860px; width: 100%; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.modal.small-modal { max-width: 460px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-head .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px; overflow: auto; }
.modal-body.flush { padding: 0; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.preview-media { background: #202124; display: flex; align-items: center; justify-content: center; min-height: 300px; }
.preview-media img { max-width: 100%; max-height: 74vh; }
.preview-media img.zoomed { max-width: none; cursor: zoom-out; }
.preview-media video { max-width: 100%; max-height: 74vh; }
.preview-media audio { width: 80%; }
.preview-media iframe { width: 100%; height: 74vh; border: none; background: var(--bg); }
.preview-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all; padding: 18px; max-height: 74vh; overflow: auto; margin: 0;
}
.md-body { padding: 18px 22px; line-height: 1.8; max-height: 74vh; overflow: auto; }
.md-body h1, .md-body h2, .md-body h3 { line-height: 1.4; }
.md-body pre { background: var(--bg-soft); padding: 12px; border-radius: 8px; overflow-x: auto; }
.md-body code { background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.md-body pre code { background: none; padding: 0; }
.share-url { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; word-break: break-all; font-size: 12px; }

#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  background: #202124; color: #e8eaed; border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.6;
}
.toast.error { background: var(--danger); color: #fff; }
.toast .t-title { font-weight: 600; margin-bottom: 2px; }
.progress-line { background: rgba(255,255,255,.25); border-radius: 99px; height: 6px; margin-top: 8px; overflow: hidden; }
.progress-line > div { background: #8ab4f8; height: 100%; transition: width .2s; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 70; background: var(--drop-bg);
  display: none; align-items: center; justify-content: center;
  border: 3px dashed var(--blue); font-size: 18px; color: var(--blue); font-weight: 600;
}
.drop-overlay.show { display: flex; }

@media (max-width: 640px) {
  .row .col.date { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .bucket-chip { display: none; }
}
