:root {
  --bg: #f3eee4;
  --ink: #2d241c;
  --muted: #6f6255;
  --accent: #0e5a50;
  --accent-2: #b67c2f;
  --card: #fffaf1;
  --line: #d4c6af;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(182, 124, 47, 0.22), transparent 35%),
    radial-gradient(circle at 90% 0%, rgba(14, 90, 80, 0.18), transparent 38%),
    linear-gradient(180deg, #f7f1e7, var(--bg));
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  backdrop-filter: blur(8px);
  background: rgba(247, 241, 231, 0.9);
  border-bottom: 1px solid var(--line);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
}

.top-auth-btn {
  width: auto;
  margin-top: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}

.top-auth-btn:hover {
  background: #f7f1e7;
  box-shadow: none;
}

.top-user-badge {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 90, 80, 0.1);
  color: #0a3d3a;
  font-size: 0.9rem;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand {
  font-size: 1.3rem;
  letter-spacing: 0.04em;
}

.layout {
  width: min(1100px, 94vw);
  margin: 20px auto 32px;
  display: grid;
  gap: 16px;
}

.layout.single {
  min-height: calc(100vh - 160px);
  align-content: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(45, 36, 28, 0.08);
  animation: rise 0.35s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3 {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
  margin-top: 0;
}

.grid2, .grid3 {
  display: grid;
  gap: 10px;
}

.grid2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

input, select, button {
  width: 100%;
  margin-top: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

button {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  border: none;
}

button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14, 90, 80, 0.3); }
button:active { transform: translateY(0); }
button.secondary { background: var(--accent-2); }
button.primary-large {
  background: linear-gradient(135deg, #0e5a50 0%, #0a3d3a 100%);
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: 12px;
  width: auto;
  margin: 20px auto;
  display: block;
  min-width: 180px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

button.primary-full {
  background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
  padding: 12px 16px;
  font-size: 0.95rem;
  border-radius: 8px;
  width: 100%;
  margin-top: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

button.primary-full:hover {
  box-shadow: 0 6px 16px rgba(0, 102, 204, 0.35);
}

.status, .result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: #fff;
  white-space: pre-wrap;
}

.actions-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.actions-row button {
  width: 100%;
  min-width: 200px;
}

.auth-switch {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-switch .is-active {
  background: var(--accent);
  color: #fff;
}

.auth-panel {
  display: none;
  margin-top: 12px;
}

.auth-panel.is-active {
  display: block;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
}

.remember-row input {
  width: auto;
  margin: 0;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.code-status {
  min-height: 18px;
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: #64748b;
}

.code-status.success {
  color: #15803d;
}

.code-status.error {
  color: #b91c1c;
}

.hidden-temp {
  display: none;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.item .meta { color: var(--muted); font-size: 0.92rem; }

.footer {
  text-align: center;
  padding: 18px;
  color: var(--muted);
}

/* Auth Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.modal-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(420px, 90vw);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 101;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  overflow: hidden;
}

.auth-modal.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #f9f9f9 0%, #f5f5f5 100%);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--ink);
}

.modal-close {
  width: auto !important;
  height: 32px;
  min-width: 32px;
  padding: 0 !important;
  background: transparent !important;
  color: var(--muted);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  border: none !important;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin: 0 !important;
}

.modal-close:hover {
  background: #f0f0f0 !important;
  color: var(--ink);
  transform: none !important;
}

.modal-content {
  padding: 24px;
  min-height: 180px;
}

.modal-panel {
  display: none;
}

.modal-panel.is-active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel input {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 12px;
  border: 1.5px solid #d4d4d4;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.modal-panel input:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.modal-panel input::placeholder {
  color: #999;
}

.modal-alt-text {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.modal-alt-text a {
  color: #0066cc;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.modal-alt-text a:hover {
  color: #0052a3;
  text-decoration: underline;
}

.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: #f9f9f9;
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .topbar { position: static; }
}