:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: #121418;
  --panel-strong: #1c2028;
  --line: #30343d;
  --text: #f5f7fb;
  --muted: #b9bdc8;
  --soft: #8f96a6;
  --accent: #4d86ff;
  --accent-strong: #74a4ff;
  --ok: #52d273;
  --warn: #ffcf5a;
  --bad: #ff6b7a;
  --mark: rgba(77, 134, 255, 0.36);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(77, 134, 255, 0.16), transparent 28rem),
    linear-gradient(180deg, #111318 0%, var(--bg) 38rem);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #181b21;
  color: var(--text);
  cursor: pointer;
}

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

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1.5rem;
  width: min(92rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.workspace,
.side-panel {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(5, 2.5rem);
  gap: 0.5rem;
}

.level-tab {
  height: 2.5rem;
  border-radius: 999px;
  font-weight: 700;
}

.level-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
}

.prompt-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 20, 24, 0.82);
}

.prompt-label,
.hint {
  margin: 0;
  color: var(--muted);
}

.prompt-label {
  margin-bottom: 0.25rem;
  font-size: 0.86rem;
}

.prompt-panel h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.35;
}

.hint {
  max-width: 27rem;
  line-height: 1.7;
}

.file-list {
  display: grid;
  gap: 0.28rem;
}

.file-row {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  align-items: center;
  min-height: 1.65rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #141517;
  color: var(--text);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.file-row.is-match {
  border-color: rgba(77, 134, 255, 0.76);
  background: var(--panel-strong);
}

.file-row.is-expected-miss {
  border-color: rgba(255, 207, 90, 0.65);
}

.file-row.is-wrong-hit {
  border-color: rgba(255, 107, 122, 0.7);
}

.file-icon {
  width: 1rem;
  text-align: center;
  font-size: 0.9rem;
  filter: grayscale(0.15);
}

.file-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(0.82rem, 1.2vw, 1rem);
  line-height: 1.2;
}

mark {
  border-radius: 4px;
  background: var(--mark);
  color: var(--text);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 1rem 1rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.stat-label {
  display: block;
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.stats strong {
  font-size: 1.4rem;
}

#judgeText.is-ok {
  color: var(--ok);
}

#judgeText.is-warn {
  color: var(--warn);
}

#judgeText.is-bad {
  color: var(--bad);
}

.pattern-bar {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) 5rem;
  align-items: center;
  gap: 1rem;
}

.pattern-bar label {
  font-size: 1.2rem;
}

.regex-input {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 2px solid #e9edf6;
  border-radius: 1.35rem;
  background: #151617;
  color: #e9edf6;
  font-size: 1.35rem;
}

.regex-input:focus-within {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(77, 134, 255, 0.18);
}

.regex-input span {
  padding: 0 0.8rem;
  color: var(--soft);
}

.regex-input input {
  width: 100%;
  min-width: 0;
  height: 3.25rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
}

.regex-input .flags {
  width: 4.5rem;
  flex: 0 0 auto;
  color: var(--accent-strong);
}

#resetButton,
.actions button {
  min-height: 2.8rem;
  border-radius: 8px;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.side-panel section {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 20, 24, 0.9);
}

.side-panel h2 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.cheatsheet {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.cheatsheet div {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
}

.cheatsheet dt {
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  background: #0e1014;
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.cheatsheet dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.answer {
  margin: 1rem 0 0;
  padding: 0.8rem;
  border-radius: 8px;
  background: #0e1014;
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

@media (max-width: 54rem) {
  .app {
    grid-template-columns: 1fr;
    padding-top: 1rem;
  }

  .topbar,
  .prompt-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .level-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }

  .pattern-bar {
    grid-template-columns: 1fr;
  }
}
