@import './base.css';

/* ---- Buttons ---- */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-mid);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ---- Import modal ---- */
.import-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.import-overlay.active { display: flex; }
.import-dialog {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 28px 24px 22px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: dialog-in 0.15s ease-out;
}
.import-dialog-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.import-dialog-desc {
  font-size: 0.85rem;
  color: var(--text-mid);
  line-height: 1.6;
}
.import-url-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--border);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.import-url-input::placeholder { color: var(--text-dim); }
.import-url-input:focus { outline: none; border-color: var(--accent); }
.import-url-input.error { border-color: var(--accent); animation: shake 0.3s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.import-hint {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin: -4px 0 0;
}
.import-error {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface) 90%);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent 70%);
  border-radius: 6px;
  padding: 8px 12px;
}
.import-error.visible { display: flex; }
.import-error::before { content: '✕'; font-weight: 700; flex-shrink: 0; }
.import-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ---- Empty state ---- */
.deck-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 24px;
}
.deck-empty-msg {
  font-size: 0.95rem;
  color: var(--text-dim);
}
.deck-empty-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.deck-empty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 32px;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  min-width: 160px;
  transition: border-color 0.15s, background 0.15s;
}
.deck-empty-btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface) 94%); }
.deck-empty-icon { font-size: 1.8rem; line-height: 1; color: var(--text-mid); }
.deck-empty-label { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.deck-empty-sub { font-size: 0.76rem; color: var(--text-dim); text-align: center; }

/* ---- Info banner ---- */
.info-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 24px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--blue) 8%, var(--surface) 92%) 0%,
    color-mix(in srgb, var(--blue) 14%, var(--surface) 86%) 50%,
    color-mix(in srgb, var(--blue) 8%, var(--surface) 92%) 100%
  );
  border-bottom: 1px solid color-mix(in srgb, var(--blue) 30%, var(--border) 70%);
  color: var(--text-mid);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}
.info-banner::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: var(--blue);
  opacity: 0.7;
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Ccircle cx='8' cy='8' r='7.5' fill='none' stroke='%23fff' stroke-width='1.2'/%3E%3Crect x='7.2' y='7' width='1.6' height='5' rx='0.6'/%3E%3Ccircle cx='8' cy='4.5' r='1'/%3E%3C/svg%3E");
  background-size: contain;
  background-color: transparent;
  opacity: 1;
}
.info-banner a {
  color: color-mix(in srgb, var(--blue) 90%, #fff 10%);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent 60%);
}
.info-banner a:hover {
  color: #fff;
  text-decoration-color: var(--blue);
}

/* ---- Deck list page ---- */
.deck-list-page { padding: 24px; }

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
  max-width: 1200px;
}

/* カード全体をひとつの枠で囲む */
.deck-card-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.deck-card-wrap:has(.deck-card:hover) { border-color: var(--accent); }

/* アクションフッター */
.deck-card-actions {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 60%, var(--bg) 40%);
}

/* 公式リンク + コピーボタンの行 */
.deck-tomy-row { display: flex; border-bottom: 1px solid var(--border); }

.deck-tomy-link {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-mid);
  text-decoration: none;
  padding: 8px 10px;
  transition: background 0.15s, color 0.15s;
}
.deck-tomy-link:hover { background: rgba(255,255,255,0.04); color: var(--text); }

.deck-copy-btn {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-mid);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.deck-copy-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.deck-copy-btn:disabled { opacity: 0.6; cursor: default; }

/* 削除ボタン */
.deck-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 7px 8px;
  cursor: pointer;
  font-size: 0.75rem;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.deck-delete-btn:hover {
  color: var(--accent);
  background: rgba(233, 69, 96, 0.08);
}

.deck-tomy-disabled {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  opacity: 0.4;
  cursor: default;
}

.deck-card {
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 16px;
  text-decoration: none;
}
.deck-card-colors { display: flex; gap: 6px; margin-bottom: 10px; }

