*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #000000;
  --surface: #111111;
  --surface-raised: #1a1a1a;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #888888;
  --accent: #1581dd;
  --accent-hover: #2B9CFF;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Login ── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.login-card .field input {
  width: 100%;
  min-width: 0;
}

.btn-login {
  width: 100%;
  margin-top: 0.25rem;
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  color: #ff6b6b;
  font-size: 0.85rem;
  background: #2a1010;
  border: 1px solid #5a2020;
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}

/* ── Header ── */

.header-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.btn-sign-out {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  transition: border-color 0.15s, color 0.15s;
}

.btn-sign-out:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem 0.75rem;
}

.header-top h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.config-panel {
  flex-shrink: 0;
}

.config-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.config-summary:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--surface);
}

.config-panel[open] .config-summary {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

.config-summary::-webkit-details-marker {
  display: none;
}

.config-icon {
  display: block;
  transition: transform 0.2s;
}

.config-panel[open] .config-icon {
  transform: rotate(45deg);
}

.controls {
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.config-controls {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.header-title-block:has(.config-panel[open]) .config-controls {
  display: flex;
}

.config-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.sizes-section {
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}

.sizes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.sizes-heading {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sizes-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.size-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.size-input {
  width: 5rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.55rem;
  transition: border-color 0.15s;
}

.size-input:focus {
  outline: none;
  border-color: var(--accent);
}

.size-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
}

.btn-text:hover {
  color: var(--accent-hover);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}

.btn-icon:hover:not(:disabled) {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.sizes-error {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #ff6b6b;
}

.config-apply {
  align-self: flex-start;
}

.field-compact {
  gap: 0.2rem;
}

.field-compact input,
.field-compact select {
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  min-width: 120px;
}

.field-compact.field-wide input {
  min-width: 280px;
}

.btn-compact {
  padding: 0.42rem 0.9rem;
  font-size: 0.8rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
  min-width: 160px;
  transition: border-color 0.15s;
}

.select-wrap {
  position: relative;
  display: inline-block;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  pointer-events: none;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.5rem;
  cursor: pointer;
  width: 100%;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}

.field-wide input {
  min-width: 340px;
}

.btn-apply {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #000;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.25rem;
  transition: background 0.15s;
  align-self: flex-end;
}

.btn-apply:hover {
  background: var(--accent-hover);
}

/* ── Main ── */

main {
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 0;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  background: #2a1010;
  border: 1px solid #5a2020;
  border-radius: var(--radius);
  color: #ff6b6b;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

/* ── Partner navigation ── */

.partner-nav {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.partner-nav-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.partner-stats-inline {
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--mono);
  font-weight: 400;
}

.btn-nav {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  transition: border-color 0.15s, background 0.15s;
  align-self: flex-end;
}

.btn-nav:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1f1f1f;
}

.btn-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.field-partner-select .select-wrap {
  min-width: 280px;
}

.partner-position {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
  align-self: flex-end;
  padding-bottom: 0.55rem;
  margin-left: auto;
}

/* ── Gallery ── */

.gallery {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.partner-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.partner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
}

.partner-header-static {
  cursor: default;
  user-select: text;
}

.partner-info {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.partner-id {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.partner-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.partner-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.theme-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.theme-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-name {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
}

.theme-url {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.iframe-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
}

.iframe-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.iframe-size-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.iframe-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a0a0a;
  position: relative;
}

.iframe-wrap iframe {
  display: block;
  border: none;
}

.no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
  font-size: 0.9rem;
}

@media (max-width: 700px) {
  .header-title-row {
    flex-direction: column;
  }

  .auth-bar {
    width: 100%;
    justify-content: space-between;
  }

  .partner-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .field-partner-select .select-wrap {
    min-width: 0;
    width: 100%;
  }

  .select-wrap {
    width: 100%;
  }

  .partner-position {
    margin-left: 0;
    text-align: center;
    padding-bottom: 0;
  }

  .btn-nav {
    width: 100%;
  }

  .field-wide input {
    min-width: 100%;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .field-compact.field-wide input {
    min-width: 0;
  }

  .field input {
    width: 100%;
  }

  .partner-nav-main {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-apply {
    width: 100%;
  }
}
