:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #f0f3ee;
  --text: #18201c;
  --muted: #68746d;
  --line: #dce3dc;
  --accent: #0b7a75;
  --accent-dark: #075f5b;
  --danger: #a33434;
  --shadow: 0 12px 35px rgba(24, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.tab,
button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.tab {
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(24, 32, 28, 0.08);
}

main {
  padding: 28px clamp(18px, 4vw, 48px) 48px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

form.panel {
  max-width: 1040px;
  padding: 22px;
}

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

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.error {
  color: var(--danger);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(11, 122, 117, 0.18);
  border-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.checkbox input {
  width: 18px;
  min-height: 18px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
}

button {
  min-height: 42px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.secondary {
  background: var(--surface-muted);
  color: var(--text);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.2rem;
}

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

.accounts-panel,
.detail-panel {
  padding: 18px;
}

.accounts-list,
.videos-list {
  display: grid;
  gap: 10px;
}

.account-item,
.video-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.account-item {
  display: grid;
  gap: 5px;
  color: var(--text);
  text-align: left;
}

.account-item.is-active {
  border-color: var(--accent);
  outline: 3px solid rgba(11, 122, 117, 0.14);
}

.account-title,
.video-title {
  margin: 0;
  font-weight: 800;
}

.video-item {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

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

.video-content {
  min-width: 0;
}

.video-caption {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.video-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.video-metrics span {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.video-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
}

.video-details div {
  min-width: 0;
}

.video-details dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.video-details dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.raw-data {
  margin-top: 12px;
}

.raw-data summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.raw-data pre {
  max-height: 320px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #111713;
  color: #e8efe9;
  font-size: 0.78rem;
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.detail-card {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.profile-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: center;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.stat strong {
  display: block;
  font-size: 1.2rem;
}

.empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.fetch-status {
  display: none;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.fetch-status.success,
.fetch-status.error {
  display: grid;
  gap: 4px;
}

.fetch-status.success {
  border-color: rgba(11, 122, 117, 0.38);
}

.fetch-status.error {
  border-color: rgba(163, 52, 52, 0.38);
  color: var(--danger);
}

.fetch-status span {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .tab {
    width: 100%;
  }

  .grid,
  .split,
  .stats,
  .video-item,
  .video-details {
    grid-template-columns: 1fr;
  }

  .video-cover {
    width: 100%;
    max-height: 360px;
    aspect-ratio: 16 / 9;
  }
}
