:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --text: #15202b;
  --muted: #5f6b7a;
  --line: #d9e0e8;

  /* Brand (一元管理) */
  --brand-primary: #17aa5d;
  --brand-primary-hover: #138f4f;
  --brand-primary-active: #0f7a43;
  --brand-primary-dark: #0b4d2e;
  --brand-primary-light: #e9f8f0;
  --brand-primary-lighter: #f4fbf7;
  --brand-primary-border: #b9e5cb;
  --brand-primary-focus: rgba(23, 170, 93, 0.24);

  /* 後方互換エイリアス */
  --brand-hover: var(--brand-primary-hover);
  --brand-dark: var(--brand-primary-active);
  --brand-darker: var(--brand-primary-dark);
  --brand-light: var(--brand-primary-light);
  --brand-border: var(--brand-primary-border);
  --brand-focus: var(--brand-primary-focus);

  --sidebar-bg: #0b4d2e;
  --sidebar-nav-active: #176b4a;
  --sidebar-nav-hover: #12583d;

  /* Accent aliases → brand */
  --accent: var(--brand-primary);
  --accent-hover: var(--brand-primary-hover);
  --accent-soft: var(--brand-primary-light);
  --accent-muted: var(--brand-primary-border);

  /* Status (ブランドと混同しない) */
  --ok: #1a7f4b;
  --ok-bg: #e8f6ee;
  --warn: #9a6700;
  --warn-bg: #fff8e6;
  --danger: #b42318;
  --disabled: #9ca3af;
  --disabled-bg: #e5e7eb;
  --shadow: 0 8px 24px rgba(21, 32, 43, 0.06);
  --radius: 12px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

/* .field { display:flex } などが [hidden] を上書きしないようにする */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.75rem;
  padding: 0.15rem 0.25rem 0.35rem;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-primary-active);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  color: #fff;
}

.brand-logo-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.brand-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.brand-sub {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  text-align: left;
}

.nav-btn:hover {
  background: var(--sidebar-nav-hover);
  color: #fff;
}

.nav-btn.active {
  background: var(--sidebar-nav-active);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  opacity: 0.85;
  width: 1.1rem;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

main {
  padding: 1.25rem 1.5rem 2rem;
  width: 100%;
}

.panel {
  display: none;
  margin: 0 auto;
  width: 100%;
}
.panel.active { display: block; }

#panel-home { max-width: 1240px; }
#panel-targets { max-width: 1200px; }
#panel-notifications { max-width: 1080px; }
#panel-keywords { max-width: 1080px; }
#panel-results { max-width: 1360px; }

.setup-complete {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 8px;
  font-weight: 700;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card.highlight {
  border-color: var(--brand-border);
  background: linear-gradient(180deg, var(--brand-light) 0%, #fff 100%);
}

.card h2 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Home section accordion */
.home-acc {
  padding: 0;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.home-acc:hover:not([data-open="true"]) {
  background: var(--brand-primary-light);
}

.home-acc[data-open="true"] {
  background: var(--brand-primary-lighter);
  border-color: var(--brand-primary);
}

.home-acc-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: none;
  background: transparent;
  padding: 1rem 1.15rem;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
  min-height: 44px;
  border-radius: 0;
}

.home-acc-toggle:hover {
  background: var(--brand-primary-light);
}

.home-acc-toggle:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
  box-shadow: 0 0 0 3px var(--brand-primary-focus);
}

.home-acc-titles {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  min-width: 0;
  flex: 1;
}

.home-acc-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.home-acc[data-open="true"] .home-acc-title {
  color: var(--brand-primary-active);
}

.home-acc-summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brand-primary-active);
  min-width: 0;
  word-break: break-word;
}

.home-acc-chevron {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  position: relative;
  color: var(--brand-primary-active);
  margin-left: auto;
}

.home-acc-chevron::before {
  content: "";
  position: absolute;
  inset: 0.25rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  transform-origin: center;
}

.home-acc[data-open="true"] .home-acc-chevron::before {
  transform: rotate(225deg);
  margin-top: 0.15rem;
}

