/**
 * HAIDEX app theme — 白・薄灰ベース + 深緑ブランド差し色 + 旧青 Primary action
 * Replay 盤面 CSS とは分離。主要アプリ画面のみ link する。
 *
 * brand green: wordmark X / active nav / subtle accent / focus
 * action primary: CTA・実行ボタン（pre-green stats/billing blue）
 */
:root {
  /* Brand accent (green) — not for Primary fill */
  --haidex-brand-green: #15803d;
  --haidex-brand-green-hover: #166534;
  --haidex-accent: #16a34a;
  --haidex-light: #dcfce7;
  --haidex-very-light: #f0f8f2;
  --haidex-border-green: #c9dfd0;
  --haidex-dark-brand: #071a13;

  /* Compat aliases: --haidex-primary* = brand green */
  --haidex-primary: var(--haidex-brand-green);
  --haidex-primary-hover: var(--haidex-brand-green-hover);

  /* Action primary — restore pre-green-theme CTA blue (stats/billing --accent) */
  --haidex-action-primary: #2f5f9f;
  --haidex-action-primary-hover: #1e4478;

  --haidex-page-bg: #f6f8f7;
  --haidex-card: #ffffff;
  --haidex-card-subtle: #f3f6f4;
  --haidex-text: #111827;
  --haidex-text-secondary: #64748b;
  --haidex-text-muted: #94a3b8;
  --haidex-border: #d8e1dc;
  --haidex-focus-ring: rgba(21, 128, 61, 0.35);
  --haidex-radius: 7px;
  --haidex-header-h: 3.25rem;
  /* Shared header geometry (LP + app). Body containers keep their own max-width. */
  --haidex-header-max: 1200px;
  --haidex-header-pad-x: 16px;
}

/* ---- page shell ---- */
body.haidex-app {
  margin: 0;
  color: var(--haidex-text);
  background: var(--haidex-page-bg);
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}

body.haidex-app a:focus-visible,
body.haidex-app button:focus-visible,
body.haidex-app summary:focus-visible,
body.haidex-app input:focus-visible,
body.haidex-app select:focus-visible,
body.haidex-app textarea:focus-visible {
  outline: 2px solid var(--haidex-brand-green);
  outline-offset: 2px;
}

body.haidex-app input[type="checkbox"],
body.haidex-app input[type="radio"] {
  accent-color: var(--haidex-brand-green);
}

/* ---- shared app header ---- */
.haidex-app-header,
#haidex_auth_nav.haidex-auth-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 1.1rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0 0.75rem;
  border-bottom: 1px solid var(--haidex-border);
  background: var(--haidex-card);
  font-size: 13px;
  line-height: 1.35;
  color: var(--haidex-text-secondary);
}

/*
 * Viewport-aligned header bar (not body max-width).
 * Content inset matches LP: max(pad, (100vw - header-max) / 2).
 * Covers auth_ui mount (#haidex_auth_nav) and static header.haidex-app-header (OSS).
 */
body.haidex-app #haidex_auth_nav.haidex-auth-nav,
body.haidex-app > header.haidex-app-header {
  box-sizing: border-box;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: 0;
  margin-top: -12px;
  margin-bottom: 1rem;
  padding-top: 0.7rem;
  padding-bottom: 0.75rem;
  padding-left: max(
    var(--haidex-header-pad-x),
    calc((100vw - var(--haidex-header-max)) / 2)
  );
  padding-right: max(
    var(--haidex-header-pad-x),
    calc((100vw - var(--haidex-header-max)) / 2)
  );
  box-shadow: 0 1px 0 rgba(7, 26, 19, 0.04);
}

.haidex-wordmark {
  display: inline-flex;
  align-items: baseline;
  flex-shrink: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-decoration: none;
  color: var(--haidex-text);
  min-width: 7.5rem;
}

.haidex-wordmark:hover {
  text-decoration: none;
  color: var(--haidex-text);
}

.haidex-wordmark:focus-visible {
  outline: 2px solid var(--haidex-brand-green);
  outline-offset: 3px;
  border-radius: 2px;
}

