:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-strong: #f0f4f3;
  --ink: #1e2523;
  --muted: #68736f;
  --line: #d9dfdc;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --gold: #b7791f;
  --red: #b83232;
  --shadow: 0 14px 34px rgba(28, 42, 39, 0.12);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.app-header {
  background: #173b35;
  color: #fff;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  min-height: 168px;
  padding: 26px 28px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
}

.kicker {
  margin: 0 0 8px;
  color: #b8d6d0;
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(104px, 1fr));
  gap: 10px;
}

.stat-strip div {
  min-height: 74px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.stat-strip strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.stat-strip span {
  display: block;
  margin-top: 8px;
  color: #cfe4df;
  font-size: 12px;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 28px 40px;
}

.controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(28, 42, 39, 0.06);
}

.search-row,
.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter-row {
  margin-top: 12px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 260px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  min-height: 44px;
}

.search-box input {
  width: 100%;
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon {
  text-align: center;
  color: var(--muted);
  font-size: 22px;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.toggle,
#resetButton {
  min-height: 42px;
  border: 0;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

.toggle + .toggle {
  border-left: 1px solid var(--line);
}

.toggle.active {
  background: var(--accent);
  color: #fff;
}

.filter-row label {
  display: grid;
  gap: 5px;
  min-width: 168px;
  color: var(--muted);
  font-size: 12px;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 34px 0 10px;
}

.content-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.side-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.breakdown {
  display: grid;
  gap: 9px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.bar {
  grid-column: 1 / -1;
  height: 6px;
  background: #e6ebe8;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.results-area {
  min-width: 0;
}

.results-head {
  height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.results-head p {
  margin: 0;
  color: var(--muted);
}

#resetButton {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cards-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(286px, 1fr));
  gap: 14px;
}

.channel-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 310px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(28, 42, 39, 0.05);
}

.thumb {
  aspect-ratio: 16 / 9;
  background: #dce5e1;
  position: relative;
}

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

.thumb-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  color: #fff;
  background: #0f766e;
}

.frequency-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.94);
  color: #fff;
  font-size: 12px;
}

.card-body {
  padding: 13px;
  display: grid;
  gap: 10px;
}

.card-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.card-title-row h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.category-pill {
  white-space: nowrap;
  border: 1px solid #c9ddd7;
  background: #ecf6f3;
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric strong {
  display: block;
  font-size: 17px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  max-width: 100%;
  border-radius: 999px;
  background: #f2f0e8;
  color: #5d5544;
  padding: 4px 7px;
  font-size: 11px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.table-view {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f3f7f5;
  z-index: 1;
  color: #44514c;
}

tr:last-child td {
  border-bottom: 0;
}

.table-name {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  text-align: left;
  font-weight: 700;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 18, 16, 0.42);
  z-index: 20;
}

.detail-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(520px, 100%);
  overflow-y: auto;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 21;
  padding: 22px;
}

.close-button {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
}

.detail-hero {
  margin-top: 8px;
}

.detail-hero h2 {
  margin: 14px 0 8px;
  font-size: 26px;
  line-height: 1.2;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kv {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.video-list {
  display: grid;
  gap: 8px;
}

.video-list a {
  color: var(--accent-strong);
  text-decoration: none;
  line-height: 1.45;
}

.compact-header .header-inner {
  min-height: 92px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.site-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.site-title a,
.static-nav a {
  color: #fff;
  text-decoration: none;
}

.static-nav {
  display: flex;
  gap: 14px;
  align-items: center;
}

.static-nav a {
  color: #cfe4df;
}

.seo-index-content,
.seo-page {
  max-width: 1120px;
  margin: 26px auto 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seo-index-content h2,
.seo-page h1,
.seo-detail h2 {
  margin: 0 0 10px;
}

.seo-index-content p,
.lead {
  color: var(--muted);
  line-height: 1.7;
}

.seo-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.seo-link-grid a,
.breadcrumbs a {
  color: var(--accent-strong);
  text-decoration: none;
}

.seo-link-grid a {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #c9ddd7;
  border-radius: 8px;
  background: #ecf6f3;
  font-weight: 700;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs span::before,
.breadcrumbs a + a::before {
  content: "/";
  color: var(--muted);
  margin-right: 8px;
}

.seo-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.seo-summary-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.seo-summary-grid strong {
  display: block;
  font-size: 24px;
}

.seo-summary-grid span,
.seo-dl dt,
.seo-video-list time {
  color: var(--muted);
  font-size: 12px;
}

.seo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.seo-list-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.seo-list-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.seo-list-card h3 a,
.seo-video-list a {
  color: var(--accent-strong);
  text-decoration: none;
}

.seo-list-card p {
  color: var(--muted);
  line-height: 1.6;
}

.seo-list-card dl,
.seo-dl {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.seo-list-card dl div,
.seo-dl div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
}

.seo-list-card dt,
.seo-dl dt {
  margin: 0;
}

.seo-list-card dd,
.seo-dl dd {
  margin: 0;
}

.seo-detail {
  margin-top: 24px;
}

.seo-video-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
}

.seo-video-list li {
  line-height: 1.5;
}

.seo-video-list time {
  display: block;
  margin-top: 3px;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .header-inner {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .stat-strip {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .side-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .search-row {
    display: grid;
  }

  .search-box {
    min-width: 0;
  }

  .view-toggle {
    width: 100%;
  }

  .toggle {
    flex: 1;
  }

  .filter-row label {
    width: 100%;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .metric-row,
  .kv-grid {
    grid-template-columns: 1fr;
  }
}