.home-acc-body {
  padding: 0 1.15rem 1.15rem;
  min-width: 0;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.hero-card {
  background: var(--brand-primary-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.hero-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.hero-card p {
  margin: 0 0 1.25rem;
  opacity: 0.92;
  font-size: 0.92rem;
  max-width: 52ch;
}

.run-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.92rem;
  cursor: pointer;
  font-family: inherit;
}

.btn.primary {
  background: var(--brand-primary);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
}

.btn.primary:active:not(:disabled) {
  background: var(--brand-primary-active);
}

.hero-card .btn.primary {
  background: #fff;
  color: var(--brand-primary-active);
  font-weight: 600;
}

.hero-card .btn.primary:hover:not(:disabled) {
  background: var(--brand-primary-light);
}

.btn.primary.large {
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
}

.btn.secondary {
  background: var(--brand-primary-light);
  color: var(--brand-primary-active);
  border: 1px solid var(--brand-primary-border);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--brand-primary-lighter);
}

.btn.secondary.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.pref-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pref-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  background: #fafbfc;
}

.pref-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.block-hint {
  margin: 0.35rem 0 0.65rem;
}

.scope-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.kanto-grid {
  max-height: none;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn:disabled {
  background: var(--disabled-bg);
  color: var(--disabled);
  opacity: 1;
  cursor: not-allowed;
  border-color: transparent;
}

.btn.ghost:disabled {
  background: transparent;
  color: var(--disabled);
  border-color: var(--line);
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.stat .num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat .lbl {
  font-size: 0.78rem;
  color: var(--muted);
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.checklist li:last-child { border-bottom: none; }

.check-icon {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.check-icon.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.check-icon.ng {
  background: var(--warn-bg);
  color: var(--warn);
}

.banner {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.banner.warn {
  background: var(--warn-bg);
  border: 1px solid #f0d78c;
  color: var(--warn);
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

textarea, .search-input {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}

.search-input {
  font-family: inherit;
  font-size: 0.95rem;
}

.example-box {
  background: #f7f9fb;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.example-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.example-box code {
  display: block;
  font-size: 0.82rem;
  margin: 0.25rem 0;
}

.region-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
}

.pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.toggle-row input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--brand-primary);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand-primary);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--brand-primary-focus);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.35rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}

.grid label {
  font-size: 0.82rem;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 0.75rem 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  z-index: 5;
}

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #fcfdfe;
}

.item-card:hover {
  border-color: var(--accent-muted);
}

.item-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.45;
}

.item-link a {
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
}

.item-link a:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.log {
  background: #1a2332;
  color: #d8e2ec;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  padding: 0.85rem;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--brand-primary-dark);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

/* —— v2 additions —— */
.brand-logo {
  width: 100%;
  height: 100%;
  max-width: 34px;
  max-height: 34px;
  border-radius: 7px;
  object-fit: contain;
  display: block;
  aspect-ratio: 1;
}

.brand-logo-wrap .brand-mark {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  font-size: 1rem;
}

.preview-badge {
  display: none;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
  min-height: 1.5rem;
  border: 1px solid transparent;
}

.env-badge.env-prod {
  color: var(--brand-primary-active);
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-border);
}

.env-badge.env-preview {
  color: #7a5b00;
  background: var(--warn-bg);
  border-color: #ead9a0;
}

.menu-toggle { display: none; }

