:root {
  --bg-color: #ffffff;
  --text-main: #1f1f1f;
  --text-secondary: rgba(31, 31, 31, 0.72);
  --text-muted: rgba(31, 31, 31, 0.45);
  --card-bg-glass: #f1f3f4;
  --border-glass: #e0e0e4;
  --btn-primary-bg: #1f1f1f;
  --btn-primary-text: #ffffff;
  --switch-track-bg: #e0e0e4;
  --switch-track-checked-bg: #1f1f1f;
  --switch-thumb-bg: #ffffff;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

*,
*:before,
*:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

::selection {
  background-color: #e0e0e4;
  color: var(--text-main);
}

body {
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button,
input,
textarea,
select,
a {
  font-family: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  background: transparent;
  border: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.module-error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  background-color: #fee2e2;
  color: #991b1b;
  border-bottom: 2px solid #ef4444;
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.5;
}

.app-container {
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
  background-color: var(--bg-color);
}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==================== 1. ヘッダー＆常設検索バー ==================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background-color: #ffffff;
  padding-top: var(--sat);
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 680px;
  height: 52px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand-logo {
  font-size: 29px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text-main);
  line-height: 1;
  text-decoration: none;
  flex-shrink: 0;
  cursor: pointer;
}

.header-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid #000000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.header-icon-btn:hover {
  background-color: #f7f7f8;
}

.header-icon-btn:active {
  transform: scale(0.92);
}

.header-icon-btn .google-icon {
  width: 19px;
  height: 19px;
  display: block;
  flex-shrink: 0;
}

.menu-close-btn,
.modal-top-close-btn {
  width: 38px;
  height: 38px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.modal-top-close-btn {
  position: absolute;
  top: calc(16px + var(--sat));
  left: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
}

.menu-close-btn:hover,
.modal-top-close-btn:hover {
  opacity: 0.6;
}

.menu-close-btn:active,
.modal-top-close-btn:active {
  transform: scale(0.92);
}

.header-search-bar-row {
  width: 100%;
  padding: 0 16px 10px;
}

.header-search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 680px;
  height: 38px;
  margin: 0 auto;
  background-color: #ffffff;
  border-radius: 9999px;
  padding: 0 14px;
  border: 1px solid #000000;
}

.search-input-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.header-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  color: var(--text-main);
}

.header-search-input::placeholder {
  color: var(--text-muted);
}

.search-clear-btn {
  color: var(--text-muted);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.search-clear-btn:hover {
  color: var(--text-main);
}

/* 検索結果が0件の場合の空状態表示 (絵文字なし) */
.search-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  width: 100%;
  text-align: center;
  gap: 8px;
}

.search-empty-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.search-empty-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ==================== 2. 全画面メニューモーダル ==================== */
.menu-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 120;
  background-color: #ffffff;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(6px + var(--sat)) 24px calc(20px + var(--sab));
  overflow-y: auto;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  height: 42px;
  flex-shrink: 0;
}

.menu-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  text-align: center;
}

.menu-top-spacer {
  width: 40px;
}

.menu-buttons-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin-top: 24px;
  margin-bottom: auto;
}

.menu-button-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.menu-stack-btn {
  width: 100%;
  height: 56px;
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid #000000;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.menu-stack-btn:hover {
  background-color: #f7f7f8;
}

.menu-stack-btn:active {
  transform: scale(0.985);
}

.menu-bottom-footer,
.main-bottom-footer {
  width: 100%;
  max-width: 680px;
  text-align: center;
  padding: 24px 0 10px;
  flex-shrink: 0;
  margin-top: auto;
}

.main-bottom-footer {
  padding: 36px 0 8px;
}

.stripe-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.stripe-badge-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.stripe-badge-logo {
  height: 22px;
  width: auto;
  color: #635bff;
  display: block;
}

.menu-footer-links {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.7rem;
  color: rgba(15, 15, 15, 0.45);
  white-space: nowrap;
  overflow-x: auto;
}

.menu-footer-links a {
  color: inherit;
  text-decoration: none;
}

.menu-footer-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.menu-footer-links span.sep {
  color: rgba(0, 0, 0, 0.15);
}

/* ==================== 3. スクロール領域＆サインカード ==================== */
.screen-scroll-container {
  flex: 1;
  width: 100%;
  min-height: 100%;
  overflow-y: auto;
  padding: calc(114px + var(--sat)) 24px calc(40px + var(--sab));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sign-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

.sign-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  overflow: hidden;
  text-align: left;
  width: 100%;
  transition: transform 0.18s ease, border-color 0.18s ease;
  position: relative;
}

.sign-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 0, 0, 0.25);
}

.sign-card-img {
  width: 100%;
  aspect-ratio: 10 / 7;
  object-fit: cover;
  display: block;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sign-card-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 14px 16px 16px;
}

.sign-card-creator {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sign-card-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.sign-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.sign-card-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.sign-buy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  height: 32px;
  background: var(--btn-primary-bg);
  border-radius: 9999px;
  color: var(--btn-primary-text);
  font-size: 0.8rem;
  font-weight: 700;
  transition: opacity 0.2s ease;
}

.sign-buy-btn:hover {
  opacity: 0.85;
}

.sign-buy-btn.owned {
  background: var(--border-glass);
  color: var(--text-main);
}

/* ==================== 4. フルスクリーンモーダル＆共通カード ==================== */
.full-screen-modal {
  position: absolute;
  inset: 0;
  z-index: 200;
  background-color: var(--bg-color);
  overflow: hidden;
  animation: fadeIn 0.22s ease;
}

