/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --sb-w: 196px;
  --sb-bg: var(--topbar-bg); /* ヘッダと同じグラデーション */
  --sb-border: rgba(255,255,255,.12);
  --sb-hover: rgba(255,255,255,.08);
  --sb-active-bg: rgba(255,255,255,.14);
  --sb-active-bar: #a5b4fc;
  --sb-text: rgba(255,255,255,.72);
  --sb-text-hi: #ffffff;

  --accent: #6366f1;
  --accent-dark: #4f46e5;

  --main-bg: #f0f2f5;
  --topbar-h: 100px;
  --topbar-bg: linear-gradient(90deg, #0a1633 0%, #2f5597 100%); /* 暗い紺 → 明るい紺 */
  --topbar-text: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --radius: 12px;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
a { text-decoration: none; }

.hidden { display: none !important; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.layout { display: flex; height: 100vh; overflow: hidden; position: relative; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sb-w);
  min-width: var(--sb-w);
  background: var(--sb-bg);
  background-attachment: fixed; /* ヘッダのグラデーションと継ぎ目なくつなげる */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--sb-border);
  transition: width .25s ease, min-width .25s ease, opacity .2s ease;
  position: relative;
  z-index: 40; /* 説明ドロワーより手前（ドロワーはこの裏から出てくる） */
}

/* サイドバーを閉じた状態 */
.layout.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  opacity: 0;
  border-right-color: transparent;
  pointer-events: none;
}

/* ハンバーガートグルボタン */
.sidebar-toggle {
  position: relative;
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: flex;
  justify-content: center; align-items: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
}
/* ホバーの減光はアイコンのみに効かせる（ツールチップまで薄くならないように） */
.toggle-icon {
  display: block; width: 26px; height: 26px;
  filter: brightness(0) invert(1);
  transition: opacity .13s;
}
.sidebar-toggle:hover .toggle-icon { opacity: .7; }

/* ツールチップ */
.sidebar-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px); left: 0;
  padding: 5px 9px;
  background: rgba(15,23,42,.92);
  color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1;
  white-space: nowrap;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(15,23,42,.18);
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity .13s, transform .13s;
  z-index: 40;
}
.sidebar-toggle:hover::after,
.sidebar-toggle:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}
/* 通常時（サイドバー展開中）は kakuda アイコン、閉じたら modosu アイコン */
.toggle-icon-collapsed { display: none; }
.layout.sidebar-collapsed .toggle-icon-open { display: none; }
.layout.sidebar-collapsed .toggle-icon-collapsed { display: block; }

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 8px 16px;
  background: var(--topbar-bg);
  background-attachment: fixed; /* トップバーと継ぎ目なくつなげる */
  border-bottom: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
}
.brand-link {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  transition: opacity .15s;
}
.brand-link:hover { opacity: .8; }
.brand-logo {
  width: auto;
  max-width: 100%;
  height: 37px;
  object-fit: contain;
}

/* カテゴリごとのグループ（見出しクリックで開閉） */
.nav-group + .nav-group { margin-top: 6px; }
.nav-group-header {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  padding: 8px 10px;
  font-family: inherit; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.06);
  border: 1px solid transparent; border-radius: 7px;
  cursor: pointer; text-align: left;
  transition: background .13s, color .13s, border-color .13s;
}
.nav-group-header:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-group-header.drop-into { border-color: rgba(165,180,252,.9); background: rgba(99,102,241,.25); }
.nav-group-caret { flex-shrink: 0; transition: transform .2s; }
.nav-group.is-collapsed .nav-group-caret { transform: rotate(-90deg); }
.nav-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group-count {
  flex-shrink: 0;
  min-width: 18px; padding: 1px 6px;
  font-size: 10px; font-weight: 600; text-align: center;
  color: rgba(255,255,255,.7); background: rgba(255,255,255,.1);
  border-radius: 999px;
}
.nav-group-header[draggable="true"] { cursor: grab; }
.nav-group.dragging { opacity: .4; }
.nav-group.group-drop-before { box-shadow: 0 -3px 0 0 rgba(99,102,241,.9); }
.nav-group.group-drop-after  { box-shadow: 0 3px 0 0 rgba(99,102,241,.9); }
.nav-group-body { padding-top: 4px; }
.nav-group.is-collapsed .nav-group-body { display: none; }

