:root {
  --cream: #f7f3ec;
  --cream-dark: #ebe4d8;
  --sage: #5f6b5a;
  --sage-dark: #2f372c;
  --gold: #b8955a;
  --gold-soft: rgba(184, 149, 90, 0.18);
  --danger: #a33b3b;
  --border: rgba(47, 55, 44, 0.12);
  --shadow: 0 18px 50px rgba(47, 55, 44, 0.08);
  --radius: 14px;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--sage-dark);
  background:
    radial-gradient(circle at top left, rgba(184, 149, 90, 0.12), transparent 32%),
    linear-gradient(180deg, #faf7f1 0%, var(--cream) 48%, #f3eee5 100%);
}

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

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.app.hidden,
.login-screen.hidden,
.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 0.9rem;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card .brand {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}

.login-card .brand-sub {
  margin: -0.4rem 0 0.5rem;
  text-align: center;
  color: var(--sage);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.user-line {
  margin: 0;
  color: var(--sage);
  font-size: 0.85rem;
}

.logout-btn {
  margin-top: auto;
}

.sidebar {
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-sub {
  margin: -1rem 0 0;
  color: var(--sage);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--sage);
  transition: 0.2s ease;
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--gold-soft);
  color: var(--sage-dark);
  border-color: rgba(184, 149, 90, 0.25);
}

.site-link {
  margin-top: auto;
  color: var(--gold);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.main {
  padding: 2.5rem 2rem 3rem;
}

.view.hidden { display: none; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.view-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 600;
}

.muted, .hint {
  color: var(--sage);
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
}

.hint { font-size: 0.85rem; margin-bottom: 0.75rem; }

.toolbar {
  margin-bottom: 1.25rem;
}

.toolbar input,
label input,
label select,
label textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.toolbar input:focus,
label input:focus,
label select:focus,
label textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.card-list {
  display: grid;
  gap: 0.85rem;
}

.item-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.item-card.category {
  grid-template-columns: 1fr auto;
}

.thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--cream-dark);
}

.thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--sage);
  font-size: 0.7rem;
}

.item-card h3 {
  margin: 0 0 0.25rem;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.meta {
  margin: 0;
  color: var(--sage);
  font-size: 0.85rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  background: white;
  transition: 0.2s ease;
}

.btn.primary {
  background: var(--sage-dark);
  color: var(--cream);
}

.btn.primary:hover { background: #1f261d; }

.btn.ghost {
  background: transparent;
  border-color: var(--border);
}

.btn.ghost:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn.danger { color: var(--danger); }
.btn.danger:hover {
  background: rgba(163, 59, 59, 0.08);
  border-color: rgba(163, 59, 59, 0.25);
}

.btn.small {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(720px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
  background: #fffdf9;
}

dialog::backdrop {
  background: rgba(47, 55, 44, 0.35);
  backdrop-filter: blur(4px);
}

.dialog-header,
.dialog-footer,
.dialog-body {
  padding: 1.25rem 1.5rem;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.8rem;
}

.dialog-body {
  display: grid;
  gap: 0.9rem;
  max-height: min(70vh, 640px);
  overflow: auto;
}

.dialog-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-top: 1px solid var(--border);
}

.spacer { flex: 1; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--sage);
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--sage);
}

.images-block {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.images-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
  color: var(--sage-dark);
  font-weight: 600;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
}

.image-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: grab;
  background: var(--cream-dark);
}

.image-card.dragging {
  opacity: 0.5;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  background: var(--sage-dark);
  color: var(--cream);
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.toast.hidden { display: none; }
.toast.error { background: var(--danger); }

.empty {
  padding: 2.5rem;
  text-align: center;
  color: var(--sage);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .site-link { margin-top: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .item-card { grid-template-columns: 64px 1fr; }
  .item-card .actions { grid-column: 1 / -1; }
}
