@import "./src/styles/diagnostics.css";
@import "./src/styles/lp-production.css";

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #00d9c0;
  --accent-2: #00d9c0;
  --violet: #4b19ff;
  --danger: #ff5263;
  --success: #35b779;
  --warning: #f59e0b;
  --blue-light: #eff6ff;
  --blue-dark: #1e40af;
  --radius: 12px;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  color-scheme: light;
  font-family: "Roboto", "Meiryo", "メイリオ", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  font-weight: 400 !important;
}

/* 特定の小見出しやタブ等の要素だけを 600 にして上品なメリハリを与える */
h1, h2, h3, h4, h5, h6,
strong,
b,
.pane-head h2,
.pane-head h3,
.panel-head h2,
.block-title strong,
.eyebrow,
.mode-tabs button,
.sidebar-nav-item,
.sidebar-brand .brand-name {
  font-weight: 600 !important;
}

/* 右上のリセットおよびログアウトボタンだけは600にして強調する */
.topbar-right button[data-action="new-project"],
.topbar-right button[data-action="logout"] {
  font-weight: 600 !important;
  min-width: 140px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  min-width: 1180px;
  font-weight: 400;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
h5,
h6,
strong,
b {
  font-weight: 600;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  margin-left: 240px;
  width: calc(100% - 240px);
  box-sizing: border-box;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-logo {
  height: 38px;
  max-width: 160px;
  object-fit: contain;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  background: #f1f5f9;
  border-radius: 7px;
  padding: 3px;
}

.mode-tabs button,
.sub-tabs button {
  border: 0;
  height: 34px;
  padding: 0 12px;
  border-radius: 5px;
  background: transparent;
  color: #7a8390;
  font-size: 12px;
  font-weight: 600;
}

.mode-tabs button.active,
.sub-tabs button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(20, 26, 35, 0.08);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* サイドバー最上部のブランドアイコン用スタイル */
.sidebar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 16px 12px;
  position: relative;
}

.sidebar-logo {
  height: 38px;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand .brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}

.sidebar-brand .brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.sidebar-nav-item:hover {
  background: #f8fafc;
  color: var(--ink);
}

.sidebar-nav-item.active {
  background: #f1f5f9;
  color: var(--ink);
  font-weight: 600;
}

.sidebar-icon {
  flex-shrink: 0;
  color: currentColor;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  margin-top: auto;
  background: #ffffff;
}

.session-role {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0.02em;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.session-role.admin {
  background: var(--blue-light);
  color: var(--blue-dark);
}

.session-role.user {
  background: var(--blue-light);
  color: var(--blue-dark);
}

.main-pane {
  grid-column: 2;
  overflow: auto;
  background: var(--bg);
  padding: 32px;
}

.pane-head {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.pane-head h2,
.pane-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.panel-head {
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel-body {
  padding: 20px;
}

.uploader {
  min-height: 120px;
  border: 2px dashed var(--line-strong);
  border-radius: 12px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: #ffffff;
  transition: all 0.2s ease;
  cursor: pointer;
}

.uploader:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.uploader.dragover {
  border-color: var(--accent) !important;
  background: rgba(10, 166, 255, 0.04) !important;
}

.uploader input {
  display: none;
}

.uploader strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  margin-top: 7px;
}

.uploader.full-width {
  margin: 0 0 24px 0;
  min-height: 140px;
}

.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.assets-grid .image-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  transition: all 0.2s ease;
  position: relative;
}

.assets-grid .image-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.assets-grid .image-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.assets-grid .thumb {
  width: 100%;
  height: 130px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.assets-grid .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.assets-grid .thumb span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.assets-grid .image-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.assets-grid .image-meta strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  word-break: break-all;
}

.assets-grid .image-meta span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.assets-grid .image-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.assets-grid .image-item:hover .image-actions {
  opacity: 1;
}

.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.btn.primary {
  background: #0d1319;
  color: #fff;
  border-color: #0d1319;
}

.btn.accent {
  background: #0d1319;
  color: #fff;
  border-color: #0d1319;
}

.btn.violet {
  background: var(--violet);
  color: #fff;
  border-color: var(--violet);
}

.btn.danger {
  color: #e11d48;
  background: rgba(255, 82, 99, 0.06);
  border-color: rgba(255, 82, 99, 0.15);
}

.btn.danger:hover {
  background: rgba(255, 82, 99, 0.12);
  border-color: rgba(255, 82, 99, 0.25);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.small {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.panel-head .btn.small {
  min-width: 105px;
}

.btn:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.canvas-stack {
  max-width: 768px;
  margin: 0 auto 40px;
  display: grid;
  gap: 18px;
}

.canvas-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-toolbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.image-canvas {
  position: relative;
  cursor: crosshair;
  user-select: none;
}

.image-canvas img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

.link-area,
.drawing-area {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(0, 217, 192, .2);
  min-width: 4px;
  min-height: 4px;
}

.link-area {
  display: flex;
  align-items: flex-start;
}

.resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 1.5px solid #ffffff;
  border-radius: 50%;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.resize-handle.nw { top: -4px; left: -4px; cursor: nwse-resize; }
.resize-handle.ne { top: -4px; right: -4px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.resize-handle.se { bottom: -4px; right: -4px; cursor: nwse-resize; }

.link-area:hover .resize-handle {
  opacity: 1;
}

.resize-handle:hover {
  transform: scale(1.2);
}

.link-badge {
  position: absolute;
  top: -28px;
  left: 0;
  max-width: 260px;
  height: 24px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: #0d1319;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.link-area:hover .link-badge {
  opacity: 1;
}

.link-pop {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  min-width: 270px;
  padding: 9px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: none;
  gap: 6px;
}

/* 位置バリエーション（密着させて隙間をゼロにすることで、ホバー切れを根本から防ぐ） */

/* 上側に表示 */
.link-pop.pop-top {
  top: auto;
  bottom: 100%;
}

/* 下側に表示 */
.link-pop.pop-bottom {
  top: 100%;
  bottom: auto;
}

/* 左寄せ（右側へ展開、デフォルト） */
.link-pop.pop-left-align {
  left: 0;
  right: auto;
}

/* 右寄せ（左側へ展開、右端見切れ防止） */
.link-pop.pop-right-align {
  left: auto;
  right: 0;
}

.link-area:hover .link-pop {
  display: grid;
}

.link-pop input {
  width: 100%;
}

.settings-stack {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.settings-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.block-title strong {
  font-size: 14px;
}

.eyebrow {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control,
input[type="text"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="color"],
input[type="time"],
input[type="email"],
input:disabled,
select {
  width: 100%;
  height: 36px;
  margin: 0; /* ブラウザ固有の余白による位置ズレを完全に排除 */
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-sizing: border-box; /* サイズ計算を厳密に統一 */
  font-size: 14px; /* 追加：記入欄のフォントサイズを14pxに統一 */
}

input:disabled,
select:disabled {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: not-allowed;
  height: 36px;
  padding: 0 10px;
  box-sizing: border-box;
}

textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

input[type="color"] {
  padding: 4px;
}

.control:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, .12);
}

.switch-row,
.cta-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  border: 0;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch.on {
  background: #0f172a;
}

.switch.on::after {
  left: 18px;
}

.cta-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  margin-bottom: 8px;
}

.preview-wrap {
  position: fixed;
  inset: 0;
  z-index: 1000; /* すべてを覆い隠す巨大ポップアップにする */
  padding: 40px 20px;
  background: #f8fafc; /* 白紙に近い洗練されたライトグレー */
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  cursor: pointer; /* 余白がクリックできることを示すカーソル */
}

/* 最新iPhone筐体コンテナ */
.preview-phone-container {
  position: relative;
  /* 画面幅と、画面の縦制限から逆算した最大幅の「小さい方」を自動適用（アスペクト比を100%崩さない相似縮小） */
  width: min(90vw, 410px, calc((100vh - 100px) * 0.462)); /* 高さいっぱいに大きく表示できるように調整 */
  aspect-ratio: 390 / 844; /* 高さはアスペクト比で完全固定 */
  max-height: calc(100vh - 100px); /* 144pxから100pxに緩和し、高さを大きく使えるように */
  border: 12px solid #090d16; /* 最新の極細黒ベゼル */
  border-radius: 54px; /* 最新端末の滑らかで大きな角丸 */
  background: #000;
  box-shadow:
    0 25px 50px -12px rgba(15, 23, 42, 0.3), /* 重厚な接地影 */
    0 0 0 2px #334155, /* チタニウムエッジの金属的な輝きを表現する外枠線 */
    inset 0 0 0 2px #1e293b; /* 画面内側の極細境界線 */
  overflow: hidden;
  box-sizing: border-box;
  margin: 0 auto;
  display: block;
  cursor: default; /* スマホモックアップ上では通常のカーソルに戻す */
}



/* モックアップ内に完全にフィットするプレビュー画面 */
.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  display: block;
}

.sub-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef0f3;
}

.analytics-layout,
.ledger-layout,
.upload-layout {
  padding: 0;
  display: grid;
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  background: var(--surface-2);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: .12em;
}

.history-bar {
  border-top: 1px solid var(--line);
  background: #f3efff;
}

.history-head {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: var(--violet);
  font-weight: 600;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.history-capture {
  height: 160px;
  margin-top: 10px;
  border-radius: 8px;
  background: #f1f2f4;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  overflow: hidden;
}

.history-capture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 26px;
  background: rgba(20, 26, 35, .76);
  display: grid;
  place-items: center;
}

.modal {
  width: min(96vw, 1760px);
  height: min(92vh, 920px);
  background: #fff;
  border-radius: 28px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr) 82px;
  box-shadow: 0 40px 140px rgba(0,0,0,.36);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  background: #1d1f21;
}

.code-editor {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e5e7eb;
  padding: 30px;
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
  resize: none;
}

.project-images {
  border-left: 1px solid rgba(255,255,255,.12);
  padding: 22px;
  color: #fff;
  overflow: auto;
}

.project-image-card {
  margin-bottom: 18px;
}

.project-image-card img {
  width: 100%;
  border-radius: 10px;
  opacity: .88;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 22px;
  bottom: 22px;
  border-radius: 8px;
  background: #0d1319;
  color: #fff;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f8fafc;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.login-card h1 {
  margin: 0;
  color: var(--text);
  letter-spacing: 0;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.login-card input[type="email"],
.login-card input[type="password"] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

.session-chip {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 54px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  margin-bottom: 12px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef1f5;
}

.bar-fill {
  height: 100%;
  background: #1e293b;
  border-radius: 999px;
}

.hidden {
  display: none !important;
}

/* カスタムチェックボックス (枠線濃いグレー + チェックマーク形式) */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  outline: none;
  background-color: #fff;
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0;
  vertical-align: middle;
}

/* ホバー時 */
input[type="checkbox"]:hover:not(:disabled) {
  border-color: #94a3b8;
  background-color: #f8fafc;
}

/* チェックONの状態：非常に綺麗な超薄グレーで塗りつぶし（会社名側の表示に固定） */
input[type="checkbox"]:checked {
  border-color: #94a3b8;
  background-color: #f1f5f9;
}

/* チェックマーク（疑似要素） */
input[type="checkbox"]::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  transform: rotate(-45deg) translate(0.5px, -0.5px) scale(0);
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: center;
  position: absolute;
  top: 3px;
  left: 3px;
}

