/* ==========================================
   my wardrobe - スタイルシート
   iPhone最適化・日本語フォント対応
   ========================================== */

/* ----------------------------------------
   CSS変数（カラーテーマ）
   ---------------------------------------- */
:root {
  --color-primary: #E8B4B8;       /* メインピンク */
  --color-primary-dark: #C8829A;  /* 濃いピンク */
  --color-primary-light: #F9E8EA; /* 薄いピンク（背景） */
  --color-bg: #FAFAFA;            /* 背景 */
  --color-surface: #FFFFFF;       /* カード・パネル背景 */
  --color-border: #EEEEEE;        /* ボーダー */
  --color-text: #333333;          /* メインテキスト */
  --color-text-sub: #888888;      /* サブテキスト */
  --color-danger: #E05555;        /* 削除ボタンなど */
  --color-badge-dispose: #E07050; /* 処分バッジ */
  --color-badge-sell: #50A0C8;    /* 売却バッジ */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
  --font: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Helvetica Neue', Arial, sans-serif;
  --nav-height: 60px;
  --header-height: 52px;
}

/* ----------------------------------------
   リセット・ベーススタイル
   ---------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: var(--font);
  font-size: 16px; /* iOSのズーム防止（16px未満でズームが発生する） */
}

img {
  display: block;
  max-width: 100%;
}

/* ----------------------------------------
   画面レイアウト（SPA・各画面）
   ---------------------------------------- */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh; /* dynamic viewport height（iPhone対応） */
  overflow: hidden;
  position: relative;
}

/* ----------------------------------------
   ヘッダー（各画面上部）
   ---------------------------------------- */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  /* Safe Area（iPhone ノッチ対応）*/
  padding-top: env(safe-area-inset-top, 0px);
  min-height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
}

.screen-header h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.back-btn {
  font-size: 15px;
  color: var(--color-primary-dark);
  padding: 8px 4px;
  min-width: 60px;
}

.header-spacer {
  min-width: 60px;
}

/* タイトルの「my（名前）」部分：タップで名前変更 */
#title-my {
  cursor: pointer;
  border-bottom: 1px dotted var(--color-primary-dark);
}

/* 設定ボタン（⚙️） */
.settings-btn {
  font-size: 20px;
  padding: 8px 4px;
  min-width: 60px;
  text-align: right;
  line-height: 1;
  color: var(--color-text-sub);
}

/* ----------------------------------------
   ボトムナビゲーション
   ---------------------------------------- */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  color: var(--color-text-sub);
  padding: 8px 0;
  transition: color 0.15s;
}

.nav-btn.active {
  color: var(--color-primary-dark);
}

.nav-btn .nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* ----------------------------------------
   一覧画面（screen-list）
   ---------------------------------------- */

/* カテゴリータブ */
.tabs-wrapper {
  display: flex;
  align-items: stretch;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* 「すべて」タブ固定エリア（スクロールしても常に見える） */
.tab-all-fixed {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 2px 0 4px;
}

/* 固定タブとスクロールタブの縦区切り線 */
.tabs-divider {
  width: 1px;
  background: var(--color-border);
  flex-shrink: 0;
  margin: 6px 0;
}

.tabs-scroll {
  display: flex;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 8px;
  gap: 4px;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-sub);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  user-select: none;
}

.tab-btn.active {
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
  font-weight: 700;
}

.tab-btn.dragging {
  opacity: 0.4;
}

.tab-count {
  font-size: 11px;
  background: var(--color-border);
  color: var(--color-text-sub);
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}

.tab-btn.active .tab-count {
  background: var(--color-primary);
  color: white;
}

/* シーズンタブ */
.season-tabs {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 12px;
  gap: 8px;
  background: var(--color-bg);
  flex-shrink: 0;
}

.season-tabs::-webkit-scrollbar {
  display: none;
}

.season-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-sub);
  border: 1.5px solid var(--color-border);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
  background: var(--color-surface);
}