.haidex-wordmark-x {
  color: var(--haidex-brand-green);
}

.haidex-app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.15rem;
  flex: 1 1 auto;
  min-width: 0;
}

.haidex-app-nav a {
  display: inline-block;
  padding: 0.35rem 0.55rem;
  color: var(--haidex-text);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  border-radius: 2px 2px 0 0;
}

.haidex-app-nav a:hover {
  color: var(--haidex-brand-green);
  text-decoration: none;
  background: var(--haidex-very-light);
}

.haidex-app-nav a.is-active,
.haidex-app-nav a[aria-current="page"] {
  color: var(--haidex-brand-green);
  font-weight: 600;
  border-bottom-color: var(--haidex-brand-green);
  background: transparent;
}

.haidex-app-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.haidex-app-header-actions a {
  color: var(--haidex-text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.3rem 0.45rem;
}

.haidex-app-header-actions a:hover {
  color: var(--haidex-brand-green);
  text-decoration: underline;
}

button.haidex-logout-btn,
.haidex-logout-btn {
  appearance: none;
  margin: 0;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--haidex-text);
  background: #fff;
  border: 1px solid var(--haidex-border);
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.3;
}

button.haidex-logout-btn:hover:not(:disabled),
.haidex-logout-btn:hover:not(:disabled) {
  background: var(--haidex-very-light);
  border-color: var(--haidex-border-green);
}

button.haidex-logout-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.haidex-auth-nav .muted {
  color: var(--haidex-text-secondary);
}

/* Mobile: row1 wordmark + logout, row2 nav */
@media (max-width: 720px) {
  .haidex-wordmark {
    font-size: 1.2rem;
    min-width: 0;
  }

  .haidex-app-header-actions {
    margin-left: auto;
  }

  .haidex-app-nav {
    flex-basis: 100%;
    order: 3;
    gap: 0.1rem 0.05rem;
    padding-top: 0.15rem;
  }

  .haidex-app-nav a {
    padding: 0.3rem 0.4rem;
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  body.haidex-app #haidex_auth_nav.haidex-auth-nav,
  body.haidex-app > header.haidex-app-header {
    --haidex-header-pad-x: 12px;
  }

  .haidex-app-nav a {
    padding: 0.28rem 0.32rem;
  }
}

/* ---- shared cards / buttons (opt-in classes) ---- */
.haidex-card {
  background: var(--haidex-card);
  border: 1px solid var(--haidex-border);
  border-radius: var(--haidex-radius);
}

.haidex-btn-primary,
button.haidex-btn-primary,
a.haidex-btn-primary {
  display: inline-block;
  padding: 0.55rem 1.15rem;
  font-size: 14px;
  font-weight: 600;
  color: #fff !important;
  background: var(--haidex-action-primary);
  border: 1px solid var(--haidex-action-primary-hover);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.35;
}

.haidex-btn-primary:hover:not(:disabled),
button.haidex-btn-primary:hover:not(:disabled),
a.haidex-btn-primary:hover {
  background: var(--haidex-action-primary-hover);
  text-decoration: none;
}

.haidex-btn-primary:disabled,
button.haidex-btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.haidex-btn-secondary,
button.haidex-btn-secondary,
a.haidex-btn-secondary {
  display: inline-block;
  padding: 0.55rem 1.15rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--haidex-text) !important;
  background: #fff;
  border: 1px solid var(--haidex-border);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.35;
}

.haidex-btn-secondary:hover:not(:disabled),
button.haidex-btn-secondary:hover:not(:disabled),
a.haidex-btn-secondary:hover {
  background: var(--haidex-very-light);
  border-color: var(--haidex-border-green);
  text-decoration: none;
}

.haidex-success-panel {
  border: 1px solid var(--haidex-border-green);
  background: var(--haidex-light);
  border-radius: var(--haidex-radius);
  color: var(--haidex-dark-brand);
}

/* Pre-green-theme PLUS badge (091c9c9^ .cond-paid-badge) */
.haidex-plus-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  color: #5d4037;
  background: #efebe9;
  border: 1px solid #bcaaa4;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  vertical-align: middle;
}
