:root {
  --brown: #6d4630;
  --brown-dark: #4f2f1f;
  --brown-light: #d09c66;
  --paper: #fffdf9;
  --ink: #3d2a20;
  --muted: #7a6659;
  --terracotta: #c46a4a;
  --mustard: #d2a13c;
  --olive: #7d8b4f;
  --rose: #c47b8a;
  --teal: #4f8b8b;
  --plum: #8a5a7d;
  --slate: #5f7896;
  --shadow: 7px 7px 0 rgba(109, 70, 48, .22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  background:
    linear-gradient(rgba(109,70,48,.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109,70,48,.13) 1px, transparent 1px),
    #fff;
  background-size: 30px 30px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }

.app-frame {
  min-height: 100dvh;
  margin: 14px;
  border: 4px solid var(--brown);
  border-radius: 30px;
  background: rgba(255,253,249,.88);
  box-shadow: 10px 10px 0 rgba(109,70,48,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.site-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px 14px;
  border-bottom: 3px solid rgba(109,70,48,.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.logo-wrap {
  width: clamp(92px, 15vw, 150px);
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--brown);
  border-radius: 22px;
  background: #fff;
  box-shadow: 5px 5px 0 rgba(109,70,48,.2);
}

.logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text { display: grid; gap: 6px; min-width: 0; }
.brand-text strong {
  color: var(--brown);
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: .02em;
}
.brand-text span {
  white-space: pre-line;
  color: var(--muted);
  font-size: clamp(15px, 2vw, 21px);
  font-weight: 700;
  line-height: 1.45;
}

.clock {
  align-self: center;
  min-width: 150px;
  padding: 12px 18px;
  border: 3px solid var(--brown);
  border-radius: 20px;
  background: #fff;
  box-shadow: 5px 5px 0 rgba(109,70,48,.18);
  text-align: center;
}
#clockTime { font-size: 38px; line-height: 1; font-weight: 800; color: var(--brown); }
#clockDate { margin-top: 5px; color: var(--muted); font-weight: 700; }

main { flex: 1; padding: 24px; }
.view { display: none; }
.view.active { display: block; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  max-width: 980px;
  margin: 18px auto 0;
}

.home-button {
  min-height: clamp(190px, 28vh, 270px);
  border: 4px solid var(--brown);
  border-radius: 30px;
  background: #fff;
  color: var(--brown-dark);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 800;
  transition: transform .12s ease, box-shadow .12s ease;
}
.home-button:active { transform: translate(4px,4px); box-shadow: 3px 3px 0 rgba(109,70,48,.22); }
.home-button small { font-size: 16px; color: var(--muted); letter-spacing: .08em; }
.home-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 3px solid currentColor;
  border-radius: 50%;
  font-size: 38px;
  line-height: 1;
  background: rgba(255,255,255,.72);
}
.accent-terracotta { background: #f7e3da; color: #9a4a30; }
.accent-mustard { background: #f8ecd0; color: #946d16; }
.accent-teal { background: #dceeed; color: #356d6d; }
.accent-rose { background: #f6e1e6; color: #9a4d60; }
.home-note { text-align: center; color: var(--muted); font-weight: 700; font-size: 19px; margin: 28px 0 4px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.section-head h1 {
  margin: 0;
  color: var(--brown);
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1.1;
  font-weight: 800;
}
.back-button, .small-button, .primary-button, .danger-button, .ghost-button {
  border: 3px solid var(--brown);
  border-radius: 999px;
  background: #fff;
  color: var(--brown-dark);
  padding: 9px 18px;
  font-weight: 800;
  box-shadow: 4px 4px 0 rgba(109,70,48,.18);
}
.primary-button { background: var(--brown); color: #fff; }
.danger-button { border-color: #a33d32; color: #a33d32; }
.ghost-button { box-shadow: none; }
.staff-head .small-button { margin-left: auto; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}
.chip {
  border: 3px solid var(--brown);
  border-radius: 999px;
  background: #fff;
  color: var(--brown-dark);
  padding: 7px 15px;
  font-weight: 800;
}
.chip.active { background: var(--chip-color, var(--brown)); color: #fff; }
.chip .count { opacity: .78; font-size: .88em; margin-left: 4px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 20px;
  align-items: stretch;
}
.card {
  position: relative;
  border: 3px solid var(--brown);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 190px;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 12px;
  border-radius: 21px 0 0 21px;
  background: var(--card-color, var(--brown-light));
}
.card > * { margin-left: 8px; }
.card h2 { margin: 0; font-size: 23px; line-height: 1.35; color: var(--brown-dark); }
.card p { margin: 0; line-height: 1.55; color: #5d4638; }
.card .price { margin-top: auto; font-size: 28px; font-weight: 800; color: var(--brown); }
.card .meta { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  border: 2px solid currentColor;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--card-color, var(--brown));
  background: #fff;
}
.duration, .valid, .conditions { color: var(--muted); font-weight: 700; }
.coupon-card {
  background:
    radial-gradient(circle at left center, transparent 13px, #fff 14px),
    radial-gradient(circle at right center, transparent 13px, #fff 14px);
}
.empty {
  grid-column: 1 / -1;
  border: 3px dashed rgba(109,70,48,.55);
  border-radius: 24px;
  background: rgba(255,255,255,.8);
  padding: 38px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 21px;
  font-weight: 800;
}
.media-card { text-align: left; width: 100%; }
.media-card .media-kind { font-size: 42px; line-height: 1; }
.open-label { margin-top: auto; color: var(--teal); font-weight: 800; }

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 430px));
  justify-content: center;
  gap: 26px;
}
.link-card {
  border: 3px solid var(--brown);
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 26px;
  text-align: center;
}
.link-card h2 { margin: 0 0 18px; color: var(--brown-dark); font-size: 28px; }
.qr-wrap {
  position: relative;
  width: min(300px, 72vw);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  place-items: center;
  background: #fff;
}
.qr-wrap svg { width: 100%; height: 100%; display: block; }
.qr-brand {
  position: absolute;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 16px;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.qr-brand.instagram { background: linear-gradient(135deg, #7b4ba8, #d64f7d 55%, #ef9b4d); }
.qr-brand.line { background: #4f9d69; border-radius: 50%; font-size: 13px; }
.qr-brand svg { width: 34px; height: 34px; }
.link-card p { color: #5d4638; line-height: 1.6; font-weight: 700; }
.link-open { display: inline-block; margin-top: 8px; color: var(--brown); font-weight: 800; }

.staff-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-top: 3px solid rgba(109,70,48,.35);
  color: var(--muted);
  font-weight: 700;
}
#staffButton {
  border: 2px solid rgba(109,70,48,.65);
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  color: var(--brown);
  padding: 7px 16px;
  font-weight: 800;
}

.staff-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.staff-tab {
  border: 3px solid var(--brown);
  border-radius: 999px;
  background: #fff;
  color: var(--brown-dark);
  padding: 9px 17px;
  font-weight: 800;
}
.staff-tab.active { background: var(--brown); color: #fff; }
.staff-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.staff-list { display: grid; gap: 12px; }
.staff-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 16px;
  align-items: center;
  border: 3px solid var(--brown);
  border-radius: 20px;
  background: #fff;
  box-shadow: 5px 5px 0 rgba(109,70,48,.16);
  padding: 15px 17px;
}
.staff-row h3 { margin: 0 0 4px; font-size: 20px; color: var(--brown-dark); }
.staff-row p { margin: 0; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.row-actions button {
  border: 2px solid var(--brown);
  border-radius: 999px;
  background: #fff;
  color: var(--brown-dark);
  padding: 6px 12px;
  font-weight: 800;
}
.row-actions .delete { border-color: #a33d32; color: #a33d32; }
.settings-form, .hidden-form {
  border: 3px solid var(--brown);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(61,42,32,.48);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(720px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  border: 4px solid var(--brown);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 10px 10px 0 rgba(0,0,0,.2);
  padding: 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-head h2 { margin: 0; color: var(--brown); font-size: 30px; }
.icon-button {
  width: 44px; height: 44px;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: #fff;
  color: var(--brown);
  font-size: 28px;
  line-height: 1;
}
.form-grid { display: grid; gap: 15px; margin-top: 18px; }
.field { display: grid; gap: 6px; font-weight: 800; color: var(--brown-dark); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 3px solid rgba(109,70,48,.65);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  font-weight: 600;
}
.field textarea { min-height: 96px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-error { color: #a33d32; font-weight: 800; min-height: 1.4em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(680px, calc(100vw - 32px));
  border: 3px solid var(--brown);
  border-radius: 999px;
  background: #fff;
  color: var(--brown-dark);
  box-shadow: var(--shadow);
  padding: 12px 22px;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 760px) {
  .app-frame { margin: 0; border-width: 0; border-radius: 0; box-shadow: none; }
  .site-header { padding: 14px; }
  .brand { gap: 12px; }
  .logo-wrap { width: 82px; border-radius: 17px; }
  .clock { min-width: 104px; padding: 9px 11px; }
  #clockTime { font-size: 28px; }
  #clockDate { font-size: 13px; }
  main { padding: 18px 14px; }
  .home-grid { grid-template-columns: 1fr; gap: 16px; }
  .home-button { min-height: 150px; }
  .staff-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
}

@media (orientation: landscape) and (max-height: 760px) {
  .logo-wrap { width: 96px; }
  .brand-text strong { font-size: 38px; }
  .home-button { min-height: 180px; }
}