/* チェックON時にチェックマークを表示 */
input[type="checkbox"]:checked::after {
  transform: rotate(-45deg) translate(0.5px, -0.5px) scale(1);
}

/* フォーカス時の影 */
input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.12);
}

/* 無効（disabled）状態 */
input[type="checkbox"]:disabled {
  background-color: var(--surface-2);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.6;
}

input[type="checkbox"]:disabled::after {
  border-color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  margin: 8px 0;
}

.weekly-grid {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.week-row {
  display: grid;
  grid-template-columns: 72px 1fr 1fr;
  gap: 6px;
  align-items: center;
}

.week-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.compact-details {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.compact-details summary {
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.form-designer {
  display: grid;
  gap: 18px;
}

.form-design-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.field-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
}

.selected-field-list {
  display: grid;
  gap: 10px;
}

.selected-field {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.drag-handle {
  color: var(--muted);
  font-weight: 600;
  cursor: grab;
  padding-top: 10px;
}

.selected-field-body {
  display: grid;
  gap: 8px;
}

.question-design-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  align-items: start;
}

.icon-upload {
  width: 64px;
  height: 64px;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-upload:hover {
  border-color: #94a3b8;
  color: var(--ink);
  background: #f1f5f9;
}

.icon-upload input {
  display: none;
}

.bulk-icon-upload {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.bulk-icon-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.icon-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-field-actions {
  display: flex;
  gap: 6px;
}

.role-note,
.settings-help {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.settings-help {
  margin-bottom: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
  font-weight: 600;
}

.email-layout {
  display: grid;
  gap: 18px;
}

.email-grid {
  display: grid;
  gap: 14px;
}

.email-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.email-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.email-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.email-card h3,
.table-title {
  margin: 0;
  font-size: 14px;
}

.email-help {
  border: 1px solid #ccfbf1;
  border-radius: 8px;
  padding: 12px;
  background: #f0fdfa;
  display: grid;
  gap: 8px;
  color: #115e59;
}

.email-help div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.email-help code {
  padding: 3px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #99f6e4;
  font-size: 11px;
}

.reminder-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.email-tables {
  display: grid;
  gap: 18px;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }
  .topbar,
  .workspace,
  .metric-grid,
  .history-grid,
  .modal-body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    top: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .reminder-options {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   サイドバー折りたたみ (Collapsed Sidebar) スタイル定義
   ========================================================================== */

/* 滑らかな開閉アニメーション */
.sidebar,
.topbar,
.workspace,
.main-pane {
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 折りたたみ時はアイコンレールを残さず完全に隠す */
.sidebar.collapsed {
  display: none;
}

/* 折りたたみ時のワークスペースとトップバーの幅調整 */
.workspace.collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.workspace.collapsed .main-pane {
  grid-column: 1;
}

.topbar.collapsed {
  margin-left: 0;
  width: 100%;
}

/* サイドバー境界に吸着する開閉トグル */
.sidebar-edge-toggle {
  z-index: 35;
  width: 22px;
  height: 42px;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.sidebar-edge-toggle:hover {
  border-color: #cbd5e1;
  background: #ffffff;
  color: #0f172a;
}

.sidebar-edge-toggle.collapse {
  position: absolute;
  top: 54px;
  right: -11px;
}

.sidebar-edge-toggle.reveal {
  position: fixed;
  top: 54px;
  left: 8px;
}

/* ==========================================================================
   Premium Custom Confirm Modals
   ========================================================================== */
@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleInModal {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.custom-confirm-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeInModal 0.2s ease-out;
}

.custom-confirm-card {
  background: #ffffff;
  border: 1px solid var(--line-strong, #e2e8f0);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: scaleInModal 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.custom-confirm-card.folder-select {
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.custom-confirm-title {
  margin: 0 0 12px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #0f172a);
  letter-spacing: -0.01em;
}

.custom-confirm-title.prompt-title {
  margin-bottom: 16px;
}

.custom-confirm-message {
  margin: 0 0 24px 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted, #64748b);
  white-space: pre-wrap;
  font-weight: 500;
}

.custom-confirm-btn-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.custom-confirm-btn-row.margin-bottom {
  margin-bottom: 16px;
}

.custom-confirm-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.custom-confirm-btn.cancel {
  background: #ffffff;
  border: 1px solid var(--line-strong, #e2e8f0);
  color: var(--ink, #0f172a);
}

.custom-confirm-btn.cancel:hover {
  background: #f8fafc;
}

.custom-confirm-btn.danger {
  background: #d9383a;
  border: none;
  color: #ffffff;
}

.custom-confirm-btn.danger:hover {
  opacity: 0.9;
}

.custom-confirm-btn.primary {
  background: #0d1319;
  border: none;
  color: #ffffff;
}

.custom-confirm-btn.primary:hover {
  opacity: 0.9;
}

.custom-confirm-prompt-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong, #e2e8f0);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 20px;
  transition: border-color 0.15s ease;
  background: #ffffff;
  color: var(--ink, #0f172a);
}

.custom-confirm-prompt-input:focus {
  border-color: #94a3b8;
}

.custom-confirm-folder-list {
  display: grid;
  gap: 8px;
  max-height: 128px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding: 2px 6px 2px 0;
  overscroll-behavior: contain;
}

.custom-confirm-folder-item {
  min-height: 38px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink, #0f172a);
  padding: 0 12px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.custom-confirm-folder-item.selected {
  border-color: var(--line-strong, #cbd5e1);
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px var(--line-strong, #cbd5e1);
}

.custom-confirm-folder-empty {
  min-height: 38px;
  display: flex;
  align-items: center;
  color: var(--muted, #64748b);
  font-size: 12px;
}

.custom-confirm-folder-create-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted, #64748b);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.custom-confirm-folder-create-toggle span {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
}

.custom-confirm-folder-create-area {
  display: none;
  gap: 10px;
  margin: 0;
}

.custom-confirm-folder-create-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong, #cbd5e1);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--ink, #0f172a);
  box-sizing: border-box;
  background: #ffffff;
}

/* シンプルスクロールナビゲーター (白ベース・ダークグレー枠・文字) */
.scroll-navigator {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 12px 8px;
  border-radius: 24px;
  border: 1.5px solid var(--line-strong, #cbd5e1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: var(--ink, #0f172a);
}

.scroll-navigator button.btn.ghost,
.scroll-navigator label.btn.ghost {
  color: var(--ink, #0f172a) !important;
  border: none;
  background: transparent;
  width: 32px;
  height: 32px;
  padding: 0;
  min-height: auto;
  border-radius: 50%;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-navigator button.btn.ghost:hover,
.scroll-navigator label.btn.ghost:hover {
  color: #000000 !important;
  background: rgba(13, 19, 25, 0.08) !important;
  transform: scale(1.1);
}

.scroll-navigator button.btn.ghost:active,
.scroll-navigator label.btn.ghost:active {
  background: rgba(13, 19, 25, 0.15) !important;
  transform: scale(0.95);
}

.scroll-navigator-separator {
  width: 16px;
  height: 1px;
  background: var(--line, #e2e8f0);
  margin: 2px 0;
}

#scrollNavIndicator {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink, #0f172a);
  font-family: Inter, sans-serif;
  min-width: 36px;
  text-align: center;
  user-select: none;
}

/* プレースホルダーの文字色を薄く上品な色味に調整 */
::placeholder {
  color: #94a3b8 !important;
  opacity: 1 !important;
}
