:root {
  --bg: #EDEBDE;
  --surface: #F7F5EB;
  --surface-strong: #fff;
  --ink: #1B1716;
  --cream: #EDEBDE;
  --muted: #665F5D;
  --line: #D8D2C4;
  --accent: #810100;
  --accent-dark: #630102;
  --accent-soft: #F3DDDA;
  --shadow: 0 18px 45px rgba(27, 23, 22, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(129, 1, 0, 0.12), transparent 30%),
    radial-gradient(circle at 82% 10%, rgba(99, 1, 2, 0.11), transparent 30%),
    linear-gradient(135deg, #EDEBDE 0%, #F7F5EB 48%, #EDEBDE 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  isolation: isolate;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(24px);
  opacity: 0.5;
  transform: translate3d(0, 0, 0);
  will-change: transform, border-radius;
}

body::before {
  inset: -18% auto auto -12%;
  width: min(58vw, 720px);
  height: min(58vw, 720px);
  border-radius: 40% 60% 58% 42% / 44% 42% 58% 56%;
  background:
    radial-gradient(circle at 35% 30%, rgba(129, 1, 0, 0.28), transparent 42%),
    radial-gradient(circle at 68% 68%, rgba(99, 1, 2, 0.18), transparent 44%),
    radial-gradient(circle at 45% 75%, rgba(237, 235, 222, 0.95), transparent 48%);
  animation: liquidDriftA 12s cubic-bezier(0.2, 0.8, 0.2, 1) infinite alternate;
}

body::after {
  right: -14%;
  bottom: -22%;
  width: min(64vw, 820px);
  height: min(64vw, 820px);
  border-radius: 62% 38% 45% 55% / 58% 48% 52% 42%;
  background:
    radial-gradient(circle at 62% 36%, rgba(99, 1, 2, 0.26), transparent 42%),
    radial-gradient(circle at 34% 70%, rgba(129, 1, 0, 0.16), transparent 46%),
    radial-gradient(circle at 45% 42%, rgba(247, 245, 235, 0.92), transparent 54%);
  animation: liquidDriftB 15s cubic-bezier(0.2, 0.8, 0.2, 1) infinite alternate;
}

button,
input,
textarea {
  font: inherit;
  font-size: 16px;
}

.admin-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.login-card,
.panel,
.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-card {
  width: min(430px, 100%);
  margin: 10vh auto;
  padding: 28px;
}

.login-card img,
.admin-header img {
  width: 138px;
  height: auto;
}

.login-card img {
  filter: brightness(0) saturate(100%);
}

.brand-switch {
  position: relative;
  width: max-content;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.brand-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 20;
  display: none;
  min-width: 140px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.brand-switch.open .brand-menu {
  display: grid;
}

.brand-menu a {
  padding: 11px 13px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.brand-menu a:hover {
  color: #EDEBDE;
  background: var(--accent);
}

.eyebrow {
  margin: 18px 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: rgba(129, 1, 0, 0.45);
  box-shadow: 0 0 0 3px rgba(129, 1, 0, 0.1);
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
}

.ai-button {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  padding: 0;
  background: var(--ink);
}

.ai-button.loading {
  color: var(--ink);
  background: var(--accent-soft);
  cursor: wait;
}

.ai-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.file-field input {
  padding: 10px;
}

button,
.header-actions a,
.row-actions a {
  border: 0;
  border-radius: 8px;
  padding: 11px 13px;
  color: #EDEBDE;
  background: var(--accent);
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

button.secondary {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.brand-button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  box-shadow: none;
}

.error {
  color: var(--accent);
  font-weight: 800;
}

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

.header-actions,
.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid div {
  padding: 18px;
}

.stats-grid strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-heading input {
  max-width: 280px;
}

.project-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.project-form label {
  margin-bottom: 0;
}

.project-form .wide,
.form-actions {
  grid-column: 1 / -1;
}

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

.screenshot-preview,
.screenshot-grid {
  display: grid;
  gap: 10px;
}

.screenshot-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.shot-item {
  position: relative;
  min-height: 98px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.shot-item img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.shot-item button {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 7px 9px;
  background: rgba(27, 23, 22, 0.86);
}

.shot-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
}

.project-table,
.compact-list,
.log-list {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
}

.row,
.log-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.row strong,
.row small,
.log-item small {
  display: block;
}

.row small,
.log-item small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.row-actions button,
.row-actions a,
.mini-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  border-radius: 8px;
  padding: 12px 14px;
  color: #EDEBDE;
  background: var(--accent-dark);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes liquidDriftA {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    border-radius: 40% 60% 58% 42% / 44% 42% 58% 56%;
  }
  50% {
    transform: translate3d(10vw, 8vh, 0) rotate(11deg) scale(1.08);
    border-radius: 58% 42% 38% 62% / 45% 61% 39% 55%;
  }
  100% {
    transform: translate3d(3vw, 14vh, 0) rotate(-8deg) scale(0.96);
    border-radius: 46% 54% 65% 35% / 62% 40% 60% 38%;
  }
}

@keyframes liquidDriftB {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    border-radius: 62% 38% 45% 55% / 58% 48% 52% 42%;
  }
  50% {
    transform: translate3d(-9vw, -7vh, 0) rotate(-10deg) scale(1.06);
    border-radius: 41% 59% 61% 39% / 44% 57% 43% 56%;
  }
  100% {
    transform: translate3d(-4vw, -13vh, 0) rotate(8deg) scale(0.98);
    border-radius: 55% 45% 42% 58% / 60% 39% 61% 40%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  body::before,
  body::after {
    animation: none !important;
  }
}

/* ── Tags input field ── */
.tag-field {
  margin-bottom: 0;
}

.tag-field-label,
.star-field-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tag-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  margin-bottom: 8px;
}

.tag-add-row input {
  margin-bottom: 0;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 5px 10px 5px 11px;
  color: #fff;
  background: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.tag-chip-remove {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: inherit;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
}

/* ── Star rating widget in admin form ── */
.star-rating-field {
  margin-bottom: 0;
}

.star-rating-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.star-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: rgba(129, 1, 0, 0.22);
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  box-shadow: none;
  transition: color 130ms ease, background 130ms ease, border-color 130ms ease;
}

.star-btn.active {
  color: #c8860a;
  background: #fdf5e6;
  border-color: #e6c070;
}

.star-btn:hover {
  color: #c8860a;
  background: #fdf5e6;
}

.star-clear-btn {
  margin-left: 6px;
  padding: 8px 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 13px;
  box-shadow: none;
}

/* ── Stars display in admin project table ── */
.admin-stars {
  display: flex;
  gap: 1px;
  margin: 2px 0;
}

.admin-stars .filled {
  color: #c8860a;
}

.admin-stars .empty {
  color: rgba(129, 1, 0, 0.2);
}

.admin-tags {
  color: var(--accent-dark);
  margin-top: 2px;
}

/* ── Star and filled/empty spans ── */
.star.filled,
.filled {
  color: #c8860a;
}

.star.empty,
.empty {
  color: rgba(129, 1, 0, 0.2);
}

@media (max-width: 900px) {
  .admin-shell {
    padding: 20px;
  }

  .admin-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

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

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

  .panel-heading input {
    max-width: none;
  }

  .project-table,
  .compact-list,
  .log-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .admin-shell {
    padding: 14px;
  }

  .login-card {
    margin: 5vh auto;
    padding: 20px;
  }

  .login-card img,
  .admin-header img {
    width: 118px;
  }

  h1 {
    font-size: 36px;
    line-height: 1;
  }

  h2 {
    font-size: 21px;
  }

  .admin-header {
    gap: 14px;
    margin-bottom: 18px;
  }

  .header-actions,
  .mini-actions,
  .form-actions,
  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .header-actions a,
  .header-actions button,
  .mini-actions button,
  .form-actions button,
  .row-actions button,
  .row-actions a {
    width: 100%;
    text-align: center;
  }

  .stats-grid {
    gap: 10px;
  }

  .stats-grid div,
  .panel {
    padding: 14px;
  }

  .stats-grid strong {
    font-size: 30px;
  }

  .admin-grid {
    gap: 14px;
    margin-bottom: 14px;
  }

  .input-action {
    grid-template-columns: minmax(0, 1fr) 54px;
  }

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

  .row-main {
    display: grid;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .header-actions,
  .mini-actions,
  .form-actions,
  .row-actions {
    grid-template-columns: 1fr;
  }

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

.panel-full {
  grid-column: 1 / -1;
}

.panel-description {
  color: var(--muted);
  font-size: 13px;
  margin: -8px 0 16px;
  padding: 0 24px;
}

.suggestion-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 6px;
}

.suggestion-badge:empty {
  display: none;
}

.suggestion-keyword {
  font-size: 15px;
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}
