:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #fbfcfe;
  --ink: #000000;
  --muted: #111827;
  --line: #c9d3df;
  --red: #dc2430;
  --gold: #7a4300;
  --teal: #007f73;
  --yellow: #f2b43c;
  --yellow-soft: #fff1bd;
  --button-dark: #020617;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis-weight: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  text-rendering: auto;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
}

body {
  margin: 0;
  overflow-x: auto;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
  font-synthesis-weight: none;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  min-width: 1840px;
  min-height: 100vh;
  margin: 0;
  padding: 22px;
  background: var(--bg);
}

.workbench {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 430px 260px;
  align-items: start;
  gap: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ranking-workspace-panel,
.result-panel,
.source-panel {
  min-width: 0;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.ranking-picker-box {
  width: 100%;
  height: 760px;
  max-height: 760px;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.ranking-picker-toolbar {
  display: grid;
  grid-template-columns: 280px 170px auto 220px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.season-type-row {
  display: grid;
  grid-template-columns: 132px 138px;
  gap: 10px;
  align-items: center;
}

.ranking-picker-season,
.ranking-picker-search,
.ranking-top10-count,
.bgm-select {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid #b9c7d6;
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: #000000;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  outline: none;
  box-shadow: none;
}

.ranking-filter-divider {
  width: 1px;
  height: 32px;
  background: #c8d3df;
}

.ranking-player-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ranking-player-tab,
.option-button,
.primary-button {
  min-height: 44px;
  border: 1px solid #b7c1cd;
  border-radius: 8px;
  background: #ffffff;
  color: #000000;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: none;
  filter: none;
}

.ranking-player-tab {
  min-width: 96px;
  padding: 0 12px;
}

.ranking-player-tab.is-active {
  border-color: #0f9f97;
  background: #e2fbf8;
  box-shadow: inset 0 0 0 1px rgba(15, 159, 151, 0.2);
}

.ranking-picker-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ranking-picker-count {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #000000;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.ranking-picker-count input,
.ranking-picker-actions .primary-button {
  width: 120px;
  min-width: 120px;
  height: 44px;
}

.ranking-picker-options {
  min-height: 0;
  height: auto;
  margin-top: 18px;
  padding-right: 8px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
}

.option-group-title {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  color: #000000;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.option-button {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
  font-synthesis-weight: none;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  text-rendering: auto;
}

.option-button strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
  text-shadow: none;
}

.option-button:hover,
.option-button.is-active {
  border-color: #e3ad29;
  background: var(--yellow-soft);
  box-shadow: inset 0 0 0 1px rgba(227, 173, 41, 0.28);
}

.primary-button {
  border-color: var(--button-dark);
  background: var(--button-dark);
  color: #ffffff !important;
  font-weight: 700;
}

.primary-button.accent {
  border-color: var(--red);
  background: var(--red);
}

.primary-button.danger {
  border-color: rgba(220, 36, 48, 0.45);
  background: #ffffff;
  color: var(--red) !important;
}

.preview-area {
  width: 430px;
  min-width: 430px;
  max-width: 430px;
  display: grid;
  align-content: start;
}

.canvas-frame {
  width: 430px;
  max-width: 430px;
  display: grid;
  place-items: center;
  background: transparent;
}

.canvas-stack {
  position: relative;
  width: 430px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f7f9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: #f6f7f9;
  image-rendering: auto;
  transform: none;
  filter: none;
  opacity: 1;
  contain: paint;
}

.canvas-play-zone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.canvas-play-button {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.canvas-stack:hover .canvas-play-button,
.canvas-play-button:focus-visible {
  opacity: 1;
}

.canvas-play-button::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: 17px 0 0 23px;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid #020617;
}

.canvas-play-button.is-playing::before {
  width: 18px;
  height: 24px;
  margin: 17px auto 0;
  border: 0;
  background: linear-gradient(90deg, #020617 0 35%, transparent 35% 65%, #020617 65% 100%);
}

.canvas-seek-zone {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
}

.canvas-seek {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
}

.canvas-seek input {
  width: 100%;
}

.canvas-seek span {
  min-width: 84px;
  color: #000000;
  font-size: 0.76rem;
  font-weight: 700;
}

.side-controls {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-field {
  width: 100%;
  min-height: auto;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.side-controls .control-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #000000;
  font-size: 0.88rem;
  font-weight: 700;
}

.duration-readout {
  display: grid;
  gap: 2px;
  text-align: right;
}

.duration-readout strong,
.control-field strong {
  color: var(--red);
  font-size: 0.94rem;
}

.duration-readout em,
.control-field em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.76rem;
  font-weight: 700;
}

.side-controls input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}

.side-controls input[type="range"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.voice-toggle-control .control-title {
  min-height: 30px;
}

.voice-toggle-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.record-panel {
  display: grid;
  gap: 10px;
}

.record-panel .primary-button {
  min-height: 58px;
}

.side-controls .sr-status {
  min-height: 46px;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.35;
  font-weight: 700;
}

.top-controls {
  display: flex;
  gap: 10px;
  justify-content: start;
  align-items: stretch;
  width: max-content;
}

.action-controls .primary-button {
  min-width: 128px;
  padding: 0 16px;
}

.data-overview-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
}

.result-panel,
.source-panel {
  padding: 16px;
  min-height: 250px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-title {
  margin: 0;
  color: #000000;
  font-size: 1rem;
  line-height: 1.1;
  font-weight: 700;
}

.result-meta {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empty-result {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.result-item {
  min-height: 76px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 11px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
}

.result-rank {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef2f5;
  color: var(--red);
  font-weight: 700;
}

.result-name {
  display: grid;
  gap: 3px;
}

.result-name strong {
  font-size: 0.94rem;
  line-height: 1.2;
}

.result-name span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.24;
}

.result-value {
  color: var(--teal);
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.result-stat-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.result-stat-card {
  min-width: 0;
  border-radius: 8px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  padding: 8px;
  display: grid;
  gap: 2px;
}

.result-stat-card span,
.result-stat-card em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.2;
}

.result-stat-card strong {
  color: #000000;
  font-size: 0.82rem;
  line-height: 1.2;
}

.source-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.source-list div {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.source-list dt {
  color: var(--muted);
  font-weight: 700;
}

.source-list dd {
  margin: 0;
  word-break: break-all;
  font-weight: 700;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid #111111;
  outline-offset: -2px;
}

@media (max-width: 980px) {
  .app-shell {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  .stage-row,
  .data-overview-grid {
    grid-template-columns: 1fr;
  }

  .preview-area,
  .canvas-frame,
  .canvas-stack,
  .side-controls {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .ranking-picker-toolbar {
    grid-template-columns: 1fr;
  }

  .ranking-picker-options,
  .result-list {
    grid-template-columns: 1fr;
  }
}

/* KBO sharp text/canvas sync */
html,
body,
button,
input,
textarea,
select {
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis-weight: none;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  text-rendering: auto;
}

body,
.app-shell,
.workbench,
.ranking-picker-box,
.side-controls,
.result-panel,
.source-panel {
  transform: none;
  filter: none;
  text-shadow: none;
}

.app-shell :where(button, input, textarea, select, label, span, p, em),
.ranking-picker-box :where(button, input, textarea, select, label, span, p, em),
.side-controls :where(button, input, textarea, select, label, span, p, em),
.result-panel :where(button, input, textarea, select, label, span, p, em),
.source-panel :where(button, input, textarea, select, label, span, p, em) {
  letter-spacing: 0;
  text-shadow: none;
  filter: none;
}

.app-shell :where(strong, h1, h2, h3, .table-title, .control-title, .option-group-title),
.ranking-picker-box :where(strong, h1, h2, h3, .option-group-title),
.side-controls :where(strong, h1, h2, h3, .control-title),
.primary-button,
.ranking-player-tab,
.ranking-picker-season,
.ranking-picker-search,
.ranking-top10-count,
.bgm-select {
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: none;
}

.option-button,
.option-button strong {
  color: #000000;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  text-shadow: none;
  filter: none;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  font-synthesis-weight: none;
  text-rendering: auto;
}

.canvas-stack,
.canvas-stack canvas,
canvas {
  image-rendering: auto;
  transform: none;
  filter: none;
  opacity: 1;
}

/* 20260528 layoutfix1: center the preview play/pause control exactly. */
.canvas-play-zone {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: none;
}

.canvas-play-button {
  position: relative;
  width: 58px;
  height: 58px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  color: transparent;
  font-size: 0;
  pointer-events: auto;
}

.canvas-play-button::before,
.canvas-play-button::after {
  content: "";
  position: absolute;
  top: 50%;
  display: block;
  margin: 0;
}

.canvas-play-button.is-playing::before,
.canvas-play-button.is-playing::after {
  width: 8px;
  height: 26px;
  border: 0;
  border-radius: 3px;
  background: #020617;
  transform: translateY(-50%);
}

.canvas-play-button.is-playing::before {
  left: 20px;
}

.canvas-play-button.is-playing::after {
  right: 20px;
}

.canvas-play-button.is-paused::before {
  left: 23px;
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 21px solid #020617;
  transform: translateY(-50%);
}

.canvas-play-button.is-paused::after {
  display: none;
}
