:root {
  --sh-header-height: 56px;
}

/* Shared header base */
.shared-header {
  position: sticky;
  top: 0;
  z-index: 54;
  height: var(--sh-header-height);
  background: rgba(11, 13, 20, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #334155;
}

.shared-header__inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  max-width: 80rem;
  margin: 0 auto;
  height: 100%;
  padding: 0 0.75rem;
}

.shared-header__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin-right: auto;
}

.shared-header__logo {
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.shared-header__title {
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shared-header__title--sub {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Gold display */
.shared-header__gold {
  display: none;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid #334155;
  color: #fbbf24;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .shared-header__gold {
    display: inline-flex;
  }
}

.shared-header__gold-icon {
  font-size: 0.875rem;
  line-height: 1;
}

.shared-header__gold-value {
  font-variant-numeric: tabular-nums;
}

.shared-header__action--announcements,
.shared-header__menu-item--announcements {
  position: relative;
}

.shared-header__announcements-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
}

.shared-header__menu-item--announcements .shared-header__announcements-badge {
  position: static;
  margin-left: auto;
}

/* Desktop actions */
.shared-header__actions {
  display: none;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  min-width: 0;
}

@media (min-width: 640px) {
  .shared-header__actions {
    display: flex;
  }
}

/* Back button is always visible when present, even on mobile */
.shared-header__action[aria-label="戻る"] {
  display: inline-flex;
}

@media (max-width: 639px) {
  .shared-header__actions {
    display: flex;
  }
  /* Hide non-back desktop actions on mobile to save space */
  .shared-header__actions > .shared-header__action:not([aria-label="戻る"]) {
    display: none;
  }
}

.shared-header__action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  border: 1px solid #334155;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.shared-header__action:hover {
  background: #27364a;
  color: #ffd06b;
}

.shared-header__action--logout:hover {
  color: #ff7373;
  border-color: rgba(255, 115, 115, 0.5);
}

/* Hamburger (always visible on all viewports) */
.shared-header__hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-left: 0.5rem;
}

.shared-header__hamburger-bar {
  display: block;
  width: 1.25rem;
  height: 0.125rem;
  background: currentColor;
  border-radius: 9999px;
  position: relative;
  transition: background-color 0.2s ease;
}

.shared-header__hamburger-bar::before,
.shared-header__hamburger-bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 0.125rem;
  background: currentColor;
  border-radius: 9999px;
  transition: transform 0.2s ease, top 0.2s ease;
}

.shared-header__hamburger-bar::before {
  top: -0.375rem;
}

.shared-header__hamburger-bar::after {
  top: 0.375rem;
}

.shared-header__hamburger[aria-expanded="true"] .shared-header__hamburger-bar {
  background: transparent;
}

.shared-header__hamburger[aria-expanded="true"] .shared-header__hamburger-bar::before {
  top: 0;
  transform: rotate(45deg);
}

.shared-header__hamburger[aria-expanded="true"] .shared-header__hamburger-bar::after {
  top: 0;
  transform: rotate(-45deg);
}

/* Slide-out drawer menu */
.shared-header__menu {
  display: none;
  position: fixed;
  top: var(--sh-header-height);
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  z-index: 53;
  background: rgba(11, 13, 20, 0.98);
  border-left: 1px solid #334155;
  padding: 0.5rem;
  box-shadow: -10px 0 25px rgba(0, 0, 0, 0.4);
  overflow-y: auto;
}

.shared-header__menu.is-open {
  display: block;
}

.shared-header__menu-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.shared-header__menu-section--mobile {
  display: flex;
}

@media (min-width: 640px) {
  .shared-header__menu-section--mobile {
    display: none;
  }
}

.shared-header__menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.shared-header__menu-item:hover,
.shared-header__menu-item:active {
  background: #1e293b;
}

.shared-header__menu-item--logout {
  color: #ff7373;
}

/* Backdrop for mobile menu */
.shared-header__backdrop {
  display: none;
  position: fixed;
  inset: var(--sh-header-height) 0 0 0;
  z-index: 52;
  background: rgba(0, 0, 0, 0.5);
}

.shared-header__backdrop.is-open {
  display: block;
}

/* Ensure body padding accounts for sticky header if needed */
body.has-shared-header {
  /* optional: padding-top: var(--sh-header-height); */
}

/* Request modal */
.request-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.request-modal.is-open {
  display: flex;
}

.request-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.request-modal__content {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.request-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #334155;
}

.request-modal__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
}

.request-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
}

.request-modal__close:hover {
  background: #1e293b;
  color: #f1f5f9;
}

.request-modal__body {
  padding: 1.25rem;
}

.request-modal__label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #cbd5e1;
}

.request-modal__textarea {
  width: 100%;
  min-height: 140px;
  padding: 0.75rem;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.875rem;
  line-height: 1.5;
  resize: vertical;
}

.request-modal__textarea::placeholder {
  color: #64748b;
}

.request-modal__textarea:focus {
  outline: none;
  border-color: #ffd06b;
}

.request-modal__counter {
  margin-top: 0.375rem;
  text-align: right;
  font-size: 0.75rem;
  color: #94a3b8;
}

.request-modal__note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.5;
}

.request-modal__error {
  margin-top: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.375rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.875rem;
}

.request-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.request-modal__button {
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.request-modal__button--primary {
  background: #ffd06b;
  color: #0f172a;
}

.request-modal__button--primary:hover:not(:disabled) {
  background: #ffdf99;
}

.request-modal__button--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.request-modal__button--secondary {
  background: transparent;
  border-color: #334155;
  color: #cbd5e1;
}

.request-modal__button--secondary:hover {
  background: #1e293b;
}

.request-modal__success {
  padding: 2rem 1.25rem;
  text-align: center;
  color: #f1f5f9;
}

.request-modal__success-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  font-size: 1.5rem;
  font-weight: 700;
}

.request-modal__success p {
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