.season-btn.active {
  color: var(--color-primary-dark);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  font-weight: 700;
}

/* ----------------------------------------
   アイテムリスト（1行1アイテム）
   ---------------------------------------- */
.item-grid {
  flex: 1;
  min-height: 0; /* Safari: flex子要素でoverflow-y scrollを有効にするための必須指定 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  /* ボトムナビ＋FABボタンの高さ分余白を確保 */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 72px);
}

/* アイテム名（type="search"）の × ボタンを非表示 */
#field-name::-webkit-search-cancel-button,
#field-name::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

.item-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  transition: transform 0.15s;
  user-select: none;
}

.item-card:active {
  transform: scale(0.98);
}

.item-card.dragging {
  opacity: 0.3;
}

/* サムネイル（小・左側） */
.item-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.item-thumb.placeholder {
  background: #F0F0F0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-thumb.placeholder::after {
  content: '📷';
  font-size: 20px;
  opacity: 0.4;
}

/* アイテム情報（中央） */
.item-info {
  flex: 1;
  min-width: 0; /* テキスト省略のため */
}

.item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub {
  font-size: 11px;
  color: var(--color-text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
}

/* ドラッグハンドル（右端） */
.drag-handle {
  font-size: 18px;
  color: #CCCCCC;
  padding: 4px 6px;
  flex-shrink: 0;
  letter-spacing: -1px;
}

/* 一覧 追加ボタン（FAB） */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--color-primary-dark);
  color: white;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(200, 130, 154, 0.5);
  z-index: 90;
  line-height: 1;
}

.fab:active {
  transform: scale(0.92);
}

/* 空の状態 */
.empty-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-sub);
  font-size: 14px;
  line-height: 1.8;
}

/* ----------------------------------------
   詳細画面（screen-detail）
   ---------------------------------------- */
.detail-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  /* ボトムナビの高さ分余白 */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* 詳細上部：写真＋タグ */
.detail-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.detail-photo {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.detail-photo.placeholder {
  width: 100px;
  height: 100px;
  background: #F0F0F0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-photo.placeholder::after {
  content: '📷';
  font-size: 28px;
  opacity: 0.35;
}

.detail-tags {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tag-label {
  font-size: 10px;
  color: var(--color-text-sub);
  margin-right: 2px;
  min-width: 55px;
}

.tag {
  font-size: 11px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: 20px;
  padding: 2px 8px;
}

.tag-empty {
  font-size: 11px;
  color: #BBBBBB;
}

/* アイテム名（詳細） */
.detail-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* 詳細グリッド（2列） */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.detail-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.detail-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-label {
  display: block;
  font-size: 10px;
  color: var(--color-text-sub);
  margin-bottom: 3px;
}

.detail-value {
  font-size: 14px;
  font-weight: 500;
}

.detail-row .detail-label {
  margin-bottom: 0;
  flex-shrink: 0;
}

/* 手放し候補行 */
.disposal-row {
  background: #FFF5F5;
  border-color: #FFCCCC;
}

/* メモ欄 */
.detail-memo {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  min-height: 60px;
}

.memo-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-all;
}

/* 詳細アクションボタン */
.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-bottom: 8px;
}

/* ----------------------------------------
   フォーム画面（screen-form）
   詳細画面と同じ配置・大きさに統一
   ---------------------------------------- */
.form-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  /* ナビバー＋保存ボタンが隠れないよう余白を確保 */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* フォーム上部：写真（左）＋ カテゴリー・シーズン（右） */
.form-top-section {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

/* 写真列（左） */
.form-photo-col {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* 写真プレビュー（詳細の detail-photo と同じサイズ） */
.photo-preview-small {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--color-border);
  background: #F8F8F8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.photo-preview-small:active {
  border-color: var(--color-primary);
}

.photo-preview-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder-small {
  font-size: 24px;
  opacity: 0.35;
  text-align: center;
  line-height: 1.3;
}

.photo-remove-btn {
  font-size: 11px;
  color: var(--color-danger);
  text-decoration: underline;
  display: none;
  white-space: nowrap;
}

/* カテゴリー・シーズン列（右） */
.form-tags-col {
  flex: 1;
  min-width: 0;
}

/* フォーム内インラインラベル（detail-label と同スタイル） */
.form-inline-label {
  display: block;
  font-size: 10px;
  color: var(--color-text-sub);
  margin-bottom: 4px;
  font-weight: 600;
}

/* コンパクトチェックボックス（2列・右カラム用） */
.checkbox-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  margin-bottom: 8px;
}

