* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* sidenote-pdf系と共通のデザイントークン（templex.jp実測分） */
:root {
  --tx-text: #0a0a0a;
  --tx-muted: #4d4d4d;
  --tx-muted-2: #71717a;
  --tx-border: #e5e5e5;
  --tx-bg-muted: #f2f2f2;
  --tx-radius-card: 14px;
  --tx-radius-btn: 8px;
  --tx-shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
  --accent: #1a73e8;
  --danger: #d33;
}
body {
  margin: 0; color: var(--tx-text); background: #fff;
  font-family: "Source Sans Pro", system-ui, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

/* ── サイドバー（pdf-metadataと同じ構造・配色） ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; overflow-y: auto;
  background: var(--tx-bg-muted); padding: 28px 20px 48px;
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; flex-direction: column; gap: 4px; }
.app-title {
  font-weight: 400; font-size: 24px; line-height: 1.35; text-align: center;
  background: var(--tx-text); color: #fff; padding: 10px 12px; border-radius: var(--tx-radius-btn);
}
.app-sub { font-size: 12px; color: var(--tx-muted-2); line-height: 1.6; }
.app-sub a { color: var(--accent); text-decoration: none; }
.app-sub a:hover { text-decoration: underline; }
#secondary-info { display: flex; flex-direction: column; gap: 28px; }
.main #secondary-info { margin-top: 32px; }
.section { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; }
.sidebar .row button { width: auto; flex: 1 1 0; min-width: 0; }
.shead { font-weight: 700; font-size: 15px; margin: 0 0 2px; }
.cap { font-size: 12.5px; color: var(--tx-muted-2); margin: 4px 0 0; line-height: 1.6; }
.is-error-text { color: var(--danger) !important; }

.sidebar .filebtn, .sidebar button {
  width: 100%; font-size: 14px; border-radius: var(--tx-radius-btn); border: 1px solid var(--tx-border);
  background: #fff; color: var(--tx-text); font-family: inherit;
  padding: 9px 12px; cursor: pointer; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.sidebar .filebtn:hover, .sidebar button:hover:not(:disabled) { border-color: var(--tx-text); background: var(--tx-bg-muted); }
.sidebar .filebtn.dragover { border-color: var(--tx-text); background: #fff; box-shadow: 0 0 0 3px rgba(10,10,10,.08); }
.sidebar button.primary { background: var(--tx-text); border-color: var(--tx-text); color: #fff; font-weight: 600; margin-top: 4px; }
.sidebar button.primary:hover:not(:disabled) { background: #262626; }
.sidebar button:disabled { opacity: .55; cursor: not-allowed; }
.filebtn input { display: none; }
.icon { width: 1.05em; height: 1.05em; flex: none; }

.badge { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px;
         border: 1px solid var(--tx-border); background: #fff; color: var(--tx-muted); font-variant-numeric: tabular-nums; }

.gh-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin: 2px 0 -2px; border-radius: 6px; color: var(--tx-text);
}
.gh-link .icon { width: 18px; height: 18px; }
.gh-link:hover { color: var(--accent); background: #e6e8ee; }

.text-input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--tx-radius-btn);
  border: 1px solid var(--tx-border); font-size: 14px; font-family: inherit;
  background: #fff; color: var(--tx-text);
}
.text-input:focus { outline: none; border-color: var(--tx-text); box-shadow: 0 0 0 3px rgba(10,10,10,.08); }

/* ── 本文 ── */
.main { margin-left: 300px; min-height: 100vh; padding: 28px 40px 80px; }
.main-title { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
#status { font-size: 13.5px; color: var(--tx-muted); margin: 0 0 24px; line-height: 1.7; }
#status.is-error { color: var(--danger); }

/* ── ページサムネイル一覧 ── */
#pages { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.page-card {
  width: 140px; display: flex; flex-direction: column; gap: 6px;
  background: #fff; border: 1px solid var(--tx-border); border-radius: var(--tx-radius-card);
  padding: 8px; box-shadow: var(--tx-shadow-sm); cursor: grab; user-select: none;
}
.page-card.dragging { opacity: .35; }
.page-thumb-wrap {
  position: relative; border: 1px solid var(--tx-border); border-radius: 6px;
  overflow: hidden; background: #f7f7f7; line-height: 0;
}
.page-thumb { display: block; width: 100%; height: auto; }
.page-remove {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0;
  border: none; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.page-remove:hover { background: var(--danger); }
.page-remove .icon { width: 11px; height: 11px; }
.page-label { display: flex; flex-direction: column; gap: 1px; font-size: 11px; }
.page-num { font-weight: 700; color: var(--tx-text); font-size: 11.5px; }
.page-source { color: var(--tx-muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-move { display: flex; gap: 4px; }
.move-btn {
  flex: 1; height: 22px; padding: 0; font-size: 13px; line-height: 1;
  border: 1px solid var(--tx-border); border-radius: 6px; background: #fff; color: var(--tx-muted); cursor: pointer;
}
.move-btn:hover { border-color: var(--tx-text); color: var(--tx-text); background: var(--tx-bg-muted); }

@media (max-width: 768px) {
  .sidebar { position: static; width: 100%; bottom: auto; }
  .main { margin-left: 0; padding: 20px 16px 60px; }
  .page-card { width: calc(50% - 8px); }
}
