/* UMS — Feeder color studio (color wheel page) */

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

:root {
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.92);
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 44px;
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar-w: 0px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(165deg, #e8eef7 0%, #dbe7f3 45%, #e5edf8 100%);
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100dvh;
  position: relative;
}

.app.hidden {
  display: none !important;
}

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
}

.gate.hidden {
  display: none !important;
}

.gate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1.5rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.gate-text {
  margin: 0;
  font-size: 0.95rem;
}

.gate-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--accent);
  animation: gate-spin 0.85s linear infinite;
}

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

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(147, 197, 253, 0.35), transparent 55%);
}

.ambient-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
  background-size: 48px 48px;
}

.site-header {
  position: relative;
  z-index: 10;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0
    max(12px, env(safe-area-inset-left));
}

.feeders-chrome {
  max-width: 1100px;
  margin: 0 auto;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.site-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(min-content, auto);
  grid-template-areas: "brand primary trail";
  align-items: center;
  column-gap: 10px;
  row-gap: 10px;
  padding: 12px 14px;
}

@media (max-width: 900px) {
  .site-nav {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand trail"
      "primary primary";
  }

  .nav-links--primary {
    justify-content: stretch;
    width: 100%;
  }

  .nav-links--primary li {
    flex: 1;
    min-width: 0;
  }

  .nav-links--primary .nav-link {
    width: 100%;
    justify-content: center;
  }
}

.nav-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.nav-brand-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-page-title {
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-page-sub {
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.14);
  color: #4f46e5;
}

.nav-links--primary {
  grid-area: primary;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-trail {
  grid-area: trail;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link-text--short {
  display: none;
}

@media (max-width: 400px) {
  .nav-link-text--full {
    display: none;
  }
  .nav-link-text--short {
    display: inline;
  }
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
}

.nav-link:hover {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
}

.nav-link[aria-current="page"] {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.12);
}

.user {
  display: none;
  font-size: 0.76rem;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 520px) {
  .user {
    display: block;
  }
}

.btn-ghost {
  min-height: var(--tap);
  padding: 0 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
}

.btn-ghost:hover {
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.25);
}

.feeders-main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px max(12px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.feeders-lead {
  margin: 0 0 18px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
  font-weight: 500;
  max-width: 52rem;
}

.feeders-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 880px) {
  .feeders-grid {
    grid-template-columns: 1fr;
  }
}

.feeders-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.feeders-card-title {
  margin: 0 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4f46e5;
}

.feeder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(48vh, 420px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
}

.feeders-empty {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.feeder-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 250, 252, 0.9);
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.feeder-list-item:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.feeder-list-item.is-selected {
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.feeder-list-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
}

.feeder-list-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.feeder-list-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feeder-list-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.feeders-field-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 0 6px;
}

.feeders-field-label--inline {
  display: inline;
  margin: 0 8px 0 0;
}

.feeders-text-input {
  width: 100%;
  padding: 10px 12px;
  min-height: var(--tap);
  font: inherit;
  font-size: 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.95);
}

.feeders-wheel-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
}

.feeder-hsv-wheel {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  touch-action: none;
  cursor: crosshair;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
}

.feeders-value-slider {
  width: 100%;
  height: 28px;
  accent-color: var(--accent);
}

.feeders-hex-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.feeders-hex-input {
  flex: 1 1 120px;
  min-width: 100px;
  padding: 8px 10px;
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.95);
}

.feeder-preview-swatch {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.feeders-presets-label {
  margin: 14px 0 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.feeder-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feeder-preset-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
  touch-action: manipulation;
}

.feeders-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

@media (min-width: 480px) {
  .feeders-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .feeders-actions .btn-primary {
    flex: 1 1 200px;
  }

  .feeders-actions .btn-secondary {
    flex: 1 1 160px;
  }
}

.btn-secondary,
.btn-primary {
  min-height: var(--tap);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-secondary {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  padding: 12px 18px;
  max-width: min(420px, calc(100vw - 24px));
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.toast.hidden {
  display: none !important;
}

.toast.toast--ok {
  border-color: rgba(5, 150, 105, 0.35);
}

.toast.toast--err {
  border-color: rgba(220, 38, 38, 0.4);
  color: #b91c1c;
}

@media (min-width: 1024px) {
  :root {
    --sidebar-w: clamp(268px, 22vw, 320px);
  }

  .app {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100dvh;
  }

  .ambient,
  .ambient-grid {
    left: var(--sidebar-w);
  }

  .site-header {
    order: -1;
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    max-width: var(--sidebar-w);
    align-self: stretch;
    min-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top)) 10px 12px max(10px, env(safe-area-inset-left));
    border-right: 1px solid rgba(148, 163, 184, 0.22);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.55) 0%, rgba(241, 245, 249, 0.4) 100%);
    display: flex;
    flex-direction: column;
  }

  .feeders-chrome {
    flex: 1;
    min-height: 0;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: 4px 0 32px rgba(15, 23, 42, 0.06), var(--shadow);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .site-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px 12px 20px;
  }

  .nav-brand {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  }

  .nav-page-sub {
    white-space: normal;
    line-height: 1.35;
  }

  .nav-links--primary {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    width: 100%;
  }

  .nav-links--primary li {
    width: 100%;
  }

  .nav-links--primary .nav-link {
    width: 100%;
    justify-content: flex-start;
    padding: 0 14px;
    min-height: 42px;
    border-radius: 10px;
  }

  .nav-trail {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .nav-trail .user {
    max-width: none;
    white-space: normal;
    word-break: break-word;
  }

  .nav-trail .nav-signout {
    width: 100%;
    justify-content: center;
  }

  .feeders-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 20px max(20px, env(safe-area-inset-right)) 28px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .toast {
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) * 0.5);
    max-width: min(420px, calc(100vw - var(--sidebar-w) - 32px));
  }
}
