:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #222222;
  --muted: #6b6b6b;
  --border: #e2e0da;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --error: #b3261e;
  --notice-bg: #fff4d6;
  --notice-border: #f0c96a;
  --notice-text: #5c4400;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #222327;
    --text: #ececec;
    --muted: #a3a3a3;
    --border: #393a3f;
    --accent: #6fb1e0;
    --accent-text: #0e1a24;
    --error: #ff8a80;
    --notice-bg: #3a2f12;
    --notice-border: #7a6224;
    --notice-text: #ffe2a0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding-top: 24px; padding-bottom: 48px; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); min-height: 1.2em; margin: 8px 0 0; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.shop-name { font-weight: 700; color: var(--text); text-decoration: none; }

.site-footer { border-top: 1px solid var(--border); padding: 20px 0; font-size: 0.85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.site-footer a { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

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

input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select.invalid { border-color: var(--error); }

button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  width: 100%;
  padding: 12px;
}
.link-button { border: none; background: none; padding: 4px; color: var(--accent); text-decoration: underline; }

/* パスワード */
.login-card { max-width: 420px; margin: 40px auto; }
.login-card form { display: grid; gap: 8px; }
.login-card input { width: 100%; }

/* ショップ */
.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-weight: 600;
}
.notice-line { display: block; }
.notice-line + .notice-line { margin-top: 4px; }
.notice a { color: inherit; white-space: nowrap; margin-left: 4px; }
.shop-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.product { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.product-image { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #fff; display: block; }
.product-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-description { margin: 0; font-size: 0.9rem; white-space: pre-wrap; }
.product-price { margin: 0; font-weight: 700; }
.product-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.product-option { flex: 1 1 100%; }
.size-chart-link { flex: 1 1 100%; text-align: left; padding: 0; font-size: 0.9rem; }
.product-fields { flex: 1 1 100%; display: grid; gap: 6px; }
.product-field { display: grid; gap: 2px; font-size: 0.85rem; }
.product-field input { width: 100%; font-size: 1rem; }
.product-field input.invalid { border-color: var(--error); }
.product-field input.upper { text-transform: uppercase; }
.product-error { flex: 1 1 100%; margin: 0; min-height: 0; font-size: 0.85rem; }
.product-error:empty { display: none; }

/* サイズ表 */
.size-chart {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
  color: var(--text);
}
.size-chart::backdrop { background: rgba(0, 0, 0, 0.45); }
.size-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.size-chart-head h2 { margin: 0; font-size: 1.05rem; }
.size-chart-close { border: none; background: none; font-size: 1.6rem; line-height: 1; padding: 4px 8px; }
.size-chart-scroll { overflow-x: auto; }
.size-chart table { border-collapse: collapse; white-space: nowrap; font-size: 0.95rem; width: 100%; }
.size-chart th, .size-chart td { border: 1px solid var(--border); padding: 6px 10px; text-align: center; }
.size-chart thead th, .size-chart tr:first-child th { background: var(--bg); }
.size-chart tr th:first-child { position: sticky; left: 0; background: var(--bg); text-align: left; }
.product-qty { width: 72px; }
.add-to-cart { flex: 1; }

.cart { position: sticky; top: 16px; }
.cart-items { list-style: none; margin: 0; padding: 0; }
.cart-items li { border-bottom: 1px solid var(--border); padding: 8px 0; }
.cart-name { display: block; }
.cart-line { display: flex; align-items: center; gap: 8px; }
.cart-line input { width: 64px; padding: 4px 6px; }
.cart-price { margin-left: auto; }

.delivery { border: none; padding: 0; margin: 16px 0 0; display: grid; gap: 4px; }
.delivery legend { font-weight: 700; margin-bottom: 4px; }
.delivery p { margin: 0; }

.contact { border: none; padding: 0; margin: 16px 0 0; display: grid; gap: 4px; }
.contact legend { font-weight: 700; margin-bottom: 4px; }
.contact input { width: 100%; }
.contact p { margin: 0; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 16px 0; }
.totals dd { margin: 0; text-align: right; }
.totals .total { font-weight: 700; font-size: 1.1rem; }

/* 文章のページ */
.doc { max-width: 760px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
.doc th { width: 32%; background: var(--bg); font-weight: 600; }
.todo { background: #fff3c4; color: #5c4400; padding: 0 4px; border-radius: 4px; }

@media (max-width: 800px) {
  .shop-layout { grid-template-columns: 1fr; }
  .cart { position: static; }
  .doc th { width: 38%; }
}
@media (max-width: 480px) {
  .products { grid-template-columns: 1fr; }
}
