/* MacBook Keyboard Tester - styles. Default theme: dark (aluminum deck). */

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

:root,
[data-theme='dark'] {
  --bg: #141418;
  --panel: #232329;
  --panel-border: #34343d;
  --text: #ececf1;
  --text-dim: #9a9aa5;
  --deck: #1d1d23;
  --key-bg-top: #45454e;
  --key-bg: #38383f;
  --key-border: #50505a;
  --key-shadow: #26262c;
  --key-text: #ececf1;
  --key-sub: #8f8f9b;
  --accent: #6c4fe0;
  --accent-strong: #8b6dff;
  --accent-glow: rgba(124, 92, 255, 0.55);
  --done: #30d158;
  --conflict: #ff9f0a;
  --conflict-text: #3a2500;
  --danger: #ff453a;
  --table-row-alt: #2a2a31;
}

[data-theme='light'] {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-border: #e2e2e8;
  --text: #1d1d1f;
  --text-dim: #6e6e73;
  --deck: #e8e8ec;
  --key-bg-top: #ffffff;
  --key-bg: #f2f2f5;
  --key-border: #c8c8d0;
  --key-shadow: #b9b9c2;
  --key-text: #1d1d1f;
  --key-sub: #8a8a92;
  --accent: #7c5cff;
  --accent-strong: #947aff;
  --accent-glow: rgba(124, 92, 255, 0.45);
  --done: #28a745;
  --conflict: #f5a623;
  --conflict-text: #3a2500;
  --danger: #d93830;
  --table-row-alt: #f7f7fa;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

.hidden {
  display: none !important;
}

/* ---------- header ---------- */

.site-header {
  padding: 20px 20px 12px;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}

.site-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover {
  border-color: var(--accent-strong);
}

.btn:active {
  transform: translateY(1px);
}

/* Language switch links styled as buttons */
a.btn {
  display: inline-block;
  text-decoration: none;
  line-height: normal;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.notice {
  list-style: none;
  max-width: 1200px;
  margin: 14px auto 0;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.notice li {
  padding: 2px 0;
}

.notice li + li {
  margin-top: 2px;
}

.notice strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- layout ---------- */

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

/* ---------- stats ---------- */

.stats-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat {
  flex: 1 1 120px;
  min-width: 110px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-num {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.progress-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 6px;
  transition: width 0.15s ease-out;
}

.progress-text {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

.banner {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--done);
  color: #06290f;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.02em;
}

.untested-wrap {
  margin-top: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.untested-label {
  font-size: 13px;
  color: var(--text-dim);
  padding-top: 3px;
  flex-shrink: 0;
}

.untested-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  white-space: nowrap;
}

.chip-none {
  border-style: dashed;
  color: var(--text-dim);
}

/* ---------- keyboard ---------- */

.keyboard-panel {
  padding: 8px;
}

.keyboard-scroll {
  overflow-x: auto;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 940px;
  max-width: 1140px;
  margin: 0 auto;
  padding: 18px;
  border-radius: 16px;
  background: var(--deck);
  border: 1px solid var(--panel-border);
}

.kb-row {
  display: flex;
  gap: 6px;
}

.key {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--key-border);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--key-bg-top), var(--key-bg));
  box-shadow: 0 2px 0 var(--key-shadow);
  color: var(--key-text);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.08s, border-color 0.15s, box-shadow 0.08s,
    transform 0.05s;
}

.key:active {
  transform: translateY(1px);
}

.key-sym {
  font-size: 11px;
  line-height: 1;
  margin-bottom: 2px;
  color: var(--text-dim);
}

.key-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 4px;
}

.key-sub {
  font-size: 10px;
  line-height: 1;
  margin-bottom: 1px;
  color: var(--key-sub);
}

.key-count {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--done);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* fn key: cannot be detected from a web page */
.key-untestable {
  border-style: dashed;
  opacity: 0.7;
}

/* pressed state: blue-purple backlight */
.key.pressed {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-color: var(--accent-strong);
  box-shadow: 0 0 16px var(--accent-glow), 0 2px 0 var(--key-shadow);
  color: #fff;
  transform: translateY(1px);
}

.key.pressed .key-sym,
.key.pressed .key-sub {
  color: rgba(255, 255, 255, 0.85);
}

/* tested state: green outline */
.key.done {
  border-color: var(--done);
  box-shadow: 0 0 0 1px var(--done), 0 2px 0 var(--key-shadow);
}

.key.done.pressed {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  box-shadow: 0 0 16px var(--accent-glow), 0 0 0 1px var(--done);
}

/* suspect conflict state */
.key.conflict {
  background: linear-gradient(180deg, #ffb948, var(--conflict));
  border-color: var(--conflict);
  color: var(--conflict-text);
  box-shadow: 0 0 14px rgba(255, 159, 10, 0.45);
  animation: conflict-pulse 1s ease-in-out infinite;
}

.key.conflict .key-sym,
.key.conflict .key-sub,
.key.conflict .key-count {
  color: var(--conflict-text);
}

@keyframes conflict-pulse {
  0%,
  100% {
    box-shadow: 0 0 6px rgba(255, 159, 10, 0.35);
  }
  50% {
    box-shadow: 0 0 18px rgba(255, 159, 10, 0.7);
  }
}

/* arrow cluster: full-height left/right, half-height up/down stacked */
.arrow-cluster {
  flex: 3 1 0;
  min-width: 0;
  display: flex;
  gap: 6px;
}

.arrow-cluster > .key {
  flex: 1 1 0;
}

.arrow-mid {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.arrow-mid .key {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
}

.arrow-mid .key,
.arrow-cluster > .key {
  font-size: 16px;
  font-weight: 700;
}

/* ---------- records ---------- */

.table-wrap {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.records-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 6px 10px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

.records-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

.records-table tbody tr:nth-child(even) {
  background: var(--table-row-alt);
}

.records-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.records-table .col-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--done);
}

.empty-row td {
  text-align: center;
  color: var(--text-dim);
  padding: 18px 0;
}

/* ---------- footer ---------- */

.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 28px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .header-row {
    flex-direction: column;
  }

  .stat {
    flex: 1 1 calc(50% - 12px);
  }

  .panel {
    padding: 12px;
  }
}