.checkbox-compact .checkbox-item {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.checkbox-compact .checkbox-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary-dark);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-compact .checkbox-item span {
  font-size: 12px;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* フォームグループ（全幅フィールド用） */
.form-group {
  margin-bottom: 8px;
}

.form-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-sub);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 4px;
}

/* テキスト入力（全幅フィールド） */
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-input::placeholder {
  color: #CCCCCC;
}

/* テキストエリア */
textarea.form-input {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

/* ----------------------------------------
   フォーム2列グリッド（詳細画面と同じ構造）
   ---------------------------------------- */
.form-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

/* 詳細画面の detail-col に相当するフォームボックス */
.detail-col-form {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color 0.15s;
}

.detail-col-form:focus-within {
  border-color: var(--color-primary);
}

/* ボックス内の入力（ボーダーなし・透明背景） */
.form-input-inline {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px; /* iOSズーム防止 */
  color: var(--color-text);
  padding: 2px 0;
  -webkit-appearance: none;
}

.form-input-inline:focus {
  outline: none;
}

.form-input-inline::placeholder {
  color: #CCCCCC;
}

/* 2列グリッド内の評価ボタン（小さめに調整） */
.detail-col-form .rating-group {
  display: flex;
  gap: 1px;
  margin-top: 2px;
}

.detail-col-form .rating-btn {
  font-size: 18px;
  line-height: 1;
  opacity: 0.22;
  padding: 2px 1px;
  transition: opacity 0.1s;
}

.detail-col-form .rating-btn.active {
  opacity: 1;
}

/* 手放し候補 */
.disposal-row-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.disposal-row-form label {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.disposal-row-form input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-danger);
  cursor: pointer;
}

/* 処分/売却ラジオ */
.disposal-options {
  display: none;
  gap: 12px;
  padding: 10px 14px;
  background: #FFF5F5;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}

.disposal-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.disposal-options input[type="radio"] {
  accent-color: var(--color-danger);
  width: 18px;
  height: 18px;
}

/* 保存ボタンエリア */
.form-submit-area {
  padding: 8px 0 4px;
}

/* ----------------------------------------
   処分候補一覧（screen-disposal）
   ---------------------------------------- */
.disposal-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.disposal-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}

.disposal-item:active {
  transform: scale(0.98);
}

.disposal-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.disposal-thumb.placeholder {
  background: #F0F0F0;
  display: block;
}

.disposal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.disposal-name {
  font-size: 15px;
  font-weight: 600;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.badge-dispose {
  background: var(--color-badge-dispose);
}

.badge-sell {
  background: var(--color-badge-sell);
}

.badge-none {
  background: #BBBBBB;
}

/* ----------------------------------------
   共通ボタン
   ---------------------------------------- */
.btn {
  flex: 1;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-primary {
  background: var(--color-primary-dark);
  color: white;
}

.btn-secondary {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.btn-danger {
  background: #FFEEEE;
  color: var(--color-danger);
}

/* ----------------------------------------
   ドラッグ中のゴースト要素
   ---------------------------------------- */
.drag-ghost {
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22) !important;
  border-radius: var(--radius-md);
  transform: scale(1.03);
}

/* ----------------------------------------
   所持枚数ステッパー（キーボードを出さない ー 数字 ＋ UI）
   ---------------------------------------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 28px; /* 高さ固定：キーボード出現の影響を受けない */
}

.stepper-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s;
}

