:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #8b93a5;
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --accent-text: #ffffff;
  --danger: #ff5c6c;
  --ok: #3ecf8e;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --border: #dfe2e8;
    --text: #1a1d24;
    --muted: #6b7280;
    --accent: #3d6df2;
    --accent-2: #2f5ad6;
    --danger: #e0384a;
    --shadow: 0 8px 30px rgba(20, 30, 50, .12);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.5em; margin: 8px 0 0; font-size: 14px; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  transition: background .15s, border-color .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.icon { width: 42px; padding: 0; font-size: 18px; background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }

input[type=password], input[type=search], input[type=text] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* iOS のズーム防止 */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

/* Boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-view { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 20px; text-align: center;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-card p.muted { margin: 0 0 18px; }
.login-card input { margin-bottom: 12px; }
.logo {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #a26bff); color: #fff;
}
.logo.sm { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; margin: 0; flex: none; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 700; }
.topbar-actions { display: flex; gap: 6px; flex: none; }

.container { max-width: 960px; margin: 0 auto; padding: 16px; padding-bottom: max(32px, env(safe-area-inset-bottom)); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.drop-zone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.drop-icon { font-size: 24px; color: var(--muted); }
.drop-text { margin: 4px 0 12px; color: var(--muted); }
.pc-only, .drop-text { display: none; }
@media (hover: hover) and (pointer: fine) {
  .pc-only { display: inline; }
  .drop-text { display: block; }
  .drop-zone { padding: 32px 16px; }
}

/* Upload list */
.upload-list { display: grid; gap: 10px; margin-top: 12px; }
.upload-list:empty { display: none; }
.up-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.up-row { display: flex; align-items: center; gap: 10px; }
.up-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-stats { margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s; }
.up-item.done .bar > div { background: var(--ok); }
.up-item.failed .bar > div { background: var(--danger); }
.up-item.failed .up-stats { color: var(--danger); }

/* Search */
.search-row { margin: 20px 0 12px; }

/* File list */
.file-list { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .file-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .file-list { grid-template-columns: repeat(3, 1fr); } }
.card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; min-width: 0;
  cursor: pointer; transition: border-color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.card:hover { border-color: var(--muted); }
.card:active { transform: scale(.99); }
.thumb {
  flex: none; width: 48px; height: 48px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); color: var(--accent);
}
.thumb.other { background: var(--surface-2); color: var(--muted); }
.card-body { flex: 1; min-width: 0; }
.card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 4px; flex: none; }
.card-actions .btn.icon { width: 38px; min-height: 38px; font-size: 16px; color: var(--muted); }
.card-actions .btn.icon.del:hover { color: var(--danger); border-color: var(--danger); }
.empty { text-align: center; padding: 32px 0; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .7); }
.modal-panel {
  position: relative; width: 100%; max-width: 900px; max-height: 100%;
  overflow-y: auto; background: var(--surface);
  padding: 12px 16px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .modal { padding: 24px; }
  .modal-panel { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
}
@media (max-width: 699px) {
  .modal { align-items: flex-end; }
  .modal-panel { border-radius: var(--radius) var(--radius) 0 0; }
}
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.modal-title { flex: 1; min-width: 0; margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.player-media video {
  display: block; width: 100%; max-height: 70vh; max-height: 70dvh;
  background: #000; border-radius: 10px;
}
.player-media .no-preview {
  padding: 32px 16px; text-align: center; background: var(--surface-2);
  border-radius: 10px; color: var(--muted);
}
.modal-meta { margin: 10px 0; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
@media (min-width: 700px) { .modal-actions .btn { flex: none; min-width: 140px; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 100;
  max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow);
}

/* 中断・再開待ち */
.up-item.paused .bar > div { background: #e0a030; }
.up-item.paused .up-stats { color: #c88a1c; }
.up-row .btn + .btn { margin-left: -4px; }
