* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

body {
  font-family: Georgia, "Times New Roman", serif;
  background: #ffffff;
  color: #1a1a1a;
  min-height: 100vh;
  animation: fadeIn 0.5s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  body,
  .top-bar,
  header,
  main,
  .item-card,
  .auth-card,
  .item-detail-image,
  .item-detail-body,
  .admin-item-row,
  .placeholder {
    animation: none !important;
    transition: none !important;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e8e8e8;
  animation: fadeInDown 0.5s ease-out;
}

.brand {
  font-size: 1.1rem;
  letter-spacing: 0.06em;
}

.top-bar-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid #ccc;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.04em;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:hover {
  background: #f5f5f5;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-admin {
  border-color: #1a1a1a;
}

.btn-primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.btn-primary:hover {
  background: #333;
}

.btn-secondary {
  border-color: #ccc;
}

.btn-danger {
  border-color: #c44;
  color: #a33;
}

.btn-danger:hover {
  background: #fff5f5;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

header {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  border-bottom: 1px solid #e8e8e8;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

h1 {
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.subtitle {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: #666;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.catalogue {
  width: 100%;
}

.search-bar {
  margin-bottom: 2rem;
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 2px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #1a1a1a;
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.search-input::placeholder {
  color: #999;
}

.placeholder {
  color: #999;
  font-size: 1rem;
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.item-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
  animation-delay: var(--delay, 0ms);
}

.item-card {
  display: block;
  flex: 1;
  border: 1px solid #e8e8e8;
  background: #fff;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.item-card-wrap .btn-add-cart {
  width: 100%;
}

.item-card:hover {
  border-color: #ccc;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transform: translateY(-4px);
}

.item-image {
  aspect-ratio: 4 / 3;
  background: #fafafa;
  overflow: hidden;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.item-card:hover .item-image img {
  transform: scale(1.05);
}

.item-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 0.9rem;
}

.item-body {
  padding: 1rem;
}

.item-body h2 {
  font-size: 1.15rem;
  font-weight: 400;
  margin-bottom: 0.75rem;
}

.item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.item-price {
  font-weight: 600;
}

.item-stock {
  color: #666;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 2rem 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  border: 1px solid #e8e8e8;
  padding: 2rem;
  animation: fadeInUp 0.6s ease-out 0.15s both;
}

.auth-card h1 {
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  text-align: center;
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: #444;
  margin-bottom: 1rem;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 2px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #1a1a1a;
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-error {
  color: #a33;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.form-success {
  color: #2a6;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  animation: fadeInUp 0.3s ease-out;
}

.admin-page {
  max-width: 720px;
}

.admin-section {
  margin-bottom: 2.5rem;
}

.admin-section h1,
.admin-section h2 {
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 1rem;
  letter-spacing: 0.04em;
}

.admin-section .search-bar {
  margin-bottom: 1rem;
}

.item-form {
  border: 1px solid #e8e8e8;
  padding: 1.5rem;
  animation: fadeInUp 0.5s ease-out 0.1s both;
}

.admin-items {
  border: 1px solid #e8e8e8;
}

.admin-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #eee;
  animation: fadeInUp 0.4s ease-out both;
  animation-delay: var(--delay, 0ms);
  transition: background 0.2s ease;
}

.admin-item-row:hover {
  background: #fafafa;
}

.admin-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.current-image {
  margin-bottom: 1rem;
}

.current-image-label {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.current-image img {
  max-width: 120px;
  max-height: 120px;
  object-fit: cover;
  border: 1px solid #eee;
}

.admin-item-row:last-child {
  border-bottom: none;
}

.admin-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-item-info strong {
  display: block;
  font-weight: 400;
  margin-bottom: 0.15rem;
}

.admin-item-info span {
  font-size: 0.85rem;
  color: #666;
}

.admin-item-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid #eee;
}

.item-page {
  max-width: 900px;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 2rem;
  transition: color 0.2s ease, transform 0.2s ease;
  animation: fadeInLeft 0.5s ease-out;
}

.back-link:hover {
  color: #1a1a1a;
  transform: translateX(-4px);
}

.item-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.item-detail-image {
  aspect-ratio: 1;
  background: #fafafa;
  overflow: hidden;
  border: 1px solid #e8e8e8;
  animation: fadeInLeft 0.6s ease-out 0.1s both;
}

.item-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: fadeIn 0.8s ease-out 0.2s both;
}

.item-detail-body {
  animation: fadeInRight 0.6s ease-out 0.2s both;
}

.item-detail-body h1 {
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.item-detail-price {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.item-detail-stock {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1rem;
}

.item-add-cart {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 2rem;
}

.btn-cart {
  position: relative;
}

.cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: #1a1a1a;
  color: #fff;
  border-radius: 999px;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 2px;
}

.qty-btn {
  width: 2rem;
  height: 2rem;
  font-family: inherit;
  font-size: 1rem;
  border: none;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.qty-btn:hover {
  background: #f5f5f5;
}

.qty-input {
  width: 3rem;
  height: 2rem;
  text-align: center;
  border: none;
  border-left: 1px solid #ccc;
  border-right: 1px solid #ccc;
  font-family: inherit;
  font-size: 0.9rem;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cart-page h1 {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  margin-bottom: 1.5rem;
}

.cart-empty {
  margin-bottom: 1rem;
}

.cart-list {
  border: 1px solid #e8e8e8;
  margin-bottom: 1.5rem;
}

.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #eee;
}

.cart-row:last-child {
  border-bottom: none;
}

.cart-row-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.cart-row-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid #eee;
  flex-shrink: 0;
}

.cart-row-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  color: #bbb;
}

.cart-row-name {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.cart-row-name:hover {
  text-decoration: underline;
}

.cart-row-unit {
  font-size: 0.85rem;
  color: #666;
}

.cart-row-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cart-row-total {
  font-weight: 600;
  min-width: 5rem;
  text-align: right;
}

.cart-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.5rem;
}

.cart-total-label {
  font-size: 1.1rem;
}

.btn-buy-now {
  font-size: 1rem;
  padding: 0.65rem 1.5rem;
  letter-spacing: 0.02em;
}

.cart-messenger-hint {
  width: 100%;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid #e8e8e8;
  padding: 1.75rem;
  animation: fadeInUp 0.3s ease-out;
}

.modal-card h2 {
  font-size: 1.25rem;
  font-weight: 400;
  margin-bottom: 0.75rem;
  text-align: center;
}

.modal-text,
.modal-note {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #444;
  text-align: center;
  margin-bottom: 0.75rem;
}

.modal-note {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-actions .btn {
  width: 100%;
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

.cart-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  padding: 0.65rem 1.25rem;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.9rem;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1000;
}

.cart-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.item-detail-description h2 {
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #666;
  margin-bottom: 0.75rem;
}

.item-detail-description p {
  font-size: 1rem;
  line-height: 1.7;
  color: #333;
}

@media (max-width: 700px) {
  .item-detail {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .cart-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .cart-row-controls {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .top-bar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