.ink-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.ink-dot-amber    { background: #ffc040; }
.ink-dot-amethyst { background: #c080ff; }
.ink-dot-emerald  { background: #40d090; }
.ink-dot-ruby     { background: #ff6070; }
.ink-dot-sapphire { background: var(--blue); }
.ink-dot-steel    { background: #90a0b0; }

.deck-card-name  { font-size: 0.95rem; font-weight: bold; color: var(--text); }
.deck-card-count { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.deck-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 48px 0;
}

/* ---- Edit page ---- */
header input[type="text"] {
  background: var(--border);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.95rem;
  width: 200px;
}
.ink-btn-amber    { background: #ffc040; }
.ink-btn-amethyst { background: #c080ff; }
.ink-btn-emerald  { background: #40d090; }
.ink-btn-ruby     { background: #ff6070; }
.ink-btn-sapphire { background: var(--blue); }
.ink-btn-steel    { background: #90a0b0; }

.edit-body {
  display: flex;
  height: calc(100vh - 49px);
  overflow: hidden;
}

/* ---- Card browser ---- */
.card-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.browser-toolbar {
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}
.browser-filter-group { display: flex; gap: 6px; align-items: center; }

.filter-ink-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.filter-ink-btn.active { opacity: 0.2; border-color: var(--accent); }

.filter-type-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-mid);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.filter-type-btn.active { border-color: var(--accent); color: var(--accent); opacity: 0.5; text-decoration: line-through; }
.search-row { display: flex; gap: 6px; align-items: center; width: 100%; }
#filter-section { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.browser-filter-row {
  width: 100%;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 52px;
}
.filter-spacer { flex: 1; }
/* ---- Dual slider ---- */
.dual-slider {
  position: relative;
  height: 26px;
  flex: 1;
  min-width: 80px;
}
.ds-track {
  position: absolute;
  left: 7px; right: 7px;
  top: 9px;
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  pointer-events: none;
}
.ds-ticks {
  position: absolute;
  left: 7px; right: 7px;
  top: 16px;
  pointer-events: none;
}
.ds-tick {
  position: absolute;
  width: 1px;
  height: 4px;
  background: var(--border2);
  transform: translateX(-50%);
  opacity: 0.7;
}
.ds-fill {
  position: absolute;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.ds-input {
  position: absolute;
  width: 100%;
  height: 22px;
  top: 0; left: 0;
  margin: 0; padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
}
.ds-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  pointer-events: all;
  position: relative; z-index: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.ds-input::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  pointer-events: all;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.ds-input::-webkit-slider-runnable-track { background: transparent; }
.ds-input::-moz-range-track { background: transparent; border: none; }
.ds-stat-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  width: 100%;
}
.ds-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 180px;
}
.ds-val {
  font-size: 0.72rem;
  color: var(--accent);
  white-space: nowrap;
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}
.filter-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.filter-set-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-mid);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.filter-set-btn.active { border-color: var(--accent); color: var(--accent); opacity: 0.4; text-decoration: line-through; }

.filter-rarity-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filter-rarity-btn.active { border-color: var(--accent); color: var(--accent); opacity: 0.4; text-decoration: line-through; }
.filter-rarity-btn[data-rarity="common"].active        { color: #aaa;    background: rgba(170,170,170,0.12); }
.filter-rarity-btn[data-rarity="uncommon"].active      { color: #60c0ff; background: rgba(96,192,255,0.12); }
.filter-rarity-btn[data-rarity="rare"].active          { color: #ffd060; background: rgba(255,208,96,0.12); }
.filter-rarity-btn[data-rarity="super_rare"].active    { color: #ff9040; background: rgba(255,144,64,0.12); }
.filter-rarity-btn[data-rarity="legendary"].active     { color: #d080ff; background: rgba(208,128,255,0.15); }
.filter-rarity-btn[data-rarity="enchanted"].active     { color: #80ffcc; background: rgba(128,255,204,0.12); }
.filter-rarity-btn[data-rarity="epic"].active          { color: #ffb830; background: rgba(255,184,48,0.12); }
.filter-rarity-btn[data-rarity="iconic"].active        { color: #40d8d0; background: rgba(64,216,208,0.12); }
.filter-rarity-btn[data-rarity="プロモーションカード"].active { color: #ff80c0; background: rgba(255,128,192,0.12); }
.filter-toggle-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-dim);
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filter-toggle-btn.active { border-color: var(--blue); color: var(--blue); background: rgba(64,144,255,0.1); }
.sort-select {
  background: var(--border);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}
.search-mode {
  display: flex;
  border: 1px solid var(--border2);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.search-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 9px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.search-mode-btn.active { background: var(--accent); color: #fff; }
.search-hints { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.search-hints > span { font-size: 0.72rem; color: var(--text-dim); }
.search-hint-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-mid);
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.search-hint-btn:hover { border-color: var(--accent); color: var(--text); }
.search-hint-btn code { font-family: monospace; font-size: 0.72rem; }
.search-hints-collapse { border: none; }
.search-hints-collapse > summary {
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
  list-style: none;
}
.search-hints-collapse > summary::before { content: '▶ '; font-size: 0.6rem; }
.search-hints-collapse[open] > summary::before { content: '▼ '; }
.search-hints-collapse > summary:hover { color: var(--text); }
.search-hints-collapse > .search-hints { margin-top: 4px; }

.browser-toolbar input[type="text"] {
  background: var(--border);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  width: 200px;
}
.browser-toolbar input[type="text"]::placeholder { color: var(--text-dim); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  align-content: start;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.card-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
  touch-action: manipulation; /* ダブルタップズームを防ぐ */
}
.card-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-item.in-deck { border-color: var(--blue); }
.card-item-image {
  width: 100%;
  display: block;
  border-radius: 5px 5px 0 0;
}
.card-item-count {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 0.75rem;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-item.at-max { opacity: 0.45; }
.card-item-max {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}
.browser-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 48px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ---- Deck panel (right) ---- */
.deck-panel {
  width: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: background 0.15s;
}
.deck-panel.drag-over   { background: rgba(64,144,255,0.08); box-shadow: inset 0 0 0 2px var(--blue); }
.card-browser.drag-over { background: rgba(233,69,96,0.06);  box-shadow: inset 0 0 0 2px var(--accent); }
.deck-panel-header {
  padding: 8px 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-mid);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.deck-progress-bar {
  height: 3px;
  background: var(--border2);
  overflow: hidden;
  margin: 0 -16px;
}
.deck-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s, background 0.3s;
}
.deck-progress-fill.full { background: var(--blue); }
.deck-card-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.deck-entry {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  gap: 8px;
  font-size: 0.85rem;
}
.deck-entry-thumb {
  position: relative;
  height: 32px;
  flex-shrink: 0;
}
.thumb-img-wrap {
  position: absolute;
  width: 48px;
  height: 32px;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: -1px 0 3px rgba(0,0,0,0.4);
}
.thumb-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
}
.deck-entry:hover { background: var(--surface); }
.deck-entry-names { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.deck-entry-name { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-entry-version { font-size: 0.72rem; color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-entry-controls { display: flex; align-items: center; gap: 6px; }
.deck-entry-controls button {
  background: var(--border);
  border: none;
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.deck-entry-controls button:hover { background: var(--border2); }
.deck-entry-count { width: 16px; text-align: center; font-weight: bold; }
.deck-panel-empty { padding: 32px 16px; color: var(--text-dim); font-size: 0.85rem; text-align: center; }

/* ---- Deck stats ---- */
.deck-stats {
  border-top: 1px solid var(--border);
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-row2 { display: flex; gap: 10px; }
.stats-section { flex: 1; min-width: 0; }
.stats-title { font-size: 0.65rem; color: var(--text-dim); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

/* マナカーブ */
.stats-curve {
  display: flex;
  gap: 2px;
  height: 60px;
}
.curve-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.curve-count {
  height: 12px;
  font-size: 0.6rem;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
}
.curve-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}
.curve-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 0;
  transition: height 0.2s;
}
.curve-cost {
  height: 12px;
  font-size: 0.6rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* インク色 */
.stats-colors { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.stats-color-item { display: flex; align-items: center; gap: 3px; }
.stats-num { font-size: 0.75rem; font-weight: 600; color: var(--text); }

/* タイプ */
.stats-types { display: flex; flex-direction: column; gap: 2px; }
.stats-type-item { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.stats-type-label { font-size: 0.72rem; color: var(--text-mid); }

/* インクウェル */
.inkwell-ratio-bar {
  height: 5px;
  background: var(--border2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}
.inkwell-ratio-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}
.inkwell-ratio-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-mid);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--text-mid);
}
.pagination button {
  background: var(--border);
  border: none;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}
.pagination button:disabled { opacity: 0.3; cursor: default; }
.pagination button:not(:disabled):hover { background: var(--border2); }

/* ---- Mobile tabs ---- */
.mobile-tabs {
  display: none;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.mobile-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.mobile-tab.active { border-bottom-color: var(--accent); color: var(--text); }
.mobile-tab.drag-over-add    { background: rgba(64,144,255,0.25); box-shadow: inset 0 0 0 2px var(--blue);   color: #fff; }
.mobile-tab.drag-over-remove { background: rgba(233,69,96,0.25);  box-shadow: inset 0 0 0 2px var(--accent); color: #fff; }

.mobile-filter-toggle { display: none; }

/* ---- Touch drag ghost ---- */
.touch-drag-ghost {
  position: fixed;
  width: 80px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
  opacity: 0.85;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.touch-drag-ghost img {
  width: 100%;
  display: block;
  border-radius: 6px;
}

/* ---- Back confirm dialog ---- */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.confirm-overlay.active { display: flex; }
.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 28px 24px 20px;
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: dialog-in 0.15s ease-out;
}
@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.confirm-icon { font-size: 2rem; line-height: 1; }
.confirm-title { font-size: 1rem; font-weight: 700; color: var(--text); text-align: center; }
.confirm-body  { font-size: 0.82rem; color: var(--text-mid); text-align: center; margin-bottom: 4px; }
.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.confirm-btn { width: 100%; justify-content: center; }
.btn-outline-danger {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-outline-danger:hover { background: rgba(233, 69, 96, 0.1); }

/* ---- Card modal ---- */
#card-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#card-modal.active { display: flex; }
#card-modal img {
  max-width: min(90vw, 400px);
  max-height: 90vh;
  border-radius: 8px;
  pointer-events: none;
}

/* ---- Mobile responsive ---- */
@media (max-width: 767px) {
  header input[type="text"] { width: auto; flex: 1; min-width: 0; }

  .ds-stat-item { min-width: 100%; }

  .mobile-tabs { display: flex; }

  body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

  /* 横スクロール + snap で2パネルをスワイプ切り替え */
  .edit-body {
    flex: 1;
    min-height: 0;
    flex-direction: row;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  .edit-body::-webkit-scrollbar { display: none; } /* Chrome/Safari */

  .card-browser {
    flex-shrink: 0;
    flex: none;
    width: 100vw;
    min-height: 0;
    border-right: none;
    border-bottom: none;
    overflow: hidden;
    scroll-snap-align: start;
  }
  .card-browser.tab-inactive { display: flex; } /* 常に表示 */

  .deck-panel {
    flex-shrink: 0;
    flex: none;
    width: 100vw;
    display: flex !important; /* 常に表示 */
    min-height: 0;
    max-height: none;
    scroll-snap-align: start;
  }
  .deck-panel.tab-active { display: flex; } /* no-op */

  .mobile-filter-toggle {
    display: block;
    background: transparent;
    border: 1px solid var(--border2);
    color: var(--text-mid);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  #filter-section { display: none; }
  #filter-section.open { display: flex; flex-direction: column; gap: 4px; }

  .browser-toolbar input[type="text"] { width: auto; flex: 1; min-width: 0; }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    overflow-y: auto;
  }

  .deck-entry { padding: 6px 12px; }
  .deck-entry-controls button { width: 32px; height: 32px; font-size: 1rem; }
  .deck-entry-count { width: 20px; font-size: 0.9rem; }
}
