:root {
  color-scheme: light;
  --background: #fff7ef;
  --surface: #fffdf9;
  --surface-muted: #f8e9dc;
  --text: #3d2a22;
  --text-muted: #755f53;
  --border: #e6cdbc;
  --primary: #a94f2d;
  --primary-dark: #74351f;
  --primary-soft: #f4ded0;
  --accent: #c45d24;
  --accent-dark: #8f3b18;
  --danger: #9f2525;
  --focus: #e9a11b;
  --shadow: 0 12px 34px rgba(87, 47, 28, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 5%, rgba(196, 93, 36, 0.12), transparent 28rem),
    var(--background);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 220, 190, 0.28), transparent 24rem),
    linear-gradient(125deg, #74351f 0%, #a94f2d 48%, #fff7ef 48%, #fff7ef 100%);
}

.login-layout {
  width: min(1000px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  align-items: center;
  gap: clamp(40px, 8vw, 100px);
}

.login-intro {
  color: #ffffff;
}

.login-brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 26px;
  border-radius: 50%;
  background: #fff8f2;
  color: var(--primary-dark);
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 14px 36px rgba(62, 26, 13, 0.24);
}

.login-intro h1 {
  margin-bottom: 14px;
  font-size: clamp(38px, 6vw, 64px);
}

.login-intro > p:last-child {
  max-width: 510px;
  color: #f9e2d4;
  font-size: 18px;
}