.stepper-btn:active {
  background: var(--color-primary);
  color: white;
}

.stepper-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  min-width: 24px;
  text-align: center;
}

/* ----------------------------------------
   グリッドモード（2列）
   JSで2件ずつ .grid-row に束ねる方式。
   コンテナはリストモードと同じflex-columnのまま維持し、
   Safariの高さ圧縮バグを根本回避する。
   ---------------------------------------- */

/* grid-mode時のコンテナ：flex-columnはそのまま（変更なし）。
   gapをrow間隔に合わせる。 */
.item-grid.grid-mode {
  gap: 10px;
}

/* 1行分のラッパー（2列） */
.grid-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  flex-shrink: 0; /* 行を絶対に圧縮しない */
}

/* カード：幅固定・blockでシンプルに */
/* (100vw - padding12×2 - gap10) / 2 = 50vw - 17px */
.item-grid.grid-mode .item-card {
  display: block;
  width: calc(50vw - 17px);
  flex-shrink: 0;
  padding: 0;
  overflow: hidden;
}

/* 写真：幅・高さとも明示固定で正方形を保証 */
.item-grid.grid-mode .item-thumb {
  display: block;
  width: calc(50vw - 17px);
  height: calc(50vw - 17px);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  object-fit: cover;
}

/* プレースホルダー：同サイズ固定＋カメラアイコンを中央に */
.item-grid.grid-mode .item-thumb.placeholder {
  width: calc(50vw - 17px);
  height: calc(50vw - 17px);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-grid.grid-mode .item-thumb.placeholder::after {
  font-size: 28px;
}

/* アイテム名エリア：blockで写真の下に自然表示 */
.item-grid.grid-mode .item-info {
  display: block;
  padding: 8px 8px 6px;
}

.item-grid.grid-mode .item-name {
  font-size: 13px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: unset;
}

/* ----------------------------------------
   並び替えナビボタン（アクティブ時）
   ---------------------------------------- */
#nav-sort.sort-active {
  color: var(--color-primary-dark);
}

/* ----------------------------------------
   ソートシート（ボトムシート）
   ---------------------------------------- */
.sort-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 140;
}

.sort-backdrop.open {
  display: block;
}

.sort-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 150;
  padding: 12px 16px;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
  box-shadow: var(--shadow-lg);
}

.sort-sheet.open {
  display: block;
}

.sort-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 14px;
}

.sort-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sort-sheet-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-sub);
  text-align: center;
  margin-bottom: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex: 1;
}

.sort-apply-btn {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary-dark);
  padding: 6px 4px;
  min-width: 60px;
  text-align: right;
}

.sort-cancel-btn {
  font-size: 14px;
  color: var(--color-text-sub);
  padding: 6px 4px;
  min-width: 60px;
}

.sort-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  color: var(--color-text);
  transition: background 0.1s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sort-option:active {
  background: var(--color-primary-light);
}

.sort-option.active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.sort-dir {
  font-size: 13px;
  color: var(--color-text-sub);
  font-weight: 400;
}

.sort-option.active .sort-dir {
  color: var(--color-primary-dark);
}

/* ----------------------------------------
   カラーテーマ選択
   ---------------------------------------- */
.color-options {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 20px 16px 8px;
  flex-wrap: wrap;
}

.color-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: transform 0.15s, outline-color 0.15s;
  flex-shrink: 0;
}

.color-circle.active {
  outline-color: #555555;
  transform: scale(1.12);
}

.color-circle:active {
  transform: scale(0.95);
}

/* ----------------------------------------
   設定シート：セクションラベル・データ管理ボタン
   ---------------------------------------- */
.settings-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-sub);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 4px 4px;
}

.settings-data-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
}

.settings-data-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 12px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.settings-data-btn:active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.settings-data-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.settings-data-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-data-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.settings-data-desc {
  font-size: 12px;
  color: var(--color-text-sub);
}
