@import url("/styles/admin.css");
@import url("/styles/feed.css");

:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f7f2;
  color: #111827;
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-2: #fbfaf5;
  --surface-3: #f3f4f6;
  --ink: #111827;
  --ink-2: #1f2937;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #e3e4dc;
  --border: #e3e4dc;
  --brand: #0b1220;
  --brand-2: #fb923c;
  --brand-3: #0d9488;
  --accent: #6366f1;
  --success: #0d9488;
  --warn: #b45309;
  --bad: #dc2626;
  --success-bg: #e7f6f4;
  --warn-bg: #fff3e6;
  --bad-bg: #feecec;
  --accent-bg: #eeeeff;
  --shadow: 0 16px 34px rgba(11, 18, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  background:
    linear-gradient(180deg, rgba(251, 146, 60, 0.08), rgba(251, 146, 60, 0) 220px),
    var(--bg);
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
a[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  margin: 0 auto;
  max-width: 1120px;
  min-height: 100vh;
  padding: 18px 14px 94px;
}

.auth-mode .app-shell {
  max-width: none;
  padding: 0;
}

.auth-mode .app-header,
.auth-mode .bottom-nav {
  display: none;
}

.app-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 6px 0 16px;
}

.eyebrow {
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 3px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--brand);
  font-size: 31px;
  font-weight: 840;
  line-height: 1;
}

h2 {
  color: var(--brand);
  font-size: 20px;
  line-height: 1.15;
}

h3 {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
}

.screen {
  display: grid;
  gap: 14px;
  outline: 0;
}

.auth-mode .screen {
  display: block;
}

.bottom-nav {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  bottom: 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, 1fr);
  left: 14px;
  margin: 0 auto;
  max-width: 520px;
  padding: 6px;
  position: fixed;
  right: 14px;
  z-index: 10;
}

.nav-item,
.icon-action,
.primary,
.secondary,
.ghost,
.danger {
  border: 0;
  border-radius: 7px;
  min-height: 42px;
  padding: 10px 12px;
}

.nav-item {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
  position: relative;
}

.nav-item.is-active {
  background: #fff3e6;
  color: var(--brand);
}

.nav-item.is-active::before {
  background: var(--brand-2);
  border-radius: 999px;
  content: "";
  height: 3px;
  left: 14px;
  position: absolute;
  right: 14px;
  top: 5px;
}

.icon-action {
  background: var(--brand);
  box-shadow: 0 9px 20px rgba(11, 18, 32, 0.18);
  color: #ffffff;
  font-size: 25px;
  font-weight: 560;
  height: 44px;
  line-height: 1;
  padding: 0;
  width: 44px;
}

.top-tools {
  align-items: center;
  display: flex;
  gap: 10px;
}

.top-search,
.top-tool {
  display: none;
}

.top-sign-out {
  min-height: 44px;
  padding: 0 12px;
  white-space: nowrap;
}

.sidebar-link,
.nav-section-label {
  display: none;
}

.card,
.feed-item,
.search-card,
.saved-card,
.onboarding,
.empty-state,
.composer,
.admin-card,
.progress-banner,
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card,
.search-card,
.saved-card,
.empty-state,
.composer,
.admin-card,
.filter-panel {
  padding: 14px;
}

.rubric-quality {
  border-color: rgba(13, 148, 136, 0.35);
}

.rubric-quality.needs-work {
  border-color: rgba(180, 83, 9, 0.36);
}

.onboarding {
  display: grid;
  gap: 16px;
  overflow: hidden;
  padding: 18px;
}

.onboarding h2 {
  font-size: 24px;
  max-width: 560px;
}

.onboarding p,
.muted {
  color: var(--muted);
  line-height: 1.4;
}

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

.category-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 12px;
  text-align: left;
}

.category-card strong {
  color: var(--brand);
  font-size: 15px;
}

.category-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.category-card.is-selected {
  background: #fff3e6;
  border-color: #fed7aa;
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.22);
}

.category-card.is-disabled,
.category-card:disabled {
  background: #f3f4f6;
  color: var(--muted-2);
}

.category-card.is-disabled span,
.category-card:disabled span {
  color: var(--muted-2);
}

.primary,
.secondary,
.ghost,
.danger {
  font-weight: 800;
}

.primary {
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(11, 18, 32, 0.12);
  color: #ffffff;
}

.secondary {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--brand);
}

.ghost {
  background: transparent;
  color: var(--brand);
  padding-left: 0;
  padding-right: 0;
}

.danger {
  background: var(--bad-bg);
  color: var(--bad);
}

