:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --line: #d8dee6;
  --text: #18202a;
  --muted: #637083;
  --accent: #d7263d;
  --accent-dark: #a5162b;
  --green: #1d7f54;
  --amber: #9b6411;
  --shadow: 0 18px 42px rgba(22, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  padding-bottom: 96px;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  color: #f7fafc;
  background: #111820;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: #aab6c4;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #c8d2de;
  text-decoration: none;
}

.nav a[aria-current="page"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav span {
  width: 18px;
  text-align: center;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
}

.status-pill,
.key-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
}

.status-pill[data-state="ready"],
.key-state[data-state="ready"] {
  color: var(--green);
  border-color: rgba(29, 127, 84, 0.25);
  background: rgba(29, 127, 84, 0.08);
}

.status-pill[data-state="missing"],
.key-state[data-state="missing"] {
  color: var(--amber);
  border-color: rgba(155, 100, 17, 0.25);
  background: rgba(155, 100, 17, 0.09);
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.summary-layout {
  display: grid;
  gap: 18px;
  max-width: 1120px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard {
  display: grid;
  gap: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.manual-video-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.manual-video-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.manual-video-form input,
.manual-video-form select,
.manual-video-form textarea {
  width: min(320px, 48vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.manual-video-form input,
.manual-video-form select {
  height: 40px;
  padding: 0 11px;
}

.manual-video-form select {
  width: 96px;
}

.manual-video-form textarea {
  min-height: 40px;
  max-height: 88px;
  padding: 9px 11px;
  resize: vertical;
}

.manual-video-form input:disabled,
.manual-video-form select:disabled,
.manual-video-form textarea:disabled {
  background: #f5f7f9;
}

.manual-video-result {
  max-width: min(460px, 70vw);
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-search-progress {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 112px;
  height: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.manual-search-progress[hidden] {
  display: none;
}

.manual-search-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: rgba(29, 127, 84, 0.18);
}

.manual-search-progress strong {
  position: relative;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.manual-video-result[data-state="added"] {
  color: var(--green);
}

.manual-video-result[data-state="existing"] {
  color: #303b49;
}

.manual-video-result[data-state="error"] {
  color: var(--accent);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 98px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.15;
}

.ranking-panel {
  overflow: hidden;
}

.ranking-panel.is-youtube-mode {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.keyword-group-tabs,
.category-tabs,
.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.category-tabs {
  padding-bottom: 10px;
}

.category-tabs[hidden] {
  display: none;
}

.keyword-group-tabs {
  padding-bottom: 10px;
  background: #f9fbfc;
}

.bookmark-add-form {
  justify-content: flex-start;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.bookmark-add-form[hidden] {
  display: none;
}

.bookmark-add-form input {
  width: min(460px, 54vw);
}

.view-tabs {
  justify-content: flex-end;
  padding-top: 10px;
  padding-bottom: 10px;
}

.ranking-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.filter-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.translation-progress {
  display: grid;
  gap: 10px;
  padding: 12px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.translation-progress[hidden] {
  display: none;
}

.translation-progress-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  color: #303b49;
  font-size: 13px;
}

.translation-progress-copy strong {
  font-size: 14px;
  font-weight: 900;
}

.translation-progress-copy span {
  color: var(--muted);
  font-weight: 800;
}

.translation-progress-meter {
  overflow: hidden;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #dce5ef;
}

.translation-progress-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.filter-toggle {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #303b49;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.filter-toggle[aria-pressed="true"] {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.number-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.number-filter input {
  width: 132px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  background: #fff;
}

.number-filter input:disabled {
  background: #f5f7f9;
}

.date-filter {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.date-filter label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-filter input {
  width: 84px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  background: #fff;
}

.quick-filter-button {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #303b49;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
}

.quick-filter-button:hover,
.quick-filter-button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 78px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #303b49;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.keyword-tab-label {
  display: grid;
  gap: 2px;
  text-align: left;
  line-height: 1.15;
}

.keyword-tab-label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tab-button[aria-pressed="true"] {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.table-wrap {
  overflow-x: auto;
}

.youtube-list-view {
  display: grid;
  gap: 24px;
  width: 100%;
  max-width: 1580px;
  margin: 0 auto;
  padding: 24px 28px 36px;
  background: #fff;
}

.youtube-list-view[hidden] {
  display: none;
}

.youtube-result-item {
  display: grid;
  grid-template-columns: 38px minmax(360px, 520px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  min-width: 0;
  cursor: pointer;
}

.youtube-result-rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: 4px;
  border-radius: 8px;
  color: #303b49;
  background: #f5f7f9;
  font-size: 14px;
  font-weight: 900;
}

.youtube-result-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #eef2f6;
  cursor: pointer;
  overflow: hidden;
  text-decoration: none;
}

.youtube-result-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.youtube-result-thumb span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  background: rgba(15, 23, 32, 0.88);
  font-size: 12px;
  font-weight: 900;
}

.youtube-result-body {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding-top: 1px;
}

.youtube-result-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: start;
  gap: 10px;
}

.youtube-title-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.youtube-result-title {
  display: -webkit-box;
  overflow: hidden;
  max-width: 920px;
  padding: 0;
  border: 0;
  color: #0f0f0f;
  background: transparent;
  cursor: pointer;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font: inherit;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.28;
  text-align: left;
  text-decoration: none;
}

.youtube-original-title {
  display: -webkit-box;
  overflow: hidden;
  max-width: 920px;
  color: #606060;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  line-height: 1.35;
}

.youtube-result-title:hover {
  color: #0f0f0f;
}

.youtube-result-menu {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #0f0f0f;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

.youtube-result-menu:hover {
  background: #f2f2f2;
}

.youtube-result-meta,
.youtube-result-channel,
.youtube-result-stats,
.youtube-result-chapter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  color: #606060;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
}

.youtube-result-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
}

.youtube-result-channel {
  margin-top: 6px;
  gap: 8px;
}

.youtube-channel-avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: #5f6368;
  font-size: 12px;
  font-weight: 800;
}

.youtube-channel-name {
  color: #606060;
}

.youtube-result-description {
  display: -webkit-box;
  overflow: hidden;
  max-width: 920px;
  margin: 2px 0 0;
  color: #606060;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  line-height: 1.45;
}

.youtube-result-chapter {
  display: grid;
  grid-template-columns: 72px auto auto auto auto 1fr;
  min-height: 46px;
  max-width: 920px;
  margin-top: 4px;
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  background: #f2f2f2;
  color: #535353;
  font-weight: 500;
  overflow: hidden;
}

.youtube-result-mini-thumb {
  display: block;
  overflow: hidden;
  width: 64px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: #ddd;
}

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

.youtube-result-chapter-caret {
  justify-self: end;
  color: #0f0f0f;
  font-size: 18px;
  line-height: 1;
}

.youtube-result-stats {
  margin-top: 2px;
  gap: 8px;
  color: #303b49;
}

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f9fbfc;
  font-size: 12px;
  font-weight: 900;
}

.sortable-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.sort-button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.sort-button[aria-pressed="true"] {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

td {
  font-size: 14px;
}

tbody tr {
  cursor: pointer;
}

.rank-cell {
  width: 70px;
  color: var(--muted);
  font-weight: 900;
}

.bookmark-cell {
  width: 58px;
  text-align: center;
}

.video-bookmark-star {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.video-bookmark-star[aria-pressed="true"] {
  border-color: rgba(29, 127, 84, 0.32);
  background: rgba(29, 127, 84, 0.08);
}

.efficiency-cell {
  font-weight: 900;
}

.source-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.video-cell {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.video-cell img {
  width: 96px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-muted);
}

.video-cell-copy,
.video-cell strong,
.video-cell small {
  display: block;
}

.video-title-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.video-title-button strong {
  display: -webkit-box;
  overflow: hidden;
  max-width: 520px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.3;
}

.video-title-button:hover strong {
  color: var(--accent);
}

.video-original-title {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.video-cell small,
.video-channel-line {
  margin-top: 5px;
  color: var(--muted);
}

.video-inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.video-inline-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
}

.video-cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.video-shorts-chip,
.video-keyword-chip,
.video-hide-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #303b49;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.video-shorts-chip,
.video-keyword-chip,
.video-hide-chip {
  cursor: pointer;
  font-family: inherit;
}

.video-hide-chip {
  color: var(--amber);
}

.video-manual-label {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.video-shorts-chip:hover,
.video-bookmark-star:hover,
.video-keyword-chip:hover,
.video-hide-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.delta-cell {
  color: var(--green);
  font-weight: 900;
}

.delta-cell span,
.delta-cell small {
  display: block;
}

.delta-cell small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.action-cell {
  white-space: nowrap;
}

.action-cell-inner {
  display: grid;
  align-items: center;
  gap: 6px;
}

.table-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #303b49;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.table-action-button {
  cursor: pointer;
  font-family: inherit;
}

.table-action-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.compact-empty {
  min-height: 280px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.settings-form {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.summary-test-form {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.summary-test-form label {
  color: #303b49;
  font-size: 14px;
  font-weight: 700;
}

.summary-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.summary-input-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.summary-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 38, 61, 0.14);
}

.settings-form label {
  color: #303b49;
  font-size: 14px;
  font-weight: 700;
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.settings-form > input,
.secret-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.settings-form > input:focus,
.secret-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 38, 61, 0.14);
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-muted);
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  padding: 0 18px;
  color: #303b49;
  border-color: var(--line);
  background: #fff;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.help-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.compact-panel {
  padding: 22px;
}

.summary-result-panel {
  overflow: hidden;
}

.summary-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.summary-result-header h2 {
  margin-bottom: 8px;
}

.summary-result-header a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.summary-error {
  margin: 22px;
  padding: 16px;
  border: 1px solid rgba(215, 38, 61, 0.22);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(215, 38, 61, 0.07);
  font-weight: 800;
}

.summary-error[hidden] {
  display: none;
}

.summary-output {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.summary-output[hidden] {
  display: none;
}

.summary-block {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.summary-block h3 {
  margin: 0;
  font-size: 15px;
}

.summary-block p,
.summary-block ul {
  margin: 0;
  color: #303b49;
  line-height: 1.65;
}

.summary-block ul {
  padding-left: 20px;
}

.summary-details {
  padding: 0 22px 22px;
}

.summary-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.summary-details ul {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.summary-details li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #303b49;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.summary-details li[data-state="ready"] {
  color: var(--green);
  border-color: rgba(29, 127, 84, 0.25);
  background: rgba(29, 127, 84, 0.08);
}

.summary-details li[data-state="missing"] {
  color: var(--amber);
  border-color: rgba(155, 100, 17, 0.25);
  background: rgba(155, 100, 17, 0.09);
}

.summary-details pre {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #303b49;
  background: #f9fbfc;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.dev-data-panel {
  grid-column: 1 / -1;
}

.search-config-panel {
  grid-column: 1 / -1;
}

.search-config-body {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.config-grid,
.quota-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.quota-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.config-field,
.keyword-setting-row,
.quota-summary div {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.config-field span,
.config-field small,
.keyword-setting-row span,
.keyword-setting-row small,
.quota-summary span,
.quota-summary strong {
  display: block;
}

.config-field span,
.keyword-setting-row span,
.quota-summary strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.config-field small,
.keyword-setting-row small,
.quota-summary span {
  color: var(--muted);
  font-size: 12px;
}

.config-field input,
.keyword-setting-row input,
.keyword-setting-row textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.config-field input,
.keyword-setting-row input {
  height: 36px;
  padding: 0 10px;
  font-weight: 800;
}

.keyword-setting-row textarea {
  min-height: 82px;
  padding: 10px;
  resize: vertical;
  line-height: 1.5;
}

.keyword-settings-header,
.keyword-setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 40px;
  align-items: start;
  gap: 12px;
}

.keyword-settings-header {
  align-items: center;
  padding-top: 4px;
}

.keyword-settings-header h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.keyword-settings-list {
  display: grid;
  gap: 12px;
}

.keyword-terms-field {
  min-width: 0;
}

.remove-keyword-group {
  align-self: end;
}

.dev-data-body {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-list {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
}

.meta-list div {
  display: grid;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.meta-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.meta-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 420px;
  padding: 64px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state p {
  max-width: 460px;
  margin-bottom: 0;
  color: var(--muted);
}

.empty-visual {
  display: flex;
  align-items: end;
  gap: 8px;
  width: 92px;
  height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.empty-visual span {
  display: block;
  width: 18px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
}

.empty-visual span:nth-child(1) {
  height: 28px;
}

.empty-visual span:nth-child(2) {
  height: 46px;
  background: #1d7f54;
}

.empty-visual span:nth-child(3) {
  height: 34px;
  background: #2f6fed;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 112px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: #17202a;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
}

.version-footer {
  position: fixed;
  right: 30px;
  bottom: 18px;
  left: 290px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(240px, 1.2fr);
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #303b49;
  background: #fff;
  box-shadow: 0 10px 28px rgba(22, 32, 42, 0.08);
}

.version-node {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.version-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.version-node strong,
.version-footer p {
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.version-node strong {
  font-weight: 900;
}

.version-footer p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.version-footer p[data-state="ready"] {
  color: var(--green);
}

.version-footer p[data-state="missing"] {
  color: var(--amber);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(15, 23, 32, 0.48);
}

.modal-backdrop[hidden],
.history-tooltip[hidden] {
  display: none;
}

.history-modal {
  width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 32, 0.24);
}

.history-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.history-modal-header h2 {
  display: -webkit-box;
  overflow: hidden;
  max-width: calc(100vw - 160px);
  margin: 2px 0 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 18px;
  line-height: 1.35;
}

.history-modal-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history-chart-wrap {
  position: relative;
  overflow-x: auto;
  padding: 18px 22px 22px;
}

.history-chart {
  display: block;
  width: max(100%, 1600px);
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.chart-axis {
  stroke: #d9e0e7;
  stroke-width: 1.5;
}

.chart-grid-line {
  stroke: #e8edf2;
  stroke-width: 1;
}

.chart-axis-label,
.chart-empty {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-estimated-line {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2.5;
  stroke-dasharray: 7 6;
  stroke-linecap: round;
}

.chart-point,
.chart-hover-point,
.chart-estimated-point {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-estimated-point {
  stroke: #94a3b8;
}

.chart-gap-marker {
  stroke: #94a3b8;
  stroke-width: 2;
  stroke-linecap: round;
}

.chart-hover-line {
  stroke: #303b49;
  stroke-dasharray: 4 4;
  stroke-width: 1.5;
}

.history-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 168px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 10px 28px rgba(22, 32, 42, 0.12);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

@media (max-width: 860px) {
  body {
    padding-bottom: 148px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
  }

  .nav {
    grid-auto-flow: column;
  }

  .nav a {
    min-height: 38px;
  }

  .main {
    padding: 20px 14px;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .summary-input-row {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .youtube-list-view {
    padding: 20px 0 28px;
  }

  .youtube-result-item {
    grid-template-columns: 34px minmax(260px, 320px) minmax(0, 1fr);
  }

  .config-grid,
  .quota-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .keyword-settings-header,
  .keyword-setting-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .version-footer {
    right: 14px;
    bottom: 14px;
    left: 14px;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toast {
    right: 14px;
    bottom: 164px;
    max-width: calc(100vw - 28px);
  }
}

@media (max-width: 520px) {
  .brand small {
    display: none;
  }

  .nav a {
    padding: 0 10px;
  }

  .panel-header,
  .settings-form {
    padding: 18px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dev-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-group {
    width: 100%;
  }

  .youtube-result-item {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
  }

  .youtube-result-thumb,
  .youtube-result-body {
    grid-column: 2;
  }

  .youtube-result-title {
    font-size: 17px;
    line-height: 1.35;
  }

  .youtube-result-heading {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .youtube-result-menu {
    width: 28px;
    height: 28px;
  }

  .youtube-result-channel {
    margin-top: 2px;
  }

  .youtube-result-chapter {
    grid-template-columns: 64px minmax(0, 1fr) auto;
  }

  .youtube-result-chapter span:nth-child(4),
  .youtube-result-chapter span:nth-child(5) {
    display: none;
  }

  .config-grid,
  .quota-summary {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .toolbar-actions,
  .ranking-filters,
  .number-filter,
  .date-filter {
    display: grid;
    grid-template-columns: 1fr;
  }

  .number-filter input,
  .date-filter input {
    width: 100%;
  }

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