body {
    margin: 0;
    font-family: system-ui, "Helvetica Neue", Arial, sans-serif;
}

.app-container {
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #1e293b;
    color: #fff;
    padding: 1rem .75rem;
    transition: width .2s ease; /* ← 重複定義統合 */
}

.sidebar-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: .75rem;
    gap: .5rem; /* d-flex gap-2 と合わせて確実に余白を確保 */
    justify-content: flex-start; /* ← ヘッダーは左寄せを明示 */
}

.sidebar .nav-link {
    color: #cbd5e1;
    padding: .4rem .6rem;
    border-radius: 4px;
    font-size: .95rem;
}

.sidebar .nav-link:hover {
    background: #334155;
    color: #fff;
}

.sidebar .nav-link.active {
    background: #0ea5e9;
    color: #fff;
}

.content {
    background: #f1f5f9;
    min-width: 0;          /* ← 追加: フレックス子要素のはみ出し防止 */
    overflow-x: hidden;    /* ← 追加: 保険で横スクロール抑止 */
}

/* ホーム：レスポンシブ列数（等幅保証） */
.home-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr)); /* mobile: 1列（等幅） */
    gap: 16px;
    width: 100%;
}

@media (min-width: 768px) {
    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* tablet: 2列（等幅） */
    }
}

@media (min-width: 992px) {
    .home-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)); /* desktop: 3列（等幅） */
    }
}

.home-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0; /* ← 追加: 子要素の長文で列幅を押し広げない */
}

/* すべて同じ横幅・16:9を維持してカバー表示 */
.thumb-wrap {
    display: block;
    width: 100%;
    max-width: 100%; /* ← 追加: 保険 */
    aspect-ratio: 16 / 9;
    background: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.drop-zone {
    position: relative;
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background: #ffffff;
    transition: border-color .2s, background .2s;
}

.drop-zone.drag-over {
    border-color: #0ea5e9;
    background: #f0f9ff;
}

.drop-zone.disabled {
    opacity: .5;
    pointer-events: none;
}

.drop-zone .drop-zone-inner {
    pointer-events: none;
}

.is-disabled {
    background-color: #e2e8f0 !important;
}

.unified-wrapper {
    position: relative;
}

.unified-textarea.disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

.unified-file-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 2;
}