.full-screen-card {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: calc(22px + var(--sat)) 20px calc(32px + var(--sab));
  overflow-y: auto;
}

.full-screen-header {
  text-align: center;
  padding: 6px 0 14px;
  margin-bottom: 12px;
}

.full-screen-header h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.full-screen-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 28px;
}

.surface-card {
  background-color: var(--card-bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.shop-notice-text {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: center;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.canvas-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden-file-input {
  display: none;
}

.file-upload-btn,
.tool-mini-btn {
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  background-color: #ffffff;
  color: var(--text-main);
}

.file-upload-btn:hover,
.tool-mini-btn:hover {
  background-color: var(--border-glass);
}

.sign-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  background-color: #ffffff;
  border: 2px dashed var(--border-glass);
  border-radius: 12px;
  cursor: crosshair;
  touch-action: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.form-row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.line-input {
  width: 100%;
  padding: 10px 4px;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-glass);
  color: var(--text-main);
  font-size: 0.98rem;
  font-weight: 600;
  transition: border-color 0.2s ease;
}

.line-input:focus {
  border-bottom-color: var(--text-main);
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.detail-label {
  color: var(--text-muted);
  font-weight: 600;
}

.detail-val {
  color: var(--text-main);
  font-weight: 700;
}

.text-ok {
  color: #047857;
}

.text-warn {
  color: #b45309;
}

.modal-actions-row {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.modal-btn-cancel {
  flex: 1;
  padding: 15px;
  background: var(--card-bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-radius: 30px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.modal-btn-cancel:hover {
  background-color: var(--border-glass);
}

.modal-btn-submit {
  flex: 1.4;
  padding: 15px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-radius: 30px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.modal-btn-submit:hover {
  opacity: 0.9;
}

.stream-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-glass);
}

.stream-setting-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.stream-setting-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.badge-outline {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  background-color: #ffffff;
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  white-space: nowrap;
}

.toggle-switch-btn {
  flex-shrink: 0;
  width: 48px;
  height: 26px;
  border-radius: 13px;
  background: var(--switch-track-bg);
  position: relative;
  transition: background 0.2s ease;
}

.toggle-switch-btn.checked {
  background: var(--switch-track-checked-bg);
}

.toggle-switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--switch-thumb-bg);
  position: absolute;
  top: 3px;
  left: 3px;
  transition: left 0.2s ease;
}

.toggle-switch-btn.checked .toggle-switch-thumb {
  left: 25px;
}

.btn-glass-action {
  width: 100%;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  transition: background-color 0.2s ease;
}

.btn-glass-action:hover {
  background-color: var(--border-glass);
}

/* ==================== 5. 購入完了フルスクリーン演出 ==================== */
.purchase-complete-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  padding: calc(24px + var(--sat)) 24px calc(36px + var(--sab));
  animation: fadeIn 0.25s ease-out forwards;
}

.purchase-complete-brand {
  position: absolute;
  top: calc(20px + var(--sat));
  left: 24px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.purchase-complete-content {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.purchase-complete-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.purchase-complete-kaomoji {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.purchase-complete-badge-showcase {
  margin: 12px 0;
  width: 240px;
  aspect-ratio: 10 / 7;
  border-radius: 16px;
  border: 2px solid var(--border-glass);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.purchase-complete-badge-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.purchase-complete-badge-label {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.purchase-complete-desc {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 12px;
}

.purchase-complete-btn {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-primary-bg);
  border-radius: 9999px;
  color: var(--btn-primary-text);
  font-size: 1rem;
  font-weight: 700;
}

/* ==================== 6. マイページ固有要素 ==================== */
.mypage-user-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mypage-avatar-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--text-main);
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mypage-user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.mypage-user-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mypage-user-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.mypage-user-email {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mypage-section-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
}

.mypage-collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mypage-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background-color: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 12px 6px;
}

.mypage-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.mypage-stat-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.mypage-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.mypage-collection-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

.mypage-collection-item {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.mypage-collection-item:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 0, 0, 0.25);
}

.mypage-collection-img {
  width: 100%;
  aspect-ratio: 10 / 7;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.mypage-collection-info {
  padding: 8px 10px;
}

.mypage-collection-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mypage-collection-creator {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mypage-logout-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.mypage-logout-btn {
  width: 100%;
  height: 48px;
  background-color: #ffffff;
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.mypage-logout-btn:hover {
  background-color: #fef2f2;
  border-color: rgba(220, 38, 38, 0.4);
}

.mypage-logout-btn:active {
  transform: scale(0.99);
}

/* ==================== 7. クリーン・テキスト表示 (ボックスなし) ==================== */
.clean-text-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 4px 48px;
}

.clean-text-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clean-text-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.clean-text-body {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.clean-info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* ==================== 8. 独立リーガルHTMLページ ==================== */
.legal-page-body {
  height: auto;
  min-height: 100dvh;
  overflow-y: auto;
  user-select: text;
}

.legal-page-container {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(16px + var(--sat)) 20px calc(40px + var(--sab));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.legal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  margin-bottom: 20px;
}

.legal-back-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid #000000;
  border-radius: 9999px;
}

.legal-back-link:hover {
  background-color: #f7f7f8;
}

.legal-page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  max-width: 560px;
  width: 100%;
  margin: 0 auto 20px;
  padding: 0 4px;
}
