/* ============================================
   AUBE — Mobile App Shell
   会員ページ共通のアプリシェル。style.css の後に読み込む。
   ============================================ */

:root {
  /* Color */
  --app-bg: #080808;
  --app-surface: #0d0d0d;
  --app-surface-raised: #141414;
  --app-border: rgba(201, 168, 76, 0.18);
  --app-gold: #c9a84c;
  --app-gold-light: #e2c97a;
  --app-gold-dim: #8a6f2e;
  --app-text: #f0ead8;
  --app-text-sub: #8a99b0;

  /* Safe area */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Geometry */
  --tap-min: 44px;
  --app-header-base: 56px;
  --app-header-height: calc(var(--app-header-base) + var(--safe-top));
  --app-tab-base: 64px;
  --app-tab-height: calc(var(--app-tab-base) + var(--safe-bottom));
  --app-inline-padding: 16px;
  --app-inline-left: max(var(--app-inline-padding), var(--safe-left));
  --app-inline-right: max(var(--app-inline-padding), var(--safe-right));

  /* Bottom sheet */
  --sheet-peek: calc(112px + var(--safe-bottom));
  --sheet-half: 52dvh;
  --sheet-expanded: calc(100dvh - var(--app-header-height));

  /* Keyboard / visual viewport（JSから更新） */
  --keyboard-height: 0px;
  --visual-viewport-height: 100dvh;
  --visual-viewport-offset-top: 0px;

  /* Layer */
  --z-content: 1;
  --z-sticky: 20;
  --z-header: 40;
  --z-tabs: 50;
  --z-map-controls: 60;
  --z-sheet-backdrop: 80;
  --z-sheet: 90;
  --z-modal: 100;
  --z-toast: 110;
}

/* ============================================
   1. Viewport helpers
   ============================================ */

.app-viewport {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
}

.app-fixed-viewport {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
}

/* ============================================
   2. Shell
   ============================================ */

body.app-shell {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--app-bg);
  overflow-x: clip;
}

.app-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: var(--z-header);
  height: var(--app-header-height);
  padding: var(--safe-top) var(--app-inline-right) 0 var(--app-inline-left);
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 8px;
  background: rgba(8, 8, 8, 0.9);
  border-bottom: 1px solid var(--app-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap-min);
  text-decoration: none;
  justify-self: start;
}

.app-brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--app-gold);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--app-gold);
  font: 400 15px/1 'Cormorant Garamond', serif;
  flex: 0 0 auto;
}

.app-brand-name {
  font: 400 15px/1 'Cormorant Garamond', serif;
  letter-spacing: 0.28em;
  color: var(--app-text);
}

.app-header-title {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--app-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-action {
  justify-self: end;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border: 0;
  background: none;
  color: var(--app-text-sub);
  font-size: 19px;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.app-main {
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(var(--app-header-height) + 16px) var(--app-inline-right)
    calc(var(--app-tab-height) + 24px) var(--app-inline-left);
}

/* ============================================
   3. Bottom tabs
   ============================================ */

.app-tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: var(--z-tabs);
  height: var(--app-tab-height);
  padding: 4px max(6px, var(--safe-right)) var(--safe-bottom)
    max(6px, var(--safe-left));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: rgba(8, 8, 8, 0.96);
  border-top: 1px solid var(--app-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.app-tab {
  position: relative;
  min-width: 0;
  min-height: var(--tap-min);
  padding: 0;
  border: 0;
  background: none;
  color: var(--app-text-sub);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-tab-icon {
  font-size: 19px;
  line-height: 1;
}

.app-tab-label {
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.app-tab.is-active {
  color: var(--app-gold-light);
}

.app-tab.is-active::after {
  content: '';
  position: absolute;
  top: 0;
  width: 24px;
  height: 1px;
  background: var(--app-gold);
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.45);
}

.app-tab-call {
  overflow: visible;
  color: var(--app-gold-light);
}

.app-tab-call-icon {
  width: 52px;
  height: 52px;
  margin-top: -24px;
  border: 1px solid var(--app-gold);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 25%, #e2c97a, #8a6f2e);
  color: #080808;
  font: 600 23px/1 'Cormorant Garamond', serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 0 5px #080808;
}

.app-tab-badge {
  position: absolute;
  top: 3px;
  left: calc(50% + 8px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--app-gold);
  color: #080808;
  font-size: 10px;
  line-height: 17px;
  text-align: center;
}

/* ============================================
   4. Bottom sheet
   ============================================ */

.app-sheet {
  --sheet-current-height: var(--sheet-peek);

  position: fixed;
  inset: auto 0 0;
  z-index: var(--z-sheet);
  height: var(--sheet-current-height);
  max-height: calc(100dvh - var(--app-header-height));
  padding-bottom: var(--safe-bottom);
  border-radius: 20px 20px 0 0;
  background: var(--app-surface-raised);
  border-top: 1px solid var(--app-border);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
  transform: translateY(100%);
  visibility: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

.app-sheet.is-open {
  transform: translateY(0);
  visibility: visible;
}

.app-sheet.is-peek {
  --sheet-current-height: var(--sheet-peek);
}

.app-sheet.is-half {
  --sheet-current-height: var(--sheet-half);
}

.app-sheet.is-expanded {
  --sheet-current-height: var(--sheet-expanded);
}

.app-sheet-handle {
  width: 100%;
  min-height: var(--tap-min);
  touch-action: none;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}

.app-sheet-handle span {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(240, 234, 216, 0.25);
}

.app-sheet-header {
  flex: 0 0 auto;
  padding: 0 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-sheet-header h2 {
  margin: 0;
  font: 400 17px/1.4 'Cormorant Garamond', serif;
  letter-spacing: 0.1em;
  color: var(--app-text);
}

.app-sheet-close {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border: 0;
  background: none;
  color: var(--app-text-sub);
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.app-sheet-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px calc(20px + var(--safe-bottom));
}

.app-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet-backdrop);
  background: rgba(0, 0, 0, 0.68);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s;
}

.app-sheet-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

body.has-open-sheet {
  overflow: hidden;
  touch-action: none;
}

body.has-open-sheet .app-sheet,
body.has-open-sheet .app-sheet-body {
  touch-action: pan-y;
}

/* 「その他」シートの共通メニュー */
.more-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 8px;
}

.more-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 4px;
  font-size: 15px;
  color: var(--app-text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.more-item-icon {
  font-size: 17px;
  width: 22px;
  text-align: center;
}

.more-item-tag {
  margin-left: auto;
  background: rgba(201, 168, 76, 0.15);
  color: var(--app-gold);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.05em;
}

/* ============================================
   5. Form controls — iOS自動ズーム防止
   ============================================ */

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

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
  font-size: 16px !important;
}

input[type='checkbox'],
input[type='radio'] {
  width: 20px;
  height: 20px;
}

.app-control,
.app-button {
  min-height: var(--tap-min);
}

.app-button-primary {
  min-height: 50px;
}

.app-check-label {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* チップ類：見た目は 36〜38px のまま、実タップ領域だけ 44px に広げる */
.filter-tag,
.filter-chip {
  position: relative;
}

.filter-tag::after,
.filter-chip::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: var(--tap-min);
}

/* ============================================
   6. Interaction — hover隔離 / motion
   ============================================ */

.app-tab:active,
.app-button:active,
.app-card:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .app-tab:hover {
    color: var(--app-gold-light);
  }

  .app-card:hover {
    border-color: var(--app-gold-dim);
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
