/* ========== Reset & Theme ========== */
:root {
  --bg: #0d1117;
  --fg: #e6edf3;
  --muted: #9aa4b2;
  --primary: #6366f1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ========== Layout ========== */
.container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ========== Topbar ========== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #161b22;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .brand-logo { width: 28px; height: 28px; }
.topbar .nav { display: flex; gap: 10px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 0;
  text-decoration: none;
  transition: background .2s, box-shadow .2s, transform .1s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.subtle { background: rgba(255,255,255,0.08); color: var(--fg); }
.btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* 操作不可でも見た目を揃える */
.btn.disabled,
.btn[aria-disabled="true"]{
  pointer-events: none;
  opacity: .45;
  filter: grayscale(12%);
}

/* ========== Card (汎用) ========== */
.card {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

/* ========== Login ========== */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card { width: 320px; padding: 20px; }
.login-wrap { text-align: center; }
.logo { width: 64px; margin-bottom: 20px; }

/* ========== Chips ========== */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(255,255,255,0.08);
  padding: 4px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

/* ========== Text helpers ========== */
.error { color: #f87171; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 12px; }

/* ========== NG Words UI ========== */
.ng-panel { padding: 18px 18px 14px; }

.ng-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:10px;
}
.ng-header h2 { margin:0; }
.ng-meta { color:var(--muted); font-size:12px; }

/* 入力行 */
.row.gap-8[action*="ngwords"]{
  position: relative;
  isolation: isolate;
  display:flex; gap: 12px; align-items:center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    0 1px 0 rgba(255,255,255,.04) inset,
    0 10px 24px rgba(0,0,0,.25) inset;
}
.row.gap-8[action*="ngwords"] input[name="word"]{
  flex: 1;
  height: 44px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 0 14px 0 40px;
  color: var(--fg);
  background:
    linear-gradient(#0c1016, #0c1016) padding-box,
    linear-gradient(120deg, rgba(99,102,241,.9), rgba(56,189,248,.85)) border-box;
  box-shadow:
    0 0 0 0 rgba(99,102,241,0),
    0 6px 16px rgba(0,0,0,.35) inset;
  transition: box-shadow .2s, background .2s;
  background-image:
    url("data:image/svg+xml;utf8,\
      <svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a5b4fc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-3.5-3.5'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 18px 18px;
}
.row.gap-8[action*="ngwords"] input[name="word"]:focus{
  outline: none;
  box-shadow:
    0 0 0 4px rgba(99,102,241,.18),
    0 6px 16px rgba(0,0,0,.35) inset;
}
.row.gap-8[action*="ngwords"] input[name="word"]::placeholder{
  color: rgba(255,255,255,.55);
}

/* 入力中インジケータ */
.row.gap-8[action*="ngwords"]::after{
  content: "";
  position: absolute; inset: -8px -8px auto auto;
  width: 10px; height: 10px; border-radius: 50%;
  background: transparent;
  transition: background .2s, box-shadow .2s;
}
.row.gap-8[action*="ngwords"].is-typing::after{
  background: #60a5fa;
  box-shadow: 0 0 0 6px rgba(96,165,250,.18);
}

/* 追加ボタン */
.row.gap-8[action*="ngwords"] .btn.primary{
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, #7c83ff, #6366f1);
  color: white;
  box-shadow:
    0 8px 18px rgba(99,102,241,.35),
    0 1px 0 rgba(255,255,255,.12) inset;
  transition: transform .06s ease, box-shadow .2s, filter .2s;
}
.row.gap-8[action*="ngwords"] .btn.primary:hover{
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow:
    0 12px 26px rgba(99,102,241,.45),
    0 1px 0 rgba(255,255,255,.22) inset;
}

/* ツールバー */
.ng-toolbar {
  margin-top:12px; display:flex; gap:10px; align-items:center; justify-content:space-between;
}
.ng-actions { display:flex; gap:8px; }

/* NGワードのタグ一覧 */
.chips {
  margin-top:12px;
  display:flex; flex-wrap:wrap; gap:10px;
  max-height: 52vh; overflow:auto; padding:8px;
  border:1px solid rgba(255,255,255,0.06);
  border-radius:16px;
  background:
    radial-gradient(1200px 300px at top left, rgba(99,102,241,.06), transparent 60%),
    radial-gradient(800px 200px at bottom right, rgba(56,189,248,.06), transparent 55%),
    rgba(255,255,255,0.02);
  backdrop-filter: blur(6px);
}
.chips .chip {
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  box-shadow:
    0 1px 0 rgba(255,255,255,.08) inset,
    0 8px 18px rgba(0,0,0,.25);
  transition: transform .08s ease, box-shadow .2s, border-color .2s, background .2s;
}
.chips .chip:hover {
  transform: translateY(-1px);
  border-color: rgba(99,102,241,.5);
  box-shadow:
    0 1px 0 rgba(255,255,255,.12) inset,
    0 12px 24px rgba(0,0,0,.35);
  background: linear-gradient(180deg, rgba(99,102,241,.12), rgba(255,255,255,.04));
}
.chips .chip .icon-btn {
  width:22px; height:22px; border:0; border-radius:999px; cursor:pointer;
  display:inline-grid; place-items:center;
  color:#fff; background:rgba(255,255,255,.12);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: background .15s, transform .08s ease, box-shadow .2s;
}
.chips .chip .icon-btn:hover {
  background: #ef4444;
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 16px rgba(239,68,68,.45);
}

/* NGリストのスクロールバー */
.chips::-webkit-scrollbar { height:10px; width:10px; }
.chips::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(99,102,241,.45), rgba(56,189,248,.45));
  border-radius:10px;
}
.chips::-webkit-scrollbar-track { background: transparent; }

/* Small screen tweaks */
@media (max-width: 720px){
  .ng-toolbar { flex-direction:column; align-items:stretch; }
  .ng-actions { justify-content:flex-end; }
  .row.gap-8[action*="ngwords"]{ flex-direction: column; align-items:stretch; }
  .row.gap-8[action*="ngwords"] .btn.primary{ width:100%; }
}

/* ========== Generic grids & components ========== */
.gap-16 { gap: 16px; }
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* ========== Product Card (検索/登録 共通) ========== */
.product-card{
  display:flex; flex-direction:column; gap:10px;
  background:#0f141b;
  border:1px solid rgba(255,255,255,.06);
  border-radius:14px; padding:12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.product-thumb{
  position:relative; height:160px; border-radius:10px; overflow:hidden;
  background:#0b0f14; display:grid; place-items:center;
  border:1px solid rgba(255,255,255,.06);
}
.product-thumb img{ max-width:100%; max-height:100%; display:block; }

.product-body{ display:flex; flex-direction:column; gap:6px; }
.product-title{
  font-size:15px; margin:0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.product-actions{ display:flex; gap:8px; justify-content:flex-end; }

/* 登録カード編集用 */
.product-card--editable .product-title-input{
  width:100%; height:36px; border-radius:10px; border:1px solid rgba(255,255,255,.1);
  background:#0b0f14; color:var(--fg); padding:0 10px;
}
.inline-input{
  width:100%; height:32px; border-radius:8px; border:1px solid rgba(255,255,255,.1);
  background:#0b0f14; color:var(--fg); padding:0 8px;
}
.product-thumb .check{
  position:absolute; top:8px; left:8px;
  display:inline-flex; gap:6px; align-items:center;
  background:rgba(0,0,0,.35);
  border:1px solid rgba(255,255,255,.12);
  border-radius:999px; padding:4px 8px; font-size:12px;
}

/* ========== Tables (履歴など) ========== */
.table {
  width:100%;
  border-collapse: collapse;
  font-size:14px;
}
.table th, .table td {
  padding:10px;
  border-bottom:1px solid rgba(255,255,255,.08);
  vertical-align: top;
}
.table th { text-align:left; color: var(--muted); font-weight:600; }

/* ========== Badges & Terminal (system) ========== */
.badge{
  display:inline-block; padding:4px 8px; border-radius:999px; font-size:12px;
  border:1px solid rgba(255,255,255,.1);
}
.badge.success{ background:rgba(34,197,94,.15); color:#86efac; }
.badge.danger{  background:rgba(239,68,68,.15); color:#fca5a5; }

.terminal{
  background:#0b0f14;
  border:1px solid rgba(255,255,255,.08);
  border-radius:10px;
  padding:12px;
  min-height:80px;
  white-space:pre-wrap;
}

/* ========== Empty state ========== */
.empty-state{
  display:grid; place-items:center; text-align:center; padding:30px 12px;
  border:1px dashed rgba(255,255,255,.12); border-radius:14px;
  background:rgba(255,255,255,.02);
}
.empty-illust{ font-size:36px; margin-bottom:8px; }
.empty-title{ font-weight:700; margin-bottom:4px; }
.empty-sub{ color:var(--muted); font-size:13px; }

/* ========== 検索結果カードのサムネ（常に枠を表示） ========== */
.result-card .thumb {
  position: relative;
  border: 1px solid rgba(255,255,255,.08);   /* 常に枠を出す */
  border-radius: 14px;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(255,255,255,.03), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  overflow: hidden;
  aspect-ratio: 16 / 9;  /* 枠比率固定 */
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 枠の内側にうっすら線 */
.result-card .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
  pointer-events: none;
}

.result-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 画像エラー時のプレースホルダ用 */
.result-card .thumb.is-empty {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,.04) 0 10px,
      rgba(255,255,255,.02) 10px 20px
    );
}
.result-card .thumb.is-empty .ph {
  opacity: .66;
  font-size: 34px;
  letter-spacing: .08em;
}
/* 共通ボタン */
/* 共通ボタン */
.btn {
  display: inline-block;
  padding: 4px 10px;         /* ← 小さめ */
  margin: 3px 2px;
  font-size: 0.8rem;         /* ← 小さめ */
  font-weight: 600;
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease-in-out;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* 登録ボタン (青グラデーション) */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-2px);
}

/* メルカリ (赤ピンクグラデーション) */
.btn-mercari {
  background: linear-gradient(135deg, #ff6b6b, #ff4757);
  color: #fff;
}
.btn-mercari:hover {
  background: linear-gradient(135deg, #ff4757, #e63946);
  transform: translateY(-2px);
}

/* Amazon (オレンジグラデーション) */
.btn-amazon {
  background: linear-gradient(135deg, #ffb347, #ff9900);
  color: #111;
}
.btn-amazon:hover {
  background: linear-gradient(135deg, #ff9900, #e68a00);
  transform: translateY(-2px);
}
/* カード枠 */
.card.set-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.set-thumb img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.set-body { padding: 12px; }
.set-title,
.result-card .product-title {
  color: #000 !important;
}
.set-price { color: #111827; font-weight: 700; }

.set-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eee;
  margin-top: auto;
}

.btn { padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-primary { background: #2563eb; color: #fff; border: 1px solid transparent; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: #fff; color: #111; border: 1px solid #d1d5db; }
.btn-outline:hover { background: #f9fafb; }
.btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border: none;
}
.btn.danger:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.flash-messages {
  margin: 16px 0;
}
.alert {
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.alert-success {
  background: #e6ffed;
  color: #056608;
  border: 1px solid #8ee6a3;
}
.alert-error {
  background: #ffe6e6;
  color: #8a0000;
  border: 1px solid #e69e9e;
}
.alert-info {
  background: #e6f3ff;
  color: #004c8a;
  border: 1px solid #9ecae6;
}
