* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --red: #d62926;
  --red-dark: #b91f1c;
  --ink: #171717;
  --muted: #777777;
  --line: #e7e0de;
  --surface: #ffffff;
  --tab: #dddddd;
  --green: #55c854;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Noto Sans JP', system-ui, sans-serif;
  color: var(--ink);
  background: #1f1f1f;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.desktop-gate {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 20% 20%, rgba(214, 41, 38, 0.16), transparent 28%),
    linear-gradient(135deg, #fafafa, #ece8e5);
}

.desktop-panel {
  width: min(100%, 520px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.desktop-brand {
  margin: 0 auto 18px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.desktop-panel h1 {
  margin: 0;
  font-family: 'Noto Serif JP', serif;
  font-size: 34px;
  line-height: 1.25;
}

.desktop-panel p {
  margin: 16px 0 22px;
  color: #555555;
  line-height: 1.8;
}

.qr-frame {
  display: grid;
  width: 268px;
  height: 268px;
  margin: 0 auto 22px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.qr-frame svg {
  width: 220px;
  height: 220px;
  display: block;
}

.official-link {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid #1e1e1e;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
}

.mobile-app {
  display: none;
  overflow-x: clip;
  max-width: 100%;
}

.phone-safe {
  position: relative;
  min-height: 100dvh;
  overflow: visible;
  padding: env(safe-area-inset-top, 0px) 22px calc(env(safe-area-inset-bottom, 0px) + 28px);
  background: #ffffff;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  margin-bottom: 8px;
  background: #ffffff;
  overflow: visible;
  overflow-anchor: none;
}

.header-spacer {
  width: 42px;
  height: 42px;
}

.header-settings-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  justify-self: end;
  border: 1px solid #dedede;
  border-radius: 50%;
  background: #f6f6f6;
  color: #696969;
  box-shadow: none;
  text-decoration: none;
  outline: none;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.header-settings-button:focus,
.header-settings-button:focus-visible,
.header-settings-button:active {
  outline: none;
  box-shadow: none;
  border-color: #dedede;
  background: #f6f6f6;
  color: #696969;
  -webkit-tap-highlight-color: transparent;
}

.brand-mark {
  display: grid;
  justify-self: center;
  width: 42px;
  min-height: 42px;
  place-items: center;
}

.brand-mark img {
  width: 34px;
  max-height: 34px;
  object-fit: contain;
}

.auth-page,
.member-page,
.settings-page,
.withdrawal-page {
  width: min(100%, 430px);
  margin: 0 auto;
}

.auth-title {
  margin: 18px 0 28px;
  text-align: center;
}

.auth-title h1 {
  margin: 0;
  font-family: 'Noto Serif JP', serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.25;
}

.settings-page h1,
.withdrawal-page h1 {
  margin: 0 0 12px;
  font-family: 'Noto Serif JP', serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.25;
}

.page-lead {
  margin: 0 0 20px;
  color: #777777;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.8;
}

.member-flash {
  margin: 0 0 16px;
}

.auth-login-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.auth-lead {
  margin: 0 0 24px;
  color: #777777;
  font-size: 12px;
  font-weight: 200;
  line-height: 1.8;
  text-align: left;
}

.auth-card {
  padding: 0;
  border: 0;
  border-radius: 0;
}

.settings-card {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.settings-card .field:last-of-type {
  margin-bottom: 16px;
}

.settings-card-actions {
  display: grid;
  gap: 0;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.settings-card .settings-save-button {
  width: 100%;
  min-height: 54px;
  margin: 0;
  border: 1px solid #1e1e1e;
  background: #ffffff;
  color: #1e1e1e;
  cursor: pointer;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

.settings-secondary-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 28px;
  margin-top: 28px;
  padding: 0 8px 4px;
}

.settings-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: #555555;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.settings-secondary-link svg {
  display: block;
  flex-shrink: 0;
}

.settings-secondary-link-danger {
  color: var(--red-dark);
}

.settings-card .settings-site-link,
.settings-card .danger-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  margin: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.settings-card .settings-site-link {
  border: 1px solid #dedede;
  background: #f8f8f8;
  color: #555555;
}

.settings-card .danger-button {
  border: 1px solid #e3b5b2;
  background: #fff6f5;
  color: var(--red-dark);
}

.save-message {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #edf7ef;
  color: #197a35;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  text-align: center;
}

.withdrawal-list {
  display: grid;
  gap: 16px;
}

.withdrawal-card.is-selected {
  border-color: #ffd1da;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}

.withdrawal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.withdrawal-kicker {
  margin: 0 0 6px;
  color: #777777;
  font-size: 12px;
  font-weight: 500;
}

.withdrawal-id {
  margin: 0;
  font-family: 'Noto Serif JP', serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  color: #171717;
}

.withdrawal-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8f8f8;
  color: #555555;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.withdrawal-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.withdrawal-meta div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.withdrawal-meta dt {
  margin: 0 0 6px;
  color: #777777;
  font-size: 12px;
  font-weight: 500;
}

.withdrawal-meta dd {
  margin: 0;
  color: #171717;
  font-size: 14px;
  font-weight: 600;
}

.withdrawal-notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #555555;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.withdrawal-notice.pending {
  background: #fff4e5;
  color: #9a5b00;
}

.withdrawal-form {
  display: grid;
  gap: 0;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.withdrawal-form .field {
  margin-bottom: 16px;
}

.withdrawal-submit {
  margin-top: 0;
}

.withdrawal-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.withdrawal-page-actions {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.withdrawal-page-actions .settings-site-link {
  display: flex;
  width: 100%;
  min-height: 52px;
  margin: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #dedede;
  border-radius: 999px;
  background: #f8f8f8;
  color: #555555;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.withdrawal-empty .empty-copy {
  margin: 0 0 16px;
  color: #777777;
  font-size: 14px;
  line-height: 1.8;
}

.field {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
  color: #252525;
  font-size: 14px;
  font-weight: 500;
}

.field > span:not(.input-wrap-password),
.field > label {
  display: block;
}

.auth-card .field:nth-of-type(2) {
  margin-bottom: 24px;
}

.settings-card .field > input:not([type='hidden']):not([type='radio']):not([type='checkbox']),
.settings-card .field > textarea,
.field > input:not([type='hidden']):not([type='radio']):not([type='checkbox']),
.field > textarea {
  display: block;
  width: 100%;
  margin: 0;
  border: 1px solid #e7e0de;
  border-radius: 8px;
  background: #ffffff;
  color: #222222;
  font: inherit;
  font-weight: 400;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.settings-card .field > input:not([type='hidden']):not([type='radio']):not([type='checkbox']),
.field > input:not([type='hidden']):not([type='radio']):not([type='checkbox']) {
  min-height: 48px;
  padding: 0 14px;
}

.settings-card .field > textarea,
.field > textarea {
  min-height: 98px;
  padding: 12px 14px;
  line-height: 1.6;
  resize: vertical;
}

.field > input:not([type='hidden']):not([type='radio']):not([type='checkbox']):focus,
.field > input:not([type='hidden']):not([type='radio']):not([type='checkbox']):focus-visible,
.field > textarea:focus,
.field > textarea:focus-visible {
  outline: none;
  border-color: #111111;
  box-shadow: 0 0 0 1px #111111;
}

.field-hint {
  margin: 0;
  color: #777777;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
}

.field-hint-error {
  color: #b45309;
}

.gender-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gender-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #e7e0de;
  border-radius: 8px;
  background: #ffffff;
  color: #222222;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.gender-option span {
  line-height: 1.4;
}

.gender-option:has(input:checked) {
  border-color: #111111;
  background: #fafafa;
}

.gender-option input[type='radio'] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: #111111;
}

.input-wrap-password {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-wrap-password:focus-within {
  border-color: #111111;
  box-shadow: 0 0 0 1px #111111;
}

.field .input-wrap-password input:not([type='hidden']):not([type='radio']):not([type='checkbox']) {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  min-height: 48px;
  padding: 0 14px;
  outline: none;
  box-shadow: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.field .input-wrap-password input:not([type='hidden']):not([type='radio']):not([type='checkbox']):focus,
.field .input-wrap-password input:not([type='hidden']):not([type='radio']):not([type='checkbox']):focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.password-toggle {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 0;
  background: transparent;
  color: #777777;
}

.password-toggle svg {
  display: block;
}

.app-header .lang-switch {
  position: relative;
  top: auto;
  left: auto;
  justify-self: start;
  z-index: 50;
  overflow: visible;
}

.app-header .lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #111111;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app-header .lang-btn:hover {
  background: rgba(255, 255, 255, 0.96);
}

.app-header .lang-switch-menu {
  position: fixed;
  top: auto;
  left: auto;
  min-width: 190px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  z-index: 60;
}

.app-header .lang-switch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #111111;
}

.app-header .lang-switch-item:hover {
  background: rgba(214, 41, 38, 0.06);
}

.app-header .lang-switch-item.is-current {
  background: rgba(0, 0, 0, 0.05);
}

.app-header .lang-switch-label {
  font-size: 14px;
}

.app-header .lang-switch-code {
  font-size: 12px;
  color: #777777;
}

.app-header .lang-btn::-webkit-details-marker {
  display: none;
}

.app-header .lang-btn::marker {
  content: '';
}

.app-header .lang-switch[open] .lang-switch-menu {
  display: block;
}

.app-header .lang-switch-menu {
  display: none;
}

.form-error,
.flash-error {
  margin: -4px 0 16px;
  color: var(--red-dark);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.flash-success {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #edf7ef;
  color: #197a35;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.primary-button,
.outline-button,
.danger-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  border-radius: 999px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  border: 1px solid #dedede;
  background: #eeeeee;
  color: #9a9a9a;
  cursor: not-allowed;
}

.login-button {
  margin-top: 15px;
  min-height: 56px;
  font-size: 18px;
  font-weight: 600;
}

.login-button.is-ready {
  border-color: #111111;
  background: #111111;
  color: #ffffff;
  cursor: pointer;
}

.settings-card .primary-button {
  border-color: #1e1e1e;
  background: #ffffff;
  color: #1e1e1e;
  cursor: pointer;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-height: 40px;
  margin-bottom: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #222222;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.back-button svg {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.text-button {
  width: 100%;
  min-height: 42px;
  margin-top: 16px;
  margin-bottom: 16px;
  border: 0;
  background: transparent;
  color: #5d5d5d;
  font-size: 14px;
  font-weight: 400;
  text-decoration: underline;
  cursor: default;
}

.auth-link-stack {
  display: grid;
  gap: 0;
  margin-top: 28px;
  padding: 26px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.auth-link-stack h2 {
  margin: 0 0 24px;
  font-family: 'Noto Serif JP', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--red);
  text-align: center;
}

.register-link-button,
.official-text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  text-decoration: none;
}

.register-link-button {
  justify-self: center;
  width: min(100%, 320px);
  min-height: 56px;
  margin-bottom: 16px;
  border: 1px solid var(--red);
  border-radius: 999px;
  background: #ffffff;
  color: var(--red);
  font-size: 18px;
  font-weight: 400;
}

.official-text-link {
  gap: 6px;
  justify-self: center;
  min-width: min(100%, 260px);
  min-height: 42px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #555555;
  font-size: 14px;
  font-weight: 400;
}

.member-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  margin: 0;
}

.member-tabs button,
.member-tabs [role="tab"] {
  min-height: 48px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--tab);
  color: #ffffff;
  font-family: 'Noto Serif JP', serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.member-tabs button:focus,
.member-tabs button:focus-visible,
.member-tabs button:active,
.member-tabs [role="tab"]:focus,
.member-tabs [role="tab"]:focus-visible,
.member-tabs [role="tab"]:active {
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.member-tabs button.active,
.member-tabs [role="tab"].active {
  border-color: var(--red);
  background: var(--red);
}

.member-tab-panel {
  display: none;
}

.member-tab-panel.active {
  display: block;
}

.certificate {
  min-height: 334px;
  padding: 30px 24px;
  border: 1px solid var(--red);
  border-radius: 0 0 16px 16px;
  background: rgba(255, 255, 255, 0.98);
}

.certificate-head {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.certificate-head span,
.certificate-head dt {
  display: block;
  color: #797979;
  font-size: 10px;
  font-weight: 600;
}

.certificate-head strong {
  display: block;
  margin-top: 5px;
  font-family: 'Noto Serif JP', serif;
  font-size: 18px;
}

.status-block {
  display: grid;
  grid-template-columns: 33px 1fr;
  gap: 6px;
  align-items: start;
}

.valid-icon {
  color: var(--green);
}

.status-block dl {
  margin: 0;
  display: grid;
  gap: 2px;
}

.status-block div {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px;
}

.status-block dd {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
}

.barcode-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 312px;
  min-height: 92px;
  margin: 0 auto;
}

.barcode-panel svg {
  width: 100%;
  height: auto;
  display: block;
}

.member-number {
  margin-top: 8px;
  color: #777777;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.certificate-note {
  margin: 28px 0 0;
  color: #888888;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.65;
}

.inactive-note {
  margin: 18px 0 0;
  padding: 14px;
  border-radius: 8px;
  background: #fff6f5;
  border: 1px solid #f0d0cd;
  color: var(--red-dark);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.65;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 26px;
  color: #9b9b9b;
  text-align: center;
}

.empty-state p {
  max-width: 260px;
  margin: 0;
  font-family: 'Noto Serif JP', serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.85;
}

.empty-state a {
  color: var(--red);
  font-weight: 600;
}

.logout-row {
  display: flex;
  justify-content: center;
  margin-top: 54px;
}

.outline-button {
  width: 190px;
  border: 1px solid #555555;
  background: #ffffff;
  color: #171717;
}

.icon-inline {
  display: inline-block;
  vertical-align: middle;
}

@media (max-width: 767px) {
  body {
    background: #ffffff;
  }

  .desktop-gate {
    display: none;
  }

  .mobile-app {
    display: block;
  }
}

@media (max-width: 374px) {
  .phone-safe {
    padding-left: 16px;
    padding-right: 16px;
  }

  .certificate {
    padding-left: 18px;
    padding-right: 18px;
  }

  .member-tabs button,
  .member-tabs [role="tab"] {
    font-size: 12px;
  }

  .settings-card {
    padding: 20px;
  }

  .settings-secondary-actions {
    flex-direction: column;
    gap: 4px;
  }

  .withdrawal-meta {
    grid-template-columns: 1fr;
  }

  .withdrawal-card-head {
    flex-direction: column;
  }
}
