:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e3e6eb;
  --accent: #2557d6;
  --accent-hover: #1d47b3;
  --danger: #c4314b;
  --success: #1f7a4d;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; }
.user { display: flex; gap: 16px; align-items: center; font-size: 14px; color: var(--muted); }

.container { max-width: 1000px; margin: 32px auto; padding: 0 16px; display: grid; gap: 20px; }
.container.narrow { max-width: 560px; margin-top: 64px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; }
.success { color: var(--success); font-weight: 600; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 140px; padding: 16px; border: 2px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; word-break: break-all;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #f0f4ff; }
.drop.has-file { border-style: solid; color: var(--text); font-weight: 600; }

.options { display: flex; gap: 16px; margin: 16px 0; flex-wrap: wrap; }
.options label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 16px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; }
.check .muted { font-size: 13px; }

select, input {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer;
}
button:hover { background: #f3f4f6; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.small { padding: 4px 10px; font-size: 13px; }
button.danger { color: var(--danger); }

.progress { margin-top: 16px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.field { margin: 12px 0; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .12em; }
.code.big { width: 100%; font-size: 24px; text-align: center; padding: 12px; margin-bottom: 12px; }
#form button { width: 100%; padding: 12px; }

video { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: 8px; }
.notice { background: #fff8e6; border: 1px solid #f3dfa8; border-radius: 8px; padding: 12px; font-size: 14px; }

.row-between { display: flex; justify-content: space-between; align-items: center; }
.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px 6px; }
.files td { border-bottom: 1px solid var(--line); padding: 8px 6px; }
.files td.name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files td.actions { white-space: nowrap; text-align: right; }
.files td.actions button + button { margin-left: 6px; }
/* フォルダーの中身 */
.files tr.child td { background: #fafafa; font-size: 13px; }
.files tr.child td.name { padding-left: 28px; max-width: 360px; }
.files td.dir { color: var(--muted); font-size: 13px; padding-top: 12px; border-bottom: none; }
.files td.name.nested { padding-left: 20px; }
.files td.actions.muted { font-size: 13px; }
.pick-dir { margin: 8px 0 0; font-size: 13px; }
.pick-dir button { margin-right: 8px; }
#folder .row-between { margin: 12px 0; }
#folder + #player, #folder ~ #player { margin-top: 16px; }
.card { overflow-x: auto; }
.brand-sub { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 4px; }

/* 管理画面 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 12px 0; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.stat strong { display: block; font-size: 22px; }
.files td.bar-cell { width: 30%; min-width: 80px; }
.meter { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); }
