:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-strong: #f8f9fb;
  --text: #222222;
  --muted: #646b76;
  --line: #d9dde4;
  --line-strong: #b8bec8;
  --accent: #e71420;
  --accent-dark: #bc1019;
  --danger: #b3261e;
  --success: #147a3b;
  --warning: #8a5a00;
  --focus: #1f6feb;
  --shadow: 0 16px 42px rgba(26, 29, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

.workspace {
  width: min(860px, calc(100% - 32px));
  margin: 44px auto 24px;
}

.tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-heading {
  display: grid;
  gap: 8px;
  padding: 30px 34px 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.scope,
.message,
.result-label {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.scope {
  font-size: 15px;
  font-weight: 700;
}

.tool-grid {
  display: grid;
  padding: 34px;
}

.checker {
  display: grid;
  align-content: start;
  gap: 26px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 48px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.segment {
  min-width: 0;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.segment:hover:not(:disabled) {
  color: var(--text);
}

.segment.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(26, 29, 36, 0.1);
}

.segment:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.field {
  display: grid;
  gap: 10px;
}

label {
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: stretch;
  min-height: 58px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.input-row:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.13);
}

#pinInput {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0 18px;
  outline: none;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

#pinInput::placeholder {
  color: #9aa1ad;
}

.icon-button {
  width: 44px;
  min-height: 56px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  color: var(--text);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

#formattedPreview {
  max-width: 70%;
  overflow-wrap: anywhere;
  text-align: right;
}

.message {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: pre-line;
}

.message.is-error {
  color: var(--danger);
}

.message.is-warning {
  color: var(--warning);
}

.primary-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.result {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 22px;
  padding: 0 34px 34px;
}

.result[hidden] {
  display: none;
}

.result-label {
  font-size: 14px;
  font-weight: 900;
}

.result h2 {
  margin: 8px 0 0;
  font-size: 24px;
  line-height: 1.25;
}

.result-list {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.result-list div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 46px;
  border-top: 1px solid var(--line);
}

.result-list div:first-child {
  border-top: 0;
}

dt,
dd {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 10px 14px;
  font-size: 14px;
}

dt {
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 800;
}

dd {
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result.is-valid h2 {
  color: var(--success);
}

.result.is-invalid h2,
.result.is-error h2 {
  color: var(--danger);
}

.result.is-pending h2,
.result.is-limited h2 {
  color: var(--warning);
}

:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.35);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .workspace {
    width: min(100% - 20px, 860px);
    margin-top: 18px;
  }

  .tool-heading,
  .tool-grid,
  .result {
    padding-left: 18px;
    padding-right: 18px;
  }

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

  .segment {
    font-size: 14px;
  }

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

  h1 {
    font-size: 24px;
  }

  #pinInput {
    font-size: 18px;
  }

  .input-meta {
    display: grid;
  }

  #formattedPreview {
    max-width: 100%;
    text-align: left;
  }

  .result-list div {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  dt,
  dd {
    padding: 10px;
  }
}