.loading-bar {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.banner.danger {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f3c1bb;
  margin: 0.75rem 1.25rem 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.banner.info {
  background: #eef6ff;
  color: #0b4d7a;
  border: 1px solid #bfd8f2;
  margin: 0.75rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.stat .num.small {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.card-head h2 { margin: 0; }

.dirty-hint {
  color: var(--brand-primary-active);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field input, .field select, .field textarea {
  font-weight: 400;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  min-height: 42px;
}

.field input:focus, .field select:focus, .field textarea:focus,
.tag-input:focus-within, .btn:focus-visible, .nav-btn:focus-visible, a:focus-visible,
.agency-cat-toggle:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--brand-primary-focus);
}

.readonly-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: #f8fbf9;
}

.readonly-field strong {
  display: block;
  color: var(--text);
  font-size: 0.98rem;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  min-height: 44px;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.setup-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.setup-steps li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfe;
}

.setup-steps li.done { border-color: var(--accent-muted); background: var(--ok-bg); }

.step-no { font-size: 0.75rem; font-weight: 700; color: var(--accent); }
.step-state { font-size: 0.8rem; color: var(--muted); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin: 0;
}

.summary-grid dt { font-size: 0.78rem; color: var(--muted); }
.summary-grid dd { margin: 0.15rem 0 0; font-weight: 600; }
.summary-grid a {
  font-weight: 500;
  font-size: 0.85rem;
  margin-left: 0.35rem;
  color: var(--brand-dark);
  text-decoration: none;
}
.summary-grid a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

a {
  color: var(--brand-dark);
}
a:hover {
  color: var(--brand-hover);
}

.run-list { display: flex; flex-direction: column; gap: 0.65rem; }
.run-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  background: #fcfdfe;
}
.run-main { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.run-meta { font-size: 0.82rem; color: var(--muted); margin-top: 0.25rem; }
.run-msg { font-size: 0.82rem; margin-top: 0.25rem; color: var(--warn); }
.run-actions { margin-top: 0.5rem; }
.status-pill[data-status="skipped"] { background: #eef2f6; color: var(--muted); }
.run-detail-list { display: grid; gap: 0.75rem; }
.run-detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: #fcfdfe;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.status-pill[data-status="success"] { background: var(--ok-bg); color: var(--ok); }
.status-pill[data-status="partial"] { background: var(--warn-bg); color: var(--warn); }
.status-pill[data-status="failed"] { background: #fdecea; color: var(--danger); }

.keyword-cards { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.kw-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  background: #fcfdfe;
}
.kw-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.kw-card-actions { display: flex; gap: 0.35rem; }
.danger-text { color: var(--danger) !important; }
.hint.micro { font-size: 0.78rem; margin: 0.15rem 0 0.75rem; }

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem;
  min-height: 44px;
  background: #fff;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.82rem;
}
.tag button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--brand-dark);
  font-size: 1rem;
  line-height: 1;
  min-width: 24px;
  min-height: 24px;
  opacity: 0.85;
}
.tag button:hover {
  opacity: 1;
  color: var(--danger);
}
.tag-input > input {
  border: 0;
  flex: 1;
  min-width: 120px;
  padding: 0.35rem;
  font-size: 0.9rem;
  outline: none;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  background: #fff;
}

.agency-cats { display: flex; flex-direction: column; gap: 0.65rem; }

.agency-cat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.agency-cat:hover:not([data-open="true"]) {
  background: var(--brand-primary-lighter);
}

.agency-cat[data-open="true"] {
  background: var(--brand-primary-lighter);
  border-color: var(--brand-primary);
}

.agency-cat-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
}

.agency-cat-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: none;
  background: transparent;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  border-radius: 6px;
}

.agency-cat-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.agency-cat-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.agency-cat[data-open="true"] .agency-cat-title {
  color: var(--brand-primary-active);
}

.agency-cat-title {
  flex-shrink: 1;
  min-width: 0;
}

.pref-summary-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-primary-active);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
}

.agency-cat-chevron {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  position: relative;
  color: var(--brand-primary-active);
}

.agency-cat-chevron::before {
  content: "";
  position: absolute;
  inset: 0.25rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  transform-origin: center;
}

.agency-cat[data-open="true"] .agency-cat-chevron::before {
  transform: rotate(225deg);
  margin-top: 0.15rem;
}

.agency-cat-enable {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
}

.cat-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0.85rem 0.85rem;
}

.cat-body .pref-quick-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cat-pref-grid { margin-top: 0.15rem; max-height: none; }
.muted { color: var(--muted); font-weight: 500; font-size: 0.9rem; }

.home-diff-list {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.home-diff-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.9rem;
}

.home-diff-cat {
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
}

.home-diff-tag {
  display: inline-block;
  width: fit-content;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-primary-active);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
}

.home-diff-more {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--brand-primary-active);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.filters-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.filters-card .card-head h2 { margin: 0; }
.filters-toggle { display: none; }

.items-summary {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.items-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 1rem 0 0.5rem;
}

.pager-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.pager-compact { display: none; font-size: 0.9rem; color: var(--muted); font-weight: 600; }

.pager-page.is-current,
.btn.secondary.small.pager-page.is-current {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary-active);
  font-weight: 700;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.85rem;
}

.empty-actions a {
  color: var(--accent);
  font-size: 0.9rem;
}

.reload-btn {
  font-size: 0.82rem;
  color: var(--muted);
  border-color: transparent;
  padding: 0.35rem 0.65rem;
  min-height: 36px;
}

.reload-btn:hover {
  color: var(--text);
  border-color: var(--line);
  background: transparent;
}

.nav-backdrop {
  display: none;
}

