@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-jp.min.css");

:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --fg: #1c1a22;
  --muted: #6b6675;
  --accent: #8a5e1f; /* macchiato (darkened for contrast on light) */
  --line: #e4e0d7;
}

* {
  box-sizing: border-box;
  font-family: "Pretendard JP Variable", "Pretendard JP", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Hiragino Sans", "Apple SD Gothic Neo", Meiryo, "Noto Sans JP", "Noto Sans KR", "Malgun Gothic", Osaka, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, "Segoe UI", sans-serif;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.nav .brand { font-weight: 700; color: var(--accent); text-decoration: none; }
.nav .spacer { flex: 1; }
.nav a { color: var(--fg); text-decoration: none; }
.nav a:hover { color: var(--accent); }
.nav .who { color: var(--muted); }

.content { max-width: 860px; margin: 0 auto; padding: 1.5rem 1.25rem; }

.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.ir-status {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.ir-status::before {
  content: "";
  display: inline-block;
  width: 0.55rem; height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: middle;
}
.ir-status.online { color: #2f9e44; border-color: #88d39a; }
.ir-status.online::before { background: #2f9e44; box-shadow: 0 0 6px rgba(47, 158, 68, 0.5); }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }
.artist { color: var(--muted); font-size: 0.9rem; }

input[type="search"], input[type="text"], input[type="password"], select {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font: inherit;
}
input[type="search"] { width: 100%; margin-bottom: 1rem; }

.search-bar { display: flex; gap: 0.5rem; align-items: stretch; margin-bottom: 1rem; }
.search-bar select { flex: 0 0 auto; }
.search-bar input[type="search"] { flex: 1; margin-bottom: 0; }

button {
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.chart-list { list-style: none; padding: 0; margin: 0; }
.chart-list li { border-bottom: 1px solid var(--line); }
.chart-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.4rem;
  color: var(--fg);
  text-decoration: none;
}
.chart-list a:hover { background: var(--bg); }
.chart-list .title { font-weight: 500; }

/* Chart (leaderboard) page header — Figma: Macchiato chart page. */
.chart-head { margin-bottom: 1.25rem; }
.chart-genre { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.15rem; }
.chart-head h1 { font-size: 1.6rem; margin: 0 0 0.3rem; }
.chart-head .artist { margin: 0 0 0.9rem; }
.chart-stats { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0; }
.chart-stats div { display: flex; flex-direction: column; }
.chart-stats dt { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
.chart-stats dd { margin: 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.chart-tables { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.table-pill { padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--muted);
              color: #fff; font-weight: 700; font-size: 0.8rem; }

.chart-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.85rem; }
.chart-links .links-label { color: var(--muted); font-size: 0.85rem; }
.link-btn {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--fg);
  font-size: 0.8rem;
  text-decoration: none;
}
.link-btn:hover { filter: brightness(0.97); }
.link-btn--bms { border-color: #8fc0e8; color: #1f7fc0; }
.link-btn--mocha { border-color: #e0c068; color: #8a5e1f; }
.link-btn--minir { border-color: #7fcdd9; color: #0e7fa3; }

table.ranking { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.ranking th, table.ranking td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
table.ranking th { color: var(--muted); font-weight: 600; }
.rank, .ex { font-variant-numeric: tabular-nums; }
.when { color: var(--muted); font-size: 0.9rem; }

.device-filter { display: inline-flex; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }

/* Clear lamps. Class suffix is beatoraja's ClearType.name() (PascalCase):
   NoPlay Failed AssistEasy LightAssistEasy Easy Normal Hard ExHard
   FullCombo Perfect Max. Default = outline (used on the leaderboard). */
.lamp { font-size: 0.8rem; padding: 0.12rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); }
.lamp-Max, .lamp-Perfect { color: #b07a12; border-color: #d8b25a; }
.lamp-FullCombo { color: #0e7fa3; border-color: #6fc4dd; }
.lamp-ExHard { color: #c2561a; border-color: #e8a06a; }
.lamp-Hard { color: #c0392b; border-color: #e8908a; }
.lamp-Normal { color: #1f7fc0; border-color: #85c0e6; }
.lamp-Easy { color: #2f9e44; border-color: #88d39a; }
.lamp-AssistEasy, .lamp-LightAssistEasy { color: #8e44ad; border-color: #c39bd3; }
.lamp-Failed, .lamp-NoPlay { color: var(--muted); }

/* Filled pills — used on the dashboard feed (add class "lamp-filled"). */
.lamp-filled { color: #fff; border-color: transparent; font-weight: 600; }
.lamp-filled.lamp-Perfect { background: #19a6c0; }
.lamp-filled.lamp-FullCombo { background: #19a6c0; }
.lamp-filled.lamp-ExHard { background: #e0892f; }
.lamp-filled.lamp-Hard { background: #c0392b; }
.lamp-filled.lamp-Normal { background: #1f8fd0; }
.lamp-filled.lamp-Easy { background: #2f9e44; }
.lamp-filled.lamp-AssistEasy, .lamp-filled.lamp-LightAssistEasy { background: #9b59b6; }
.lamp-filled.lamp-Failed { background: #8b8794; }
.lamp-filled.lamp-NoPlay { background: #b8b4be; }
.lamp-filled.lamp-Max {
  background: linear-gradient(90deg, #e74c3c, #e67e22, #f1c40f, #2ecc71, #3498db, #9b59b6);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

/* IIDX letter grade (AAA..F) in the dashboard feed. */
.grade { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.grade-AAA { color: #1f7fc0; }
.grade-AA { color: #1f7fc0; }
.grade-A { color: #1f7fc0; }
.grade-B, .grade-C { color: var(--fg); }
.grade-D, .grade-E, .grade-F { color: var(--muted); }

/* Dashboard "Recent Play" cards (Figma: Macchiato/Dashboard). */
.section-title { font-size: 1.05rem; margin: 0.5rem 0 0.75rem; }
.play-feed { display: flex; flex-direction: column; gap: 10px; }

.play-card {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 1rem;
  min-height: 92px;
  padding: 0.7rem 1.1rem 0.7rem 1.45rem;
  border: 1px solid #d9d9d9;
  border-radius: 14px;
  background: var(--pc-bg, #f5f5f5);
  transition: box-shadow 0.12s ease;
}
/* Left accent stripe, rounded to match the card's left corners. */
.play-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 8px;
  background: var(--pc-bar, #9b97a3);
  border-radius: 14px 0 0 14px;
}
.play-card:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); }
/* Stretched link: covers the whole card. Interactive bits (the multi-table
   popup) sit above it via a higher z-index so they stay clickable. */
.pc-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.pc-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pc-title {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-diff { color: var(--muted); font-weight: 700; }
.pc-artist {
  color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-meta { display: flex; align-items: center; gap: 0.85rem; font-size: 0.8rem;
           margin-top: auto; padding-top: 0.45rem; }
.pc-lv { font-weight: 700; }

/* Difficulty-table level next to the keys. When a chart is in several tables a
   caret appears and a CSS-only popup (hover on desktop, tap/focus on touch —
   the span is focusable via tabindex) lists every table. */
.pc-tables { position: relative; display: inline-flex; align-items: center; gap: 0.12rem;
             font-weight: 700; color: var(--muted, var(--fg)); }
.pc-tables.has-more { cursor: pointer; z-index: 2; }
.pc-tables-caret { font-size: 1rem; line-height: 1; }
.pc-tables-pop {
  position: absolute;
  left: 0; bottom: calc(100% + 0.35rem);
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.45rem 0.6rem;
  min-width: max-content;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  font-weight: 400;
  z-index: 20;
}
.pc-tables.has-more:hover .pc-tables-pop,
.pc-tables.has-more:focus .pc-tables-pop,
.pc-tables.has-more:focus-within .pc-tables-pop { display: flex; }
.pc-tables-row { white-space: nowrap; font-size: 0.78rem; }
.pc-tables-row b { font-weight: 700; color: var(--fg); }
.pc-side {
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: 0.15rem;
  align-items: flex-end; justify-content: center; text-align: right;
  white-space: nowrap;
}
.pc-grade { font-weight: 700; font-size: 0.95rem; }
.pc-clear { font-weight: 700; font-size: 0.95rem; color: var(--pc-label, var(--fg)); }
.pc-ex { font-size: 0.88rem; }
.pc-ago { color: var(--muted); }

/* Card colour (bar + tint + label) keyed by ClearType.name(). NoPlay/Failed
   have no rule, so they fall back to the gray defaults above. Shared by the
   dashboard play-card and the play-log pl-card. */
.play-card[data-clear="AssistEasy"], .pl-card[data-clear="AssistEasy"],
.play-card[data-clear="LightAssistEasy"], .pl-card[data-clear="LightAssistEasy"] { --pc-bar: #a86fd4; --pc-bg: #f3eafb; --pc-label: #8e44ad; }
.play-card[data-clear="Easy"], .pl-card[data-clear="Easy"]      { --pc-bar: #46b96a; --pc-bg: #e7f8ed; --pc-label: #2f9e44; }
.play-card[data-clear="Normal"], .pl-card[data-clear="Normal"]    { --pc-bar: #2f8fd0; --pc-bg: #e2f1fb; --pc-label: #1f7fc0; }
.play-card[data-clear="Hard"], .pl-card[data-clear="Hard"]      { --pc-bar: #e0483f; --pc-bg: #fdeaea; --pc-label: #c0392b; }
.play-card[data-clear="ExHard"], .pl-card[data-clear="ExHard"]    { --pc-bar: #e8b80e; --pc-bg: #fdf6d4; --pc-label: #9c7a00; }
.play-card[data-clear="FullCombo"], .pl-card[data-clear="FullCombo"],
.play-card[data-clear="Perfect"], .pl-card[data-clear="Perfect"],
.play-card[data-clear="Max"], .pl-card[data-clear="Max"]       { --pc-bar: #14a3a3; --pc-bg: #e2f7f7; --pc-label: #0c8a8a; }

.flash { list-style: none; padding: 0.6rem 1.25rem; margin: 0; background: #fdeaea; color: #b3261e; }

.login-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 280px; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; }
.login-form input { width: 100%; }

/* ------------------------------------------------------------------ */
/* Play log page (Figma: Desktop - 3)                                  */
/* ------------------------------------------------------------------ */
#playlog-body { padding-bottom: 84px; } /* clearance for the floating date picker */
.pl-section { margin-bottom: 1.5rem; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }

/* Highlights panel */
.highlights {
  display: flex; flex-direction: column; gap: 0.35rem;
  background: #f3f2ee;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
}
.highlights-empty { padding: 0.85rem 1.1rem; }
.hl-row { display: flex; align-items: baseline; gap: 0.55rem; font-size: 0.92rem; }
.hl-icon { flex: 0 0 1rem; text-align: center; color: var(--muted); font-weight: 700; }

/* Play-log clear-type label colours. Mirrors the card tint's --pc-label scale;
   FullCombo / Perfect / Max deliberately share one teal. */
.cl { font-weight: 700; }
.cl-AssistEasy, .cl-LightAssistEasy { color: #8e44ad; }
.cl-Easy      { color: #2f9e44; }
.cl-Normal    { color: #1f7fc0; }
.cl-Hard      { color: #c0392b; }
.cl-ExHard    { color: #9c7a00; }
.cl-FullCombo, .cl-Perfect, .cl-Max { color: #0c8a8a; }
.cl-NoPlay, .cl-Failed { color: var(--muted); }

/* History list */
.pl-list { display: flex; flex-direction: column; gap: 12px; }

.pl-card {
  position: relative;
  border: 1px solid #d9d9d9;
  border-radius: 14px;
  background: var(--pc-bg, #f5f5f5);
}
/* Slim left accent stripe, rounded to the card's left corners (matches the
   dashboard play-card). */
.pl-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 8px;
  background: var(--pc-bar, #9b97a3);
  border-radius: 14px 0 0 14px;
}
.pl-summary {
  display: flex; align-items: stretch; gap: 1rem;
  padding: 0.7rem 1.1rem 0.7rem 1.45rem;
  cursor: pointer;
  list-style: none;
}
.pl-summary::-webkit-details-marker { display: none; }
.pl-lv { font-weight: 700; }
.pl-body {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.15rem 0;
}
.pl-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pl-title {
  font-weight: 700; font-size: 1.05rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-diff { color: var(--muted); font-weight: 700; }
.pl-artist {
  color: var(--muted); font-size: 0.82rem; margin-top: 0.1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-meta { display: flex; align-items: center; gap: 0.85rem; font-size: 0.8rem;
           color: var(--muted); margin-top: 0.5rem; }
.pl-meta .pc-tables { font-weight: 700; }

.pl-cols { flex: 0 0 auto; display: flex; gap: 0.25rem; }
/* Fixed column widths so CLEAR TYPE / RANK / SCORE line up across every card. */
.pl-col { display: flex; flex-direction: column; gap: 0.1rem; }
.pl-col-clear { flex: 0 0 110px; }
.pl-col-rank  { flex: 0 0 86px; }
.pl-col-score { flex: 0 0 80px; }
.pl-col-label { font-size: 0.68rem; letter-spacing: 0.04em; color: var(--muted); }
.pl-col-main { font-weight: 700; font-size: 1.0rem; font-variant-numeric: tabular-nums;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-col-sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-clear { color: var(--pc-label, var(--fg)); }

.pl-chevron {
  flex: 0 0 auto; align-self: center;
  color: var(--muted); font-size: 1.1rem; line-height: 1;
  transition: transform 0.15s ease;
}
.pl-card[open] .pl-chevron { transform: rotate(180deg); }

/* Expanded details */
.pl-details {
  padding: 0.9rem 1.1rem 1rem 1.45rem;
  border-top: 1px dashed var(--line);
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  align-items: flex-start;
}
.pl-stats {
  flex: 1 1 360px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem 1rem;
}
.pl-stat { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.pl-stat-label { font-size: 0.65rem; letter-spacing: 0.04em; color: var(--muted); }
.pl-stat-val { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.pl-stat-val .fast { color: #1f7fc0; } /* fast = blue */
.pl-stat-val .slow { color: #c0392b; } /* slow = red */
.pl-judge { flex: 0 0 auto; }
.pl-judge-grid {
  display: grid; grid-template-columns: 1fr; gap: 0.05rem;
  font-size: 0.82rem; font-variant-numeric: tabular-nums; margin-top: 0.25rem;
}
.pl-links { display: flex; flex-direction: column; gap: 0.4rem; flex: 0 0 auto; min-width: 140px; }
.pl-links .link-btn { text-align: center; }

/* Floating date picker — pinned bottom-centre of the viewport. */
.playlog-datepicker {
  position: fixed;
  left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
}
.dp-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  color: var(--fg); text-decoration: none; font-size: 1.05rem;
}
.dp-arrow:hover { background: var(--bg); }
.dp-date {
  border: none; background: transparent;
  font-weight: 700; font-variant-numeric: tabular-nums;
  text-align: center; padding: 0.35rem 0.4rem; margin: 0;
}
.dp-date:focus { outline: none; }