.login-eyebrow {
  margin-bottom: 8px;
  color: #ffd1b4;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.login-card {
  min-height: 430px;
  padding: clamp(28px, 5vw, 42px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(255, 253, 249, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(83, 42, 23, 0.24);
}

.login-card h2 {
  margin-bottom: 8px;
  font-size: 30px;
}

.login-card form > p:not(.eyebrow) {
  margin-bottom: 24px;
  color: var(--text-muted);
}

.login-loading {
  margin: auto;
  color: var(--text-muted);
  text-align: center;
}

.login-help {
  display: block;
  margin-top: 12px;
  color: var(--text-muted);
  text-align: center;
}

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

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.site-header {
  background: linear-gradient(120deg, #74351f, #b75a35);
  color: #ffffff;
}

.header-inner {
  width: calc(100% - 40px);
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary-dark);
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

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

h1 {
  margin-bottom: 2px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.brand p {
  margin-bottom: 0;
  color: #f7dfd0;
  font-size: 15px;
}

.session-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  text-align: right;
}

.page-shell {
  width: calc(100% - 40px);
  margin: 28px auto 56px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  min-height: 92px;
  padding: 18px 22px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(87, 47, 28, 0.07);
}

.stat-card strong {
  margin-left: auto;
  color: var(--primary-dark);
  font-size: 34px;
  line-height: 1;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 700;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  padding: 6px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(87, 47, 28, 0.1);
  backdrop-filter: blur(10px);
}

.tab {
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 800;
}

.tab:hover {
  background: var(--surface-muted);
  color: var(--primary-dark);
}

.tab.is-active {
  background: var(--primary);
  color: #ffffff;
}

.tab-panel {
  min-height: 360px;
  padding: clamp(20px, 4vw, 36px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.3;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.button {
  min-height: 48px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.button:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 7px 18px rgba(169, 79, 45, 0.24);
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button-secondary {
  border-color: var(--primary);
  background: #ffffff;
  color: var(--primary-dark);
}

.button-secondary:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.site-header .button-secondary {
  border-color: #ffffff;
  background: transparent;
  color: #ffffff;
}

.site-header .button-secondary:hover:not(:disabled) {
  background: #ffffff;
  color: var(--primary-dark);
}

.button-accent {
  background: var(--accent);
}

.button-accent:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 7px 18px rgba(196, 93, 36, 0.24);
}

.button-danger {
  background: var(--danger);
}

.button-small {
  min-height: 42px;
  padding: 9px 15px;
}

.button-wide {
  width: 100%;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.status-message {
  padding: 18px;
  background: var(--surface-muted);
  border-radius: 12px;
  color: var(--text-muted);
  text-align: center;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 18px;
}

.product-card {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(87, 47, 28, 0.09);
}

.product-image-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: #f0dfd2;
  cursor: zoom-in;
}

.product-image-button img,
.product-image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
}

.product-image-button img {
  object-fit: cover;
  transition: transform 0.25s ease;
}

.product-image-button:hover img {
  transform: scale(1.025);
}

.product-image-placeholder {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  background: var(--surface-muted);
}

.product-card-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.product-card h3 {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.product-meta {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.product-description {
  margin-bottom: 18px;
  color: var(--text-muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
  margin-bottom: 14px;
}

.price-block {
  min-width: 0;
  padding: 11px;
  background: #fbf3ec;
  border-radius: 10px;
}

.price-block span,
.price-block strong {
  display: block;
}

.price-block span {
  color: var(--text-muted);
  font-size: 12px;
}

.price-block strong {
  margin-top: 2px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.price-block.is-highlighted {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.bid-history {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.bid-history summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 800;
}

.bid-history ol {
  margin: 10px 0 0;
  padding-left: 22px;
}

.bid-history li + li {
  margin-top: 5px;
}

.bid-history p {
  margin: 8px 0 0;
}

.form-card,
.notice-card,
.security-card {
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}

.form-card {
  width: min(720px, 100%);
  margin: 0 auto;
}

.form-card h3,
.notice-card h3,
.security-card h3 {
  margin-bottom: 6px;
  font-size: 22px;
}

.form-card > p,
.notice-card p,
.security-card p {
  color: var(--text-muted);
}

.notice-card {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  background: var(--surface-muted);
}

.security-card {
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface-muted);
}

.security-card p {
  margin-bottom: 2px;
}

.security-card small {
  color: var(--text-muted);
}

.guide-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  align-items: start;
  gap: 22px;
}

.guide-card {
  min-width: 0;
  padding: clamp(22px, 4vw, 32px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}

.guide-card h3 {
  margin-bottom: 18px;
  color: var(--primary-dark);
  font-size: 22px;
}

.guide-body {
  color: var(--text);
  line-height: 1.9;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.guide-editor.form-card {
  width: 100%;
  margin: 0;
}

.guide-editor textarea {
  min-height: 420px;
}

.guide-status {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: #e6f2e5;
  color: #35613a;
  font-size: 14px;
  font-weight: 800;
}

.guide-status.is-closed {
  background: #f1dfd5;
  color: var(--primary-dark);
}

.toggle-field {
  min-height: 74px;
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 12px;
  background: var(--surface-muted);
  cursor: pointer;
}

.toggle-field span,
.toggle-field strong,
.toggle-field small {
  display: block;
}

.toggle-field small {
  margin-top: 2px;
  color: var(--text-muted);
}

.toggle-field input {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 22px;
}

.account-grid .form-card {
  width: 100%;
}

.account-panel {
  max-width: 720px;
}

.signed-in-note {
  padding: 12px 14px;
  margin-bottom: 22px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

.optional,
.field small {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid #bda394;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
}

.field textarea {
  min-height: 132px;
  resize: vertical;
}

.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: var(--primary);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary-dark);
}

.field small {
  display: block;
  margin-top: 5px;
}

input[type="file"] {
  padding: 8px;
}

input[type="file"]::file-selector-button {
  min-height: 38px;
  margin-right: 10px;
  padding: 7px 13px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.image-preview-grid figure {
  min-width: 0;
  margin: 0;
}

.image-preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.image-preview-grid figcaption {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-list-card {
  margin-top: 22px;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.section-heading.compact {
  align-items: center;
  margin-bottom: 16px;
}

.section-heading.compact h3,
.section-heading.compact p {
  margin-bottom: 0;
}

.section-heading.compact p {
  color: var(--text-muted);
}

.account-list {
  border-top: 1px solid var(--border);
}

.account-list-row {
  min-height: 72px;
  padding: 14px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.account-list-row > div {
  min-width: 0;
}

.account-list-row strong,
.account-list-row span {
  display: block;
}

.account-list-row div span {
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.role-badge {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f5e8dc;
  color: #6c4f3e;
  font-size: 13px;
  font-weight: 800;
}

.role-badge.is-admin {
  background: #f4d4bf;
  color: #7a351f;
}

.busy-overlay,
.modal-backdrop,
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(55, 29, 18, 0.74);
}

.busy-overlay {
  color: #ffffff;
  text-align: center;
}

.busy-overlay p {
  margin: 12px 0 0;
  font-weight: 800;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: auto;
  border: 5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-card {
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 28px;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

.modal-card h2 {
  margin-bottom: 10px;
  font-size: 25px;
}

.modal-card > p {
  color: var(--text-muted);
  white-space: pre-line;
}

.modal-card .current-bid {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.image-modal {
  z-index: 1100;
}

.image-modal img {
  max-width: min(1100px, 92vw);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.image-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 48px;
  height: 48px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.48);
  color: #ffffff;
  cursor: pointer;
  font-size: 30px;
  line-height: 1;
}

@media (max-width: 760px) {
  .login-shell {
    align-items: start;
    padding: 28px 16px;
    background: linear-gradient(180deg, #8e4328 0%, #b75a35 36%, #fff7ef 36%, #fff7ef 100%);
  }

  .login-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .login-intro {
    padding: 6px 6px 0;
  }

  .login-brand-mark {
    width: 54px;
    height: 54px;
    margin-bottom: 16px;
    font-size: 22px;
  }

  .login-intro h1 {
    margin-bottom: 8px;
    font-size: 36px;
  }

  .login-intro > p:last-child {
    margin-bottom: 0;
    font-size: 15px;
  }

  .login-card {
    min-height: 0;
    padding: 26px 22px;
    border-radius: 20px;
  }

  .header-inner,
  .page-shell {
    width: min(100% - 24px, 1180px);
  }

  .header-inner {
    padding: 20px 0;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .brand p {
    font-size: 14px;
  }

  .session-summary {
    width: 100%;
    justify-content: space-between;
    text-align: left;
  }

  .page-shell {
    margin-top: 16px;
  }

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

  .stat-card {
    min-height: 76px;
    padding: 14px;
  }

  .stat-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 5px;
  }

  .stat-card strong {
    grid-row: span 2;
    margin: 0;
    font-size: 28px;
  }

  .stat-card > span:last-child {
    display: none;
  }

  .tabs {
    top: 6px;
    padding: 4px;
    margin-bottom: 12px;
  }

  .tab {
    min-height: 46px;
    padding: 8px 5px;
    font-size: 14px;
  }

  .tab-panel {
    padding: 20px 16px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }

  .section-heading .button {
    width: 100%;
  }

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

  .security-card {
    align-items: stretch;
    flex-direction: column;
  }

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

  .button-row > .button {
    flex: 1 1 140px;
  }
}

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