.file-chip {
    position: absolute;
    top: 6px;
    left: 12px;
    background: #eef4ff;
    border: 1px solid #b6d2ff;
    border-radius: 16px;
    padding: 2px 8px;
    font-size: .8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.unified-wrapper.drag-over {
    outline: 2px dashed #0d6efd;
    outline-offset: 2px;
}

.unified-drop-mask {
    position: absolute;
    inset: 0;
    background: rgba(13, 110, 253, .08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: #0d6efd;
    pointer-events: none;
    border: 2px dashed #0d6efd;
    border-radius: .375rem;
    z-index: 3;
}

.btn {
    display: inline-block;
    font-size: .9rem;
    padding: .45rem .9rem;
    border: 1px solid #0d6efd;
    background: #0d6efd;
    color: #fff;
    border-radius: .375rem;
    text-decoration: none;
    cursor: pointer;
}

.btn.btn-secondary {
    background: #64748b;
    border-color: #64748b;
}

.btn:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.form-control {
    width: 100%;
    display: block;
    padding: .5rem .75rem;
    font-size: .95rem;
    border: 1px solid #cbd5e1;
    border-radius: .375rem;
    background: #fff;
}

.form-text {
    font-size: .75rem;
    color: #475569;
}

/* ハンバーガーボタン */
.hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
}
.hamburger-btn:hover { background: rgba(255,255,255,.08); }

/* 折りたたみ状態 */
.app-container.collapsed .sidebar { width: 48px; padding-left: .5rem; padding-right: .5rem; }
.app-container.collapsed .sidebar .sidebar-header .brand { display: none; }
.app-container.collapsed .sidebar .sidebar-header:not(:first-child) { display: none; }
.app-container.collapsed .sidebar .nav { display: none; }

.form-actions {
    justify-content: flex-end;
}

.home-title { 
    font-weight: 600; 
    font-size: .95rem; 
    line-height: 1.3; 
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    color: inherit;
    text-decoration: none;
    transition: color .2s ease;
}
.home-title:hover {
    color: #0ea5e9;
}

.detail-header {
    margin-bottom: 1.5rem;
}

.detail-meta {
    letter-spacing: .01em;
}

.detail-html {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    line-height: 1.75;
    color: #0f172a;
}

.detail-html h1,
.detail-html h2,
.detail-html h3 {
    margin-top: 1.25rem;
    font-weight: 600;
    color: #0f172a;
}

.detail-html p {
    margin-bottom: 1rem;
}

.detail-html ul {
    padding-left: 1.25rem;
    margin-bottom: 1rem;
}

.detail-html a {
    color: #0ea5e9;
}

.detail-html a:hover {
    text-decoration: underline;
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}
.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* 右上ユーザー情報の縦センタリング調整 */
.topbar .avatar-sm { display: block; }           /* 画像下の余白を除去 */
.topbar .user-name { line-height: 1; display: inline-block; }  /* テキストの行高を詰める */

/* プロフィール: トリミングモーダルの表示領域 */
.cropper-wrap {
    height: 60vh;
    max-height: 520px;
    min-height: 320px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    position: relative;             /* 内部の cropper-container をフルに広げる */
}
.cropper-wrap img {
    display: block;
    max-width: 100%;
    /* 高さは Cropper 側に任せる（縦パン余地を確保） */
}
/* Cropper のコンテナをラッパーいっぱいに広げる */
.cropper-wrap .cropper-container {
    width: 100% !important;
    height: 100% !important;
}

/* ドロップダウンメニューのスタイル */
.dropdown-menu {
  display: none;
  position: absolute;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
  z-index: 1000;
  right: 0; /* メニューを右揃え */
  transform: translateX(-10px); /* 画面右端から少し内側に寄せる */
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  padding: 0.5rem 1rem;
  color: #212529;
  text-decoration: none;
}

.dropdown-item:hover {
  background-color: #f8f9fa;
  color: #0d6efd;
}

/* ==== 削除: analysis 画面専用スタイル一式 ==== */
/* 以下のブロックを削除します:
   - .analysis-root, .analysis-pane*, .pane-toggle-rail*, .tabs-*（analysis UI専用）
   - .analysis-menubar*, メニュー関連
   - メディアクエリ内の analysis-* と flow-* の analysis依存レイアウト
   - drag-shrink / mobile-open など analysis 専用の可視制御
*/

/* ==== 統合・維持: 共通/レビュー結果/ホーム/プロフィール ==== */
/* 既存の重複 .flow-item.preview や .flow-canvas.panning は下記1箇所に集約し、他の重複定義を削除 */
.flow-item {
  background:#fff;
  border:1px solid #e2e8f0;
  border-radius:6px;
  padding:8px 10px;
  margin:6px 10px;
  position:relative;
  transition:background .15s ease, border-color .15s ease;
}
.flow-item.selected {
  outline:2px solid #0ea5e9;
  border-color:#0ea5e9;
  box-shadow:0 0 0 2px rgba(14,165,233,.15) inset;
}
.flow-item.dragging { opacity:.6; }
.flow-item .item-actions { position:absolute; top:4px; right:6px; display:none; gap:4px; }
.flow-item.selected .item-actions { display:flex; }
.flow-item.preview {
  opacity:.55;
  border-style:dashed;
  background:#f8fafc;
  pointer-events:none;
}
.flow-item:focus { outline:none; }
.flow-item:focus-visible {
  outline:2px solid #0ea5e9;
  outline-offset:2px;
}

.flow-canvas {
  min-height:100%;
  overflow-y:auto;
  border:1px solid transparent;
  border-radius:8px;
  outline:none;
}
.flow-canvas.panning { cursor:grabbing; }
.flow-canvas.canvas-selected {
  border:1px solid #0ea5e9;
  box-shadow:0 0 0 2px rgba(14,165,233,.15) inset;
}
.flow-canvas:focus, .flow-canvas:focus-visible { outline:none; }

/* ホーム/履歴/プロフィール/トップバーの既存スタイルは維持 */