/* ============================================================
   MOAI Trading Intelligence
   ============================================================ */

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

:root {
  --bg: #0e0a1f;
  --text: #ffffff;
  --text-2: rgba(255, 255, 255, 0.78);
  --text-3: rgba(255, 255, 255, 0.52);

  --card: rgba(255, 255, 255, 0.05);
  --card-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --border-2: rgba(255, 255, 255, 0.2);

  --accent: #a78bfa;
  --profit: #5eead4;
  --profit-soft: rgba(94, 234, 212, 0.16);
  --profit-strong: rgba(94, 234, 212, 0.4);
  --loss: #fb7185;
  --loss-soft: rgba(251, 113, 133, 0.16);
  --loss-strong: rgba(251, 113, 133, 0.4);

  --radius-s: 8px;
  --radius: 14px;

  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
}

html, body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 15% -10%, rgba(99, 102, 241, 0.2), transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 40%, rgba(167, 139, 250, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(94, 234, 212, 0.06), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Meiryo", "Segoe UI", sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-5);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  pointer-events: none;
}

/* ============================================================
   Top navigation
   ============================================================ */
.topnav {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-mark {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
}
.brand-tag {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 3px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
}
.ea-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}
.ea-pill::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #f472b6);
}

/* ============================================================
   Hamburger menu
   ============================================================ */
.menu-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.menu-toggle:hover {
  background: var(--card-2);
  border-color: var(--border-2);
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.2s;
}
.menu-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.is-open span:nth-child(2) { opacity: 0; }
.menu-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 22, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
.menu-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.menu-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: 360px;
  max-width: 88vw;
  background: linear-gradient(180deg, #150f2c 0%, #0e0a1f 100%);
  border-left: 1px solid var(--border);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.5);
}
.menu-drawer.is-open { transform: translateX(0); }

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.menu-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 1.7rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 8px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.menu-close:hover { background: var(--card-2); color: var(--text); }

.menu-nav {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-s);
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.menu-item:hover {
  background: var(--card-2);
  border-color: var(--border-2);
  color: var(--text);
  transform: translateX(2px);
}
.menu-item.is-current {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(94, 234, 212, 0.08));
  border-color: rgba(167, 139, 250, 0.4);
}
.menu-no {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  flex-shrink: 0;
}
.menu-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.menu-label {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.menu-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  line-height: 1.4;
}
.menu-arrow {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-3);
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}
.menu-item:hover .menu-arrow { color: var(--accent); transform: translateX(3px); }

.menu-foot {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.74rem;
  color: var(--text-3);
  letter-spacing: 0.08em;
}

/* ============================================================
   Section heading
   ============================================================ */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.section-head h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-head h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent), var(--profit));
  border-radius: 2px;
}
.nav-controls { display: flex; gap: var(--space-1); }
.iconbtn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-s);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.iconbtn:hover {
  background: var(--card-2);
  border-color: var(--border-2);
}
.iconbtn:disabled { opacity: 0.3; cursor: not-allowed; }
.iconbtn:disabled:hover { background: var(--card); border-color: var(--border); }

/* ============================================================
   Stats row (月間 / 累計)
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14%;
  right: 14%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  pointer-events: none;
}
.stat-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-label::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: linear-gradient(180deg, var(--accent), var(--profit));
  border-radius: 2px;
}
.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--text);
}
.stat-value.profit { color: var(--profit); }
.stat-value.loss { color: var(--loss); }
.stat-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* ============================================================
   Calendar
   ============================================================ */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.wd {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-3);
  font-weight: 500;
  padding: 4px 0;
  min-width: 0;
}
.wd.sun { color: var(--loss); }
.wd.sat { color: #93c5fd; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.day-cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s;
}
.day-cell:not(.empty):hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-2);
}
.day-cell.empty { background: transparent; border-color: transparent; }
.day-cell.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.4);
}
.day-cell .date-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.88rem;
  color: var(--text-2);
  font-weight: 500;
}
.day-cell.is-sun .date-num { color: var(--loss); }
.day-cell.is-sat .date-num { color: #93c5fd; }
.day-cell .pnl {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  min-width: 0;
}
.day-cell.profit {
  background: linear-gradient(160deg, rgba(94, 234, 212, 0.22) 0%, rgba(94, 234, 212, 0.04) 100%);
  border-color: rgba(94, 234, 212, 0.4);
}
.day-cell.profit .pnl { color: var(--profit); }
.day-cell.loss {
  background: linear-gradient(160deg, rgba(251, 113, 133, 0.22) 0%, rgba(251, 113, 133, 0.04) 100%);
  border-color: rgba(251, 113, 133, 0.4);
}
.day-cell.loss .pnl { color: var(--loss); }

/* ============================================================
   Chart
   ============================================================ */
.chart-wrap { height: 320px; position: relative; }

/* ============================================================
   Status
   ============================================================ */
.status {
  margin: var(--space-2) 0;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: 0.85rem;
  text-align: center;
  display: none;
}
.status.show { display: block; }
.status.error {
  background: var(--loss-soft);
  color: var(--loss);
  border: 1px solid var(--loss-strong);
}
.status.info {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent);
  border: 1px solid rgba(167, 139, 250, 0.32);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  max-width: 1080px;
  margin: var(--space-4) auto 0;
  padding: var(--space-3);
  font-size: 0.78rem;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .topnav {
    padding: var(--space-2);
    gap: 10px;
  }
  .brand { gap: 10px; }
  .brand-name { font-size: 1.18rem; }
  .brand-tag { font-size: 0.66rem; letter-spacing: 0.12em; }
  .logo-mark { width: 34px; height: 34px; font-size: 1.05rem; border-radius: 9px; }
  .ea-pill { padding: 6px 12px; font-size: 0.82rem; }

  .container { padding: var(--space-3) var(--space-2) var(--space-4); }

  .card { padding: 18px 14px; margin-bottom: var(--space-2); }
  .card::before { left: 18%; right: 18%; }

  .stats-row { gap: 10px; margin-bottom: var(--space-2); }
  .stat-card { padding: 16px 16px; }
  .stat-card::before { left: 18%; right: 18%; }
  .stat-label { font-size: 0.68rem; letter-spacing: 0.14em; margin-bottom: 8px; }
  .stat-label::before { height: 12px; }
  .stat-value { font-size: 1.4rem; }
  .stat-sub { font-size: 0.7rem; }

  .section-head { margin-bottom: 18px; padding-bottom: 14px; }
  .section-head h2 { font-size: 1.05rem; gap: 10px; }
  .section-head h2::before { width: 3px; height: 16px; }
  .iconbtn { width: 34px; height: 34px; font-size: 1.05rem; }

  .calendar-weekdays, .calendar-grid { gap: 4px; }
  .calendar-weekdays { margin-bottom: 6px; }
  .wd { font-size: 0.74rem; padding: 2px 0; }
  .day-cell { padding: 5px 4px; border-radius: 6px; }
  .day-cell .date-num { font-size: 0.74rem; }
  .day-cell .pnl { font-size: 0.6rem; }

  .chart-wrap { height: 240px; }

  .site-footer { padding: var(--space-3) var(--space-2); font-size: 0.74rem; }
}

@media (max-width: 380px) {
  .container { padding: var(--space-2) 12px var(--space-3); }
  .card { padding: 14px 10px; }
  .calendar-weekdays, .calendar-grid { gap: 3px; }
  .day-cell { padding: 4px 3px; }
  .day-cell .date-num { font-size: 0.68rem; }
  .day-cell .pnl { font-size: 0.54rem; }
  .wd { font-size: 0.68rem; }
  .section-head h2 { font-size: 0.98rem; }
}
