/* AI画像生成タグ・フレーズ辞典 — style.css
   ダークベースは既存プロンプトビルダー系と統一 (#0f0f13 系) */

:root {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --surface-2: #22222c;
  --border: #2e2e3a;
  --text: #e8e8ee;
  --text-sub: #9a9aac;
  --accent: #8f7ff0;       /* 辞典のメインアクセント（各カードはカテゴリ色で上書き） */
  --danger: #e07777;
  --warn-bg: #2c2416;
  --warn-border: #7a6430;
  --warn-text: #e8d9a8;
  --radius: 12px;
  --tap: 44px;
  --maxw: 640px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 14px;
}

/* ---------- 固定ヘッダー ---------- */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 15, 19, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 14px 8px;
}

h1.app-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}
h1.app-title .sub { color: var(--text-sub); font-weight: 400; font-size: 12px; margin-left: 6px; }

.search-row {
  display: flex;
  gap: 8px;
}

#search-input {
  flex: 1;
  min-height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px; /* iOSズーム防止 */
  padding: 8px 14px;
}
#search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#search-input::placeholder { color: var(--text-sub); }

#search-clear {
  min-width: var(--tap);
  min-height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-sub);
  font-size: 16px;
}

/* タブ */
nav.tabs {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  min-height: 38px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-sub);
  font-size: 13px;
  white-space: nowrap;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- 汎用 ---------- */
main { padding-top: 12px; }
section[hidden] { display: none !important; }

h3 { font-size: 14px; margin: 14px 0 8px; color: var(--text); }
h4 { font-size: 13px; margin: 10px 0 6px; color: var(--text); }

.empty {
  color: var(--text-sub);
  font-size: 13px;
  padding: 24px 8px;
  text-align: center;
}

button { cursor: pointer; font-family: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 13px;
  white-space: nowrap;
}
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #14141a;
  font-weight: 700;
}
.pill.small { min-height: 32px; padding: 4px 12px; font-size: 12px; }

.pill-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
  scrollbar-width: none;
}
.pill-row::-webkit-scrollbar { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  min-height: 36px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #14141a;
  font-weight: 600;
}

.mini-btn {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--accent);
  border: none;
  color: #14141a;
  font-size: 13px;
  font-weight: 600;
}
.mini-btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-weight: 400;
}

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 16px;
}
.icon-btn.active { color: #ffd76a; border-color: #6a5a2a; }
.icon-btn.sel-btn.active { color: #14141a; background: var(--accent); border-color: var(--accent); }
.icon-btn.danger { color: var(--danger); }

/* ---------- タグカード ---------- */
.tag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.tag-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.tag-names {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 0;
  min-height: var(--tap);
}

.tag-ja {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
}

.tag-en {
  color: var(--accent);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: 1px;
  word-break: break-all;
}

.tag-actions { display: flex; gap: 6px; flex-shrink: 0; }

.tag-summary {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-sub);
}

.badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-phrase {
  background: #2a3242;
  color: #9fc0e8;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

/* 詳細 */
.tag-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}
.kv { margin: 4px 0; color: var(--text); }
.kv-label {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-sub);
  font-size: 11px;
  border-radius: 6px;
  padding: 1px 8px;
  margin-right: 8px;
}
.link-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.link-row.danger .kv-label { color: var(--danger); }
.chip-link {
  min-height: 32px;
  padding: 3px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
}
.detail-actions { margin-top: 8px; }

/* 比較ブロック */
.comparison {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
}
.comp-axis { color: var(--text-sub); font-size: 12px; margin: 2px 0 6px; }
.comp-list { list-style: none; margin: 0; padding: 0; }
.comp-list li {
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}
.comp-list li.current { background: rgba(143, 127, 240, 0.12); }
.comp-name {
  display: block;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  text-align: left;
  min-height: 28px;
}
.comp-note { display: block; color: var(--text-sub); font-size: 12px; }
.comp-tips {
  margin: 8px 0 0;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  color: var(--warn-text);
  font-size: 12px;
}

/* ---------- 検索ホーム・曖昧語 ---------- */
.home-block { margin-bottom: 18px; }
.home-head { display: flex; justify-content: space-between; align-items: center; }

.alias-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.alias-note { margin: 0 0 4px; font-size: 13px; color: var(--warn-text); }

#search-status {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- レシピ ---------- */
.recipe-desc { color: var(--text-sub); font-size: 13px; }
.slot { margin-bottom: 8px; }
.warn-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 12px 0;
}
.warn-box h4 { margin: 0 0 4px; color: var(--warn-text); }
.warn-box p { margin: 3px 0; font-size: 13px; color: var(--warn-text); }

.recipe-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 14px;
}
.preview-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
  margin: 4px 0 10px;
}
.recipe-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.saved-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.saved-name { flex: 1; font-size: 13px; }

/* ---------- 選択中 ---------- */
.sel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.sel-info { flex: 1; min-width: 0; }
.sel-ja { display: block; font-size: 14px; font-weight: 600; }
.sel-en {
  display: block;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}
.sel-ctl { display: flex; gap: 4px; flex-shrink: 0; }

.fmt-box { margin-top: 16px; }
.copy-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
  margin: 8px 0;
  -webkit-user-select: text;
  user-select: text;
}

/* ---------- 下部固定バー ---------- */
#selection-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: rgba(20, 20, 27, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
}
.bar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bar-label { flex: 1; font-size: 13px; color: var(--text-sub); }
#bar-count { color: var(--text); font-weight: 700; font-size: 15px; }
#selection-bar .mini-btn { min-height: var(--tap); }
#selection-bar:not(.has-items) .mini-btn { opacity: 0.45; }

/* ---------- 注意書き ---------- */
.disclaimer {
  margin: 24px 0 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-sub);
}
.disclaimer h4 { margin: 0 0 4px; font-size: 12px; color: var(--text); }
.disclaimer p { margin: 3px 0; }

/* ---------- トースト ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: #2c2c38;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
  max-width: 88vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- ローディング ---------- */
#loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-sub);
}
.load-error { color: var(--danger); font-size: 14px; margin: 6px 0; }
.load-error-sub { color: var(--text-sub); font-size: 12px; }

@media (max-width: 360px) {
  body { font-size: 14px; }
  .tab { font-size: 12px; padding: 6px 8px; }
}