.items-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.75rem; }
.item-title-btn {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.item-title-btn:hover { color: var(--accent); }
.item-top { display: flex; gap: 0.5rem; align-items: flex-start; }
.new-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--brand-primary);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  margin-top: 0.35rem;
}
.item-meta { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.item-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0; }
.item-link {
  display: inline-block;
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
  min-height: 44px;
  line-height: 44px;
}
.item-link:hover { text-decoration: underline; }
.chip {
  font-size: 0.75rem;
  background: var(--brand-primary-light);
  color: var(--brand-primary-active);
  border: 1px solid var(--brand-primary-border);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

.detail-drawer { position: fixed; inset: 0; z-index: 80; }
.detail-backdrop { position: absolute; inset: 0; background: rgba(21,32,43,0.35); }
.detail-panel {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: min(440px, 100%);
  background: #fff;
  padding: 1.25rem;
  overflow: auto;
  box-shadow: var(--shadow);
}
.detail-dl { display: grid; gap: 0.75rem; margin: 1rem 0 1.25rem; }
.detail-dl dt { font-size: 0.78rem; color: var(--muted); }
.detail-dl dd { margin: 0.15rem 0 0; }

.btn.small { padding: 0.35rem 0.65rem; font-size: 0.82rem; min-height: 36px; }

@media (max-width: 800px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .app {
    flex-direction: column;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .menu-toggle { display: inline-flex; min-width: 44px; min-height: 44px; }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(21, 32, 43, 0.4);
    z-index: 55;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 88vw);
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    padding: 0.75rem;
  }

  body.nav-open .sidebar { transform: translateX(0); }
  .side-nav { flex-direction: column; overflow: visible; }
  .brand { margin-bottom: 0.75rem; }
  .sidebar-foot { display: none; }

  .main-wrap,
  main,
  .panel,
  .card,
  .item-card {
    min-width: 0;
    max-width: 100%;
  }

  main { padding: 1rem; }

  .topbar {
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    align-items: center;
  }

  .topbar h1 {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .env-badge,
  .preview-badge {
    margin-left: 0;
    flex-shrink: 0;
    font-size: 0.68rem;
    padding: 0.15rem 0.4rem;
  }

  .topbar-actions { flex-shrink: 0; }

  .reload-btn {
    padding: 0.35rem 0.45rem;
    font-size: 0;
    min-width: 40px;
    min-height: 40px;
  }

  .reload-btn::before {
    content: "↻";
    font-size: 1.05rem;
    color: var(--muted);
  }

  .stats { grid-template-columns: 1fr 1fr; gap: 0.65rem; }

  .setup-steps li { grid-template-columns: 1fr; }

  .home-summary,
  .summary-row,
  .home-diff-list li {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-acc-toggle {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    gap: 0.35rem 0.5rem;
  }

  .home-acc-titles {
    flex: 1 1 calc(100% - 2rem);
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .home-acc-chevron {
    margin-left: 0;
    margin-top: 0.15rem;
  }

  .home-acc-summary {
    width: 100%;
    font-size: 0.78rem;
    line-height: 1.4;
  }

  .kanto-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .kanto-grid label {
    min-height: 44px;
    align-items: center;
  }

  .agency-cat-head {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .agency-cat-toggle {
    flex: 1 1 100%;
    width: 100%;
  }

  .agency-cat-enable {
    flex: 1 1 100%;
    justify-content: flex-start;
    border-top: 1px solid var(--line);
    margin: 0 0.35rem 0.35rem;
    padding: 0.55rem 0.5rem;
  }

  .keyword-cards .keyword-card,
  .keyword-card {
    display: flex;
    flex-direction: column;
  }

  .filters-toggle {
    display: inline-flex;
  }

  .filters-body:not(.is-open) {
    display: none;
  }

  .filters-body.is-open {
    display: block;
  }

  .filters-grid { grid-template-columns: 1fr; }

  .item-meta {
    flex-direction: column;
    gap: 0.25rem;
  }

  .pager-pages { display: none; }
  .pager-compact { display: inline-block; }

  .items-pager {
    justify-content: space-between;
    gap: 0.75rem;
  }

  .pager-prev,
  .pager-next {
    min-height: 44px;
    min-width: 72px;
  }

  .brand-logo-wrap {
    width: 36px;
    height: 36px;
  }

  .brand-title { font-size: 0.9rem; }
}