/* 各項目のカテゴリタグ */
.nav-item-cat {
  min-width: 0; max-width: 100px;
  padding: 2px 7px;
  font-size: 10px; line-height: 1.3;
  color: #c7d2fe; background: rgba(165,180,252,.16);
  border-radius: 999px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-item-cat.empty { color: rgba(255,255,255,.4); background: transparent; border: 1px dashed rgba(255,255,255,.25); }
.nav-item-cat.editable { cursor: text; }
.nav-item-cat.editable:hover { background: rgba(165,180,252,.3); color: #fff; }
.nav-item-cat-input {
  width: 100px; background: #fff;
  border: 1px solid rgba(99,102,241,.6); border-radius: 4px;
  color: #0f172a; font-size: 10px; font-family: inherit;
  padding: 1px 4px; outline: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.nav-item {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 10px 10px 10px 13px;
  border-radius: 8px; margin-bottom: 4px;
  position: relative;
  cursor: pointer;
  transition: background .13s;
}
.nav-item::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 0;
  background: var(--sb-active-bar);
  border-radius: 0 2px 2px 0;
  transition: height .2s;
}
.nav-item:hover  { background: var(--sb-hover); }
.nav-item.active { background: var(--sb-active-bg); }
.nav-item.active::before { height: 40px; }

.nav-item-top {
  display: flex; align-items: center; gap: 6px;
}

.nav-item-num {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.45);
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
  line-height: 1;
}
.nav-item.active .nav-item-num { color: #c7d2fe; }

.nav-item img {
  width: 100%; height: auto; aspect-ratio: 16 / 9;
  object-fit: cover; border-radius: 5px;
  background: #f1f5f9;
  display: block;
  border: 1px solid rgba(255,255,255,.12);
}
.nav-item-thumb { position: relative; }
.nav-item-imgbtn {
  position: absolute; bottom: 6px; right: 6px;
  padding: 3px 8px;
  font-size: 11px; line-height: 1;
  color: #fff; background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.25); border-radius: 4px;
  cursor: pointer; opacity: 0;
  transition: opacity .15s, background .15s;
}
.nav-item-thumb:hover .nav-item-imgbtn { opacity: 1; }
.nav-item-imgbtn:hover { background: rgba(99,102,241,.85); }
.nav-item-title {
  font-size: 12px; line-height: 1.45; color: var(--sb-text);
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.nav-item.active .nav-item-title { color: var(--sb-text-hi); }
.nav-item-url-wrap {
  display: flex; align-items: center; gap: 6px;
}
.nav-item-url {
  font-size: 10px; color: rgba(255,255,255,.5);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.nav-item-copy {
  font-size: 10px; color: #64748b;
  background: #f1f5f9; border: none;
  padding: 2px 7px; border-radius: 4px; flex-shrink: 0;
  cursor: pointer; opacity: 0;
  transition: opacity .13s, background .13s, color .13s;
}
.nav-item:hover .nav-item-copy { opacity: 1; }
.nav-item-copy:hover { background: #e2e8f0; color: #0f172a; }
.nav-item-title.editable { cursor: text; }
.nav-item-title.editable:hover { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(255,255,255,.4); }
.nav-item-title-input {
  width: 100%; background: #fff;
  border: 1px solid rgba(99,102,241,.6); border-radius: 4px;
  color: #0f172a; font-size: 12px; font-family: inherit;
  padding: 2px 5px; outline: none;
}
.nav-item-url.editable { cursor: text; }
.nav-item-url.editable:hover { color: rgba(255,255,255,.8); text-decoration: underline; text-underline-offset: 2px; }
.nav-item-url-input {
  width: 100%; background: #fff;
  border: 1px solid rgba(99,102,241,.6); border-radius: 4px;
  color: #0f172a; font-size: 10px; font-family: inherit;
  padding: 1px 4px; outline: none;
}

.nav-item-top {
  display: flex; align-items: center; gap: 4px;
}
.nav-item-handle {
  font-size: 12px; color: rgba(255,255,255,.4);
  flex-shrink: 0; cursor: grab;
  padding: 2px 3px; letter-spacing: -2px;
  opacity: .5;
  transition: opacity .13s, color .13s;
  user-select: none;
}
.nav-item:hover .nav-item-handle { opacity: 1; }
.nav-item-handle:hover { color: rgba(255,255,255,.85); }
.nav-item-handle:active { cursor: grabbing; }
.nav-item.sortable { cursor: grab; }
.nav-item.sortable:active { cursor: grabbing; }
.nav-item.dragging { opacity: .4; }

/* ドロップ位置インジケータ（::before は .active のバーで使用済みのため box-shadow で描画） */
.nav-item.drop-before { box-shadow: inset 0 2px 0 0 rgba(99,102,241,.9); }
.nav-item.drop-after  { box-shadow: inset 0 -2px 0 0 rgba(99,102,241,.9); }

.nav-item-del {
  font-size: 11px; color: #f87171;
  background: none; border: none;
  padding: 3px 6px; border-radius: 4px;
  opacity: 0; flex-shrink: 0; margin-left: auto;
  transition: opacity .13s, background .13s;
}
.nav-item:hover .nav-item-del { opacity: 1; }

/* 各項目の「説明」ボタン（右端） */
.nav-item-info {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: auto; flex-shrink: 0;
  padding: 3px 8px;
  font-size: 10.5px; font-weight: 700; line-height: 1;
  color: rgba(255,255,255,.8);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  transition: background .13s, color .13s, border-color .13s;
}
.nav-item-del + .nav-item-info { margin-left: 0; }
/* 管理モードは項目の上段が混むのでアイコンだけにする */
.nav-item.sortable .nav-item-info { padding: 3px 5px; }
.nav-item.sortable .nav-item-info span { display: none; }
.nav-item-info:hover { background: rgba(255,255,255,.18); color: #fff; }
.nav-item-info.is-open { background: #fff; border-color: #fff; color: #1e3a8a; }
.nav-item-del:hover { background: rgba(248,113,113,.14); }

.sidebar-admin {
  flex-shrink: 0;
  padding: 14px 12px 16px;
  border-top: 1px solid var(--sb-border);
  background: rgba(0,0,0,.15);
}
.admin-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.6); margin-bottom: 10px;
}
/* 追加する種類（Webサイト / 画像）の切替 */
.add-type-toggle {
  display: flex; gap: 2px; padding: 2px; margin-bottom: 8px;
  background: rgba(255,255,255,.1); border-radius: 7px;
}
.add-type-btn {
  flex: 1; padding: 5px 0;
  font-size: 11px; font-weight: 600; font-family: inherit;
  color: rgba(255,255,255,.7); background: transparent;
  border: none; border-radius: 5px; cursor: pointer;
  transition: background .15s, color .15s;
}
.add-type-btn:hover:not(.is-active) { color: #fff; }
.add-type-btn.is-active { background: #fff; color: #0f172a; }

#addForm { display: flex; flex-direction: column; gap: 7px; }
#addForm input[type="text"],
#addForm input[name="url"],
#addForm textarea {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  padding: 7px 9px; border-radius: 6px;
  font-size: 12px; width: 100%; outline: none;
  transition: border-color .15s;
}
#addForm input[type="text"]:focus,
#addForm input[name="url"]:focus,
#addForm textarea:focus { border-color: var(--accent); }
#addForm input::placeholder, #addForm textarea::placeholder { color: #94a3b8; }
#addForm textarea { resize: vertical; min-height: 48px; }
.thumb-upload {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.thumb-upload:hover { border-color: var(--accent); background: #f4f6f9; }
.thumb-upload-preview {
  width: 56px; height: 40px; flex-shrink: 0;
  object-fit: cover; border-radius: 4px;
  background: #f1f5f9;
}
.thumb-upload-previews {
  display: grid; grid-template-columns: repeat(2, 26px); gap: 3px;
  flex-shrink: 0;
}
.thumb-upload-previews img {
  width: 26px; height: 19px; object-fit: cover;
  border-radius: 3px; background: #f1f5f9;
}
.thumb-upload-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.thumb-upload-text { font-size: 12px; color: #0f172a; }
.thumb-upload-hint { font-size: 10px; color: #94a3b8; }
.admin-row { display: flex; align-items: center; justify-content: space-between; }
.btn-add {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 16px; border-radius: 6px;
  font-size: 12px; font-weight: 600; transition: background .15s;
}
.btn-add:hover { background: var(--accent-dark); }

/* Sidebar footer */
.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  justify-content: flex-end;
}
.login-chip {
  font-size: 11px; font-weight: 600; color: #fff;
  padding: 5px 14px;
  border: 1.5px solid rgba(255,255,255,.45);
  border-radius: 20px;
  background: none;
  transition: background .15s, color .15s;
}
.login-chip:hover { background: var(--accent); color: #fff; }

/* ============================================================
   MAIN
   ============================================================ */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow-y: scroll; overflow-x: hidden;
  background: var(--main-bg);
  scrollbar-gutter: stable;
}
/* 常にスクロールバーを表示（macOS の自動非表示を無効化）。
   ※ 標準プロパティ scrollbar-width は指定しない。
   併記すると Chrome/Safari がそちらを優先し、
   オーバーレイ式（フェードして消える）バーになってしまうため。 */
.main::-webkit-scrollbar { width: 12px; -webkit-appearance: none; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb {
  background: rgba(15,23,42,.25);
  border-radius: 6px;
  border: 3px solid var(--main-bg);
}
.main::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,.4); }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  background-attachment: fixed;
  border-bottom: 1px solid rgba(0,0,0,.12);
  padding: 8px 24px;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-heading {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.topbar h1 {
  font-size: 14px; font-weight: 700;
  color: var(--topbar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 55vw;
}
/* ログイン中はタイトルをクリックしてインライン編集 */
.topbar h1.editable { cursor: text; }
.topbar h1.editable:hover {
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(255,255,255,.55);
}
.topbar h1:has(.site-title-input) { overflow: visible; }
.site-title-input {
  width: 55vw; max-width: 100%;
  font-family: inherit; font-size: 14px; font-weight: 700; line-height: 1.4;
  color: var(--text);
  border: 1.5px solid var(--accent); border-radius: 6px;
  padding: 3px 7px; outline: none;
}

.site-desc {
  font-size: 12px; line-height: 1.5;
  color: rgba(255,255,255,.82);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 60vw;
}
.site-desc.editable { cursor: text; }
.site-desc.editable:hover {
  color: #fff;
  text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: rgba(255,255,255,.55);
}
.site-desc.empty { font-style: italic; opacity: .75; }
.site-desc-input {
  width: 100%; max-width: 60vw;
  font-family: inherit; font-size: 12px; line-height: 1.5;
  border: 1.5px solid var(--accent); border-radius: 6px;
  padding: 4px 7px; resize: vertical; outline: none;
  color: var(--text);
}

/* プレビュー表示サイズ切替（PC / スマホ） */
.viewport-toggle {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.viewport-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 28px; padding: 0 12px;
  line-height: 1;
  font-family: inherit;
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: none; border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s, color .13s;
}
.viewport-btn svg { flex-shrink: 0; }
.viewport-btn:hover:not(.is-active):not(:disabled) { color: var(--text); }
.viewport-btn.is-active {
  background: #000; color: #fff;
  box-shadow: var(--shadow-sm);
}
.viewport-toggle.is-disabled { opacity: .45; }
.viewport-btn:disabled { cursor: not-allowed; }
/* ブラウザで見る（別タブで開く） */
.open-browser-btn {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 12px; font-weight: 700;
  color: var(--text);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s, border-color .13s, color .13s;
}
.open-browser-btn[hidden] { display: none; }
.open-browser-btn svg { flex-shrink: 0; }
.open-browser-btn:hover {
  background: #000;
  border-color: #000;
  color: #fff;
}

/* ============================================================
   作品の説明ドロワー（サイドバーの裏から右へスライド）
   ============================================================ */
.info-drawer {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--sb-w);
  z-index: 30; /* サイドバー(40)の裏、ヘッダ(20)より手前 */
  width: min(380px, calc(100vw - var(--sb-w)));
  display: flex; flex-direction: column;
  /* すりガラス風：半透明の白＋背景ぼかし */
  background: rgba(255,255,255,.55);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-right: 1px solid rgba(255,255,255,.6);
  box-shadow: 12px 0 32px rgba(15,23,42,.18), inset -1px 0 0 rgba(255,255,255,.35);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s linear .32s;
}
.info-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s;
}
.layout.sidebar-collapsed .info-drawer { display: none; }
/* ぼかしが使えないブラウザでは読みやすさ優先で不透明に近づける */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .info-drawer { background: rgba(255,255,255,.94); }
}
/* ドロワー内の各パーツも透かして、すりガラスの質感を活かす */
.info-drawer .info-drawer-head { border-bottom-color: rgba(255,255,255,.55); }
.info-drawer .info-panel.info-popover { background: transparent; }
.info-drawer .info-popover .info-label { background: rgba(255,255,255,.5); }
.info-drawer .info-edit { background: rgba(255,255,255,.85); }
.info-drawer .btn-edit,
.info-drawer .btn-io { background: rgba(255,255,255,.5); border-color: rgba(15,23,42,.12); }
.info-drawer-close:hover { background: rgba(255,255,255,.6); }
.info-drawer-head {
  position: relative;
  flex-shrink: 0;
  padding: 18px 52px 14px 24px;
  border-bottom: 1px solid var(--border);
}
.info-drawer-kicker {
  display: block;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 4px;
}
.info-drawer-title {
  font-size: 14px; font-weight: 700; line-height: 1.45;
  color: var(--text);
  overflow-wrap: anywhere;
}
.info-drawer-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent; border-radius: 999px;
  transition: background .13s, color .13s;
}
.info-drawer-close:hover { background: #f1f5f9; color: var(--text); }
.info-drawer .info-panel.info-popover {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding-top: 16px; padding-bottom: 20px;
  border-top: none;
  box-shadow: none;
}

.info-drawer .info-grid { flex: none; }
.info-drawer .info-col { flex: none; }
/* ドロワー内では縦積みレイアウトに変更 */
.info-popover .info-grid {
  flex-direction: column;
  gap: 0;
}
.info-popover .info-col {
  padding: 10px 0;
  border-right: none;
  border-bottom: none;
}
.info-popover .info-col:first-child { padding-top: 0; }
.info-popover .info-col:last-child { padding-bottom: 0; }
.info-popover .info-view { min-height: 0; }
/* ドロップダウン内の各タイトルに横幅いっぱいの薄いグレー帯 */
.info-panel.info-popover {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}
.info-popover .info-controls {
  flex-direction: row;
  justify-content: flex-end;
  padding-top: 10px;
}
/* 編集ボタンが1つも表示されていないときは余白を出さない */
.info-popover .info-controls:not(:has(button:not(.hidden))) { display: none; }
.info-popover .info-label {
  background: #f1f3f5;
  margin: 0 -24px 8px;
  padding: 6px 24px;
  width: auto;
}
/* こだわった点セクションのハイライト */
.info-col.highlight {
  animation: pointsHighlight 1.6s ease;
}
@keyframes pointsHighlight {
  0%, 40% { background: rgba(99,102,241,.12); }
  100% { background: transparent; }
}

/* ============================================================
   INFO PANEL
   ============================================================ */
.info-panel {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.info-grid {
  flex: 1; display: flex; gap: 0; min-width: 0;
}
.info-col {
  flex: 1; min-width: 0;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.info-col:first-child { padding-left: 0; }
.info-col:last-child  { border-right: none; padding-right: 0; }

.info-label {
  display: block;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: #374151;
  margin-bottom: 5px;
}
.info-view {
  flex: 1;
  font-size: 12px; line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-height: 40px;
}
.info-view.empty { color: var(--text-muted); }

.info-edit {
  width: 100%; font-size: 12px; line-height: 1.55;
  border: 1.5px solid var(--accent);
  border-radius: 6px; padding: 5px 7px;
  resize: none; outline: none;
  min-height: 64px; color: var(--text);
  transition: border-color .15s;
}
.info-edit:focus { border-color: var(--accent-dark); }

.info-controls {
  display: flex; flex-direction: column; gap: 6px;
  flex-shrink: 0; align-self: flex-start;
  padding-top: 2px;
}
.btn-edit {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-edit:hover { border-color: var(--accent); color: var(--accent); }
.btn-save {
  background: var(--accent); color: #fff; border: none;
  padding: 5px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  transition: background .15s;
}
.btn-save:hover { background: var(--accent-dark); }
.btn-cancel-edit {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px; border-radius: 6px;
  font-size: 12px; white-space: nowrap;
  transition: background .15s;
}
.btn-cancel-edit:hover { background: #f1f5f9; }

/* 説明テキストの書き出し / 読み込み */
.info-io {
  display: flex; align-items: center; gap: 6px;
  margin-right: auto;
  min-width: 0;
}
/* ボタンが両方非表示のときは余白を作らない */
.info-io:not(:has(button:not(.hidden))) { display: none; }
.btn-io {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px; border-radius: 6px;
  font-size: 12px; white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-io:hover { border-color: var(--accent); color: var(--accent); }
.info-io-msg {
  font-size: 11px; line-height: 1.4;
  color: var(--text-muted);
  min-width: 0;
}
.info-io-msg.is-error { color: #dc2626; }

/* ============================================================
   PREVIEW
   ============================================================ */
.preview-outer {
  /* 表示領域（画面高 - 上部バー）の91.8% (102% x 0.9) + 70px */
  flex: 0 0 auto;
  height: calc((100vh - var(--topbar-h)) * .918 + 70px);
  padding: 16px 32px; overflow: hidden; display: flex;
}
#previewArea {
  flex: 1; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-md);
  background: #fff; position: relative;
}
#siteFrame { width: 100%; height: 100%; border: none; display: block; }

/* スマホ表示：プレビュー幅を端末幅に絞って中央寄せ */
.preview-outer.is-mobile { justify-content: center; }
.preview-outer.is-mobile #previewArea {
  flex: 0 1 460px;
  max-width: 100%;
  border-radius: 24px;
  border: 1px solid var(--border);
}

#loadingSpinner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.85);
  z-index: 10;
  border-radius: var(--radius);
}
.spinner-circle {
  width: 40px; height: 40px;
  border: 3px solid rgba(99,102,241,.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#iframeFallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #f8fafc; padding: 32px;
}
/* 画像作品の表示 */
#imageView {
  position: absolute; inset: 0;
  overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
  background: #f8fafc; padding: 32px;
}
.work-images {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  width: 100%; margin: auto;
}
.work-images img {
  display: block; max-width: 100%; height: auto;
  border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,.1);
  background: #fff;
}
/* 管理モード：画像作品の並べ替え */
.work-image-item {
  margin: 0; position: relative; max-width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 8px; border-radius: 10px;
  border: 2px dashed transparent; cursor: grab;
  transition: border-color .15s, opacity .15s;
}
.work-image-item:hover { border-color: #cbd5e1; }
.work-image-item.is-dragging { opacity: .4; }
.work-image-item.is-drop-target { border-color: var(--accent); background: rgba(99,102,241,.06); }
.work-image-bar { display: flex; align-items: center; gap: 6px; }
.work-image-num { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.order-move-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 6px; padding: 3px 9px; font-size: 12px; line-height: 1.3;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.order-move-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.order-move-btn:disabled { opacity: .35; cursor: default; }

/* 追加フォーム：選んだ画像の並び順 */
.work-order-hint { font-size: 10px; color: rgba(255,255,255,.6); margin: 0 0 4px; }
.work-order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.work-order-item {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1.5px solid transparent; border-radius: 6px;
  padding: 3px 4px; cursor: grab;
}
.work-order-item.is-dragging { opacity: .4; }
.work-order-item.is-drop-target { border-color: var(--accent); }
.work-order-num { font-size: 11px; font-weight: 600; color: var(--text-muted); width: 12px; text-align: center; }
.work-order-item img {
  width: 48px; height: 34px; object-fit: cover; border-radius: 3px;
  background: #f1f5f9; flex: 1; min-width: 0;
}
.work-order-item .order-move-btn { padding: 2px 6px; font-size: 11px; }

.nav-item-type {
  font-size: 10px; color: rgba(255,255,255,.5);
}
#proxyStatus { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; text-align: center; line-height: 1.7; }
#siteImage { max-width: 100%; max-height: calc(100% - 100px); object-fit: contain; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,.1); }
.open-external-btn { display: inline-block; margin-top: 16px; padding: 8px 20px; background: var(--accent, #4f8ef7); color: #fff; border-radius: 6px; font-size: 13px; text-decoration: none; transition: opacity .15s; }
.open-external-btn:hover { opacity: .8; }

/* ============================================================
   MODAL  —  display は JS の inline style で制御（style="display:none"）
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  z-index: 200;
}
/* JS で display:flex / display:none を直接切り替えるため
   .hidden クラスは使わない */
.modal-card {
  background: #fff; border-radius: 16px;
  padding: 28px; width: 360px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.modal-heading { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.modal-input-wrap { position: relative; margin-bottom: 20px; }
.modal-input {
  width: 100%; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 10px 40px 10px 14px;
  font-size: 14px; color: var(--text); outline: none;
  transition: border-color .15s; display: block; box-sizing: border-box;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: #94a3b8; }
.modal-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px; opacity: .5;
  transition: opacity .15s;
}
.modal-eye:hover { opacity: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; }
.btn-ghost {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-muted); padding: 8px 18px;
  border-radius: 8px; font-size: 13px; font-weight: 500;
  transition: background .13s;
}
.btn-ghost:hover { background: #f1f5f9; }
.btn-accent {
  background: var(--accent); border: none; color: #fff;
  padding: 8px 22px; border-radius: 8px;
  font-size: 13px; font-weight: 600; transition: background .13s;
}
.btn-accent:hover { background: var(--accent-dark); }