.login-page {
  background:
    linear-gradient(180deg, rgba(251, 146, 60, 0.10), rgba(251, 146, 60, 0) 260px),
    var(--bg);
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  padding: 22px 16px;
  place-items: center;
  position: relative;
}

.login-bg {
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.trace {
  border: 1px solid rgba(11, 18, 32, 0.08);
  border-radius: 8px;
  position: absolute;
}

.trace::before,
.trace::after {
  background: rgba(13, 148, 136, 0.16);
  border-radius: 999px;
  content: "";
  height: 7px;
  position: absolute;
  width: 7px;
}

.trace-a {
  height: 86px;
  left: -28px;
  top: 86px;
  transform: rotate(-8deg);
  width: 158px;
}

.trace-a::before {
  left: 22px;
  top: 18px;
}

.trace-a::after {
  background: rgba(251, 146, 60, 0.22);
  right: 28px;
  top: 52px;
}

.trace-b {
  height: 120px;
  right: -46px;
  top: 214px;
  transform: rotate(10deg);
  width: 190px;
}

.trace-b::before {
  background: rgba(99, 102, 241, 0.18);
  left: 46px;
  top: 28px;
}

.trace-b::after {
  right: 42px;
  top: 78px;
}

.trace-c {
  bottom: 94px;
  height: 92px;
  left: 34px;
  transform: rotate(7deg);
  width: 180px;
}

.trace-c::before {
  left: 34px;
  top: 28px;
}

.trace-c::after {
  background: rgba(251, 146, 60, 0.18);
  right: 44px;
  top: 58px;
}

.login-shell {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(11, 18, 32, 0.10);
  display: grid;
  gap: 16px;
  max-width: 420px;
  padding: 22px;
  position: relative;
  width: min(100%, 420px);
}

.login-brand {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.login-brand h1 {
  font-size: 32px;
  line-height: 1.03;
  max-width: 260px;
}

.login-brand > span {
  background: #fff3e6;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  color: var(--brand);
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 850;
  padding: 6px 8px;
}

.login-copy {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form .field span {
  color: var(--brand);
  font-size: 13px;
  font-weight: 820;
}

.login-submit,
.login-google {
  width: 100%;
}

.login-divider {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
  font-size: 12px;
  font-style: normal;
  font-weight: 760;
}

.login-divider span {
  background: var(--line);
  height: 1px;
}

.login-divider em {
  font-style: normal;
}

.login-back {
  justify-self: start;
}

.login-hint {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  padding: 8px 10px;
}

.auth-error,
.auth-message {
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.35;
  padding: 9px 10px;
}

.auth-error {
  background: var(--bad-bg);
  color: var(--bad);
}

.auth-message {
  background: var(--success-bg);
  color: #08766d;
}

.login-footer {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 10px;
  justify-content: space-between;
}

.login-footer a {
  color: var(--brand);
  font-weight: 780;
  text-decoration: none;
}

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

.action-row > button,
.action-row > a {
  flex: 1 1 auto;
}

.inline-field {
  display: flex;
  gap: 8px;
}

.inline-field input {
  min-width: 0;
}

.inline-field button {
  flex: 0 0 auto;
}

.section-head {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 9px;
}

.section-head span,
.small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.removable-chip {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  padding-right: 4px;
}

.removable-chip button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  min-height: 22px;
  padding: 0 5px;
}

.search-card {
  display: grid;
  gap: 12px;
}

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

.health-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 10px 0;
  overflow: hidden;
}

.health-metric {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 10px;
  text-align: center;
}

.health-metric:last-child {
  border-right: 0;
}

.health-metric strong {
  color: var(--brand);
  display: block;
  font-size: 18px;
}

.health-grid .health-metric {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  justify-items: start;
  text-align: left;
}

.metric-dot {
  align-items: center;
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 850;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.metric-dot.teal {
  background: var(--brand-3);
}

.metric-dot.orange {
  background: var(--brand-2);
}

.metric-dot.purple {
  background: var(--accent);
}

.metric-dot.gray {
  background: var(--muted);
}

.search-health-card {
  align-self: start;
}

.empty-state {
  display: grid;
  gap: 12px;
  justify-items: start;
  min-height: 180px;
  place-content: center start;
}

.composer {
  display: grid;
  gap: 14px;
}

.stepper {
  display: flex;
  gap: 5px;
}

.stepper span {
  background: #e5e7eb;
  border-radius: 999px;
  flex: 1;
  height: 5px;
}

.stepper span.is-active {
  background: var(--brand-2);
}

.field {
  display: grid;
  gap: 7px;
}

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

@media (max-width: 620px) {
  .two-column-fields {
    grid-template-columns: 1fr;
  }
}

.field label {
  color: var(--brand);
  font-size: 13px;
  font-weight: 780;
}

textarea,
input,
select {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: var(--ink);
  min-height: 46px;
  padding: 11px 12px;
  width: 100%;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(251, 146, 60, 0.32);
  outline-offset: 2px;
}

textarea {
  line-height: 1.4;
  min-height: 160px;
  resize: vertical;
}

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

.criterion {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 9px 10px;
}

.criterion button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-weight: 800;
  min-height: 28px;
  padding: 0 4px;
}

.compact-actions {
  gap: 8px;
}

@media (max-width: 390px) {
  .category-grid,
  .health-grid {
    grid-template-columns: 1fr;
  }

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

@media (min-width: 760px) {
  .app-shell {
    padding: 24px 24px 34px;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 520px;
  }

  .screen.feed-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .feed-list,
  .search-list,
  .saved-list,
  .admin-list {
    gap: 14px;
  }

  .onboarding,
  .composer {
    margin: 0 auto;
    max-width: 720px;
  }
}

@media (min-width: 1040px) {
  .app-shell {
    margin: 0;
    max-width: none;
    padding: 88px 24px 38px 260px;
    width: 100%;
  }

  .auth-mode .app-shell {
    padding: 0;
  }

  .app-header {
    background: rgba(247, 247, 242, 0.96);
    border-bottom: 1px solid var(--line);
    height: 72px;
    left: 236px;
    padding: 0 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 9;
  }

  .app-header .eyebrow {
    display: none;
  }

  .app-header h1 {
    font-size: 26px;
    letter-spacing: 0;
  }

  .bottom-nav {
    align-content: start;
    background: rgba(255, 255, 255, 0.98);
    border: 0;
    border-radius: 0;
    border-right: 1px solid var(--line);
    bottom: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    left: 0;
    margin: 0;
    max-width: none;
    padding: 92px 14px 18px;
    right: auto;
    top: 0;
    transform: none;
    width: 236px;
  }

  .bottom-nav::before {
    color: var(--brand);
    content: "resyft ✦";
    font-size: 26px;
    font-weight: 860;
    left: 22px;
    line-height: 1;
    position: absolute;
    top: 25px;
  }

  .bottom-nav::after {
    color: var(--muted);
    content: "Decision feed";
    font-size: 12px;
    font-weight: 760;
    left: 23px;
    position: absolute;
    top: 54px;
  }

  .nav-item {
    align-items: center;
    display: flex;
    gap: 12px;
    font-size: 14px;
    justify-content: flex-start;
    min-height: 46px;
    padding: 0 14px;
    text-align: left;
    width: 100%;
  }

  .sidebar-link {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: var(--ink-2);
    display: flex;
    gap: 12px;
    font-size: 14px;
    font-weight: 720;
    justify-content: flex-start;
    min-height: 40px;
    opacity: 1;
    padding: 0 14px;
    text-align: left;
    width: 100%;
  }

  .sidebar-link:disabled {
    cursor: default;
    opacity: 1;
  }

  .nav-section-label {
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: block;
    font-size: 11px;
    font-weight: 850;
    margin: 18px 0 2px;
    padding: 18px 8px 0;
    text-transform: uppercase;
  }

  .nav-section-label.admin-label {
    margin-top: 16px;
  }

  .nav-item.is-active::before {
    bottom: 10px;
    height: auto;
    left: 5px;
    right: auto;
    top: 10px;
    width: 3px;
  }

  .searchable-mode .top-search {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    min-height: 40px;
    padding: 0 10px;
    width: 270px;
  }

  .top-search span {
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
  }

  .top-search input {
    border: 0;
    flex: 1;
    min-width: 0;
    min-height: 36px;
    padding: 0;
    width: auto;
  }

  .top-search input:focus {
    outline: 0;
  }

  .top-search kbd {
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 780;
    padding: 3px 5px;
    white-space: nowrap;
  }

  .top-tool {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--brand);
    display: inline-flex;
    font-size: 17px;
    font-weight: 850;
    height: 40px;
    justify-content: center;
    width: 40px;
  }

  .top-sign-out {
    min-height: 40px;
    padding: 0 14px;
  }

  .screen {
    gap: 16px;
  }

  .screen.feed-layout {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) 400px;
  }

  .screen.feed-layout > .progress-banner,
  .screen.feed-layout > .error-banner {
    grid-column: 1 / -1;
  }

  .feed-list,
  .search-list,
  .saved-list,
  .admin-list {
    gap: 16px;
  }

  .feed-item {
    padding: 16px 16px 0;
  }

  .search-health-card {
    position: static;
  }

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