:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1d2428;
  --muted: #607078;
  --line: #d7ded8;
  --accent: #0d766e;
  --accent-strong: #075e58;
  --accent-soft: #e1f3ef;
  --warn: #8a4b09;
  --good: #11723a;
  --bad: #a33434;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.user-status {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.inline-login {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-login input {
  width: 132px;
  min-height: 42px;
  padding: 0 10px;
}

.inline-login button,
.secondary-button {
  min-height: 42px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent-strong);
}

.secondary-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.danger-button {
  border-color: #d7b5b5;
  background: #fff7f7;
  color: var(--bad);
}

.danger-button:hover,
.danger-button:focus-visible {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px #f3dfdf;
  outline: none;
}

.hidden {
  display: none !important;
}

.login-guide {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.help-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  font-weight: 750;
  text-decoration: none;
}

.help-link:hover,
.help-link:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.status-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-band div {
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-band span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-band strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.35;
}

.admin-status-band {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-panel {
  margin-top: 14px;
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.admin-table td {
  line-height: 1.45;
}

.admin-table td:nth-child(5) {
  display: flex;
  gap: 8px;
}

.admin-pin-input {
  width: 120px;
  min-height: 38px;
  padding: 0 10px;
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
}

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

.panel {
  min-height: 244px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 124px;
  resize: vertical;
  padding: 14px;
  line-height: 1.5;
}

input {
  min-height: 54px;
  padding: 0 14px;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
}

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

button:disabled {
  background: #b9c4c1;
  cursor: not-allowed;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel h1 {
  margin-bottom: 8px;
  font-size: 32px;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.login-error {
  margin-top: 14px;
  color: var(--bad);
  font-weight: 800;
}

#resetButton {
  flex: 0 0 auto;
  background: #263238;
}

output {
  display: block;
  min-height: 118px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-size: 18px;
}

.focus {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.result-panel output {
  font-size: 16px;
}

.good {
  color: var(--good);
  font-weight: 800;
}

.bad {
  color: var(--bad);
  font-weight: 800;
}

.warn {
  color: var(--warn);
}

.history-panel {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.history-heading p {
  text-align: right;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.history-item:hover {
  border-color: var(--accent);
  box-shadow: 0 3px 12px rgba(13, 118, 110, 0.12);
  transform: translateY(-1px);
}

.history-item:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.history-item strong {
  color: var(--muted);
}

.history-item.correct strong {
  color: var(--good);
}

.history-item.incorrect strong {
  color: var(--bad);
}

.history-item span {
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.empty-history {
  padding: 10px 0;
}

.help-shell {
  min-height: 100vh;
  padding: 28px;
}

.help-page {
  width: min(880px, 100%);
  margin: 0 auto;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.help-content {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.help-content h1,
.help-content h2,
.help-content h3 {
  margin: 26px 0 10px;
  letter-spacing: 0;
}

.help-content h1:first-child,
.help-content h2:first-child,
.help-content h3:first-child {
  margin-top: 0;
}

.help-content p,
.help-content li {
  color: var(--ink);
  line-height: 1.65;
}

.help-content ul,
.help-content ol {
  padding-left: 22px;
}

.help-content pre {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f4f2;
  line-height: 1.5;
}

.help-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

@media (max-width: 760px) {
  .shell {
    padding: 18px;
  }

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

  .top-actions,
  .help-header {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-login {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }

  .inline-login input {
    width: 100%;
  }

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

  .status-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-heading p {
    text-align: left;
  }

  .panel {
    min-height: 210px;
  }
}
