:root {
  --bg: #f5f6fb;
  --card: rgba(255, 255, 255, 0.94);
  --text: #162335;
  --muted: #66758f;
  --line: rgba(22, 35, 53, 0.12);
  --brand: #1f6feb;
  --brand-deep: #144b9f;
  --accent: #e87d39;
  --danger: #ba4e4e;
  --shadow: 0 24px 60px rgba(22, 35, 53, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 0 0, rgba(31, 111, 235, 0.15), transparent 30%),
    radial-gradient(circle at 100% 0, rgba(232, 125, 57, 0.14), transparent 26%),
    linear-gradient(180deg, #fcfdff 0%, var(--bg) 100%);
}

.page {
  width: calc(100vw - 64px);
  max-width: none;
  min-width: 320px;
  margin: 0 auto;
  position: relative;
  height: 100vh;
  padding: 8px 0 30px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  padding: 8px 10px;
}

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(20px, 2.5vw, 27px);
  letter-spacing: -0.03em;
}

.hero-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  cursor: pointer;
  font-size: 13px;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease, background 140ms ease;
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.16);
}

button.secondary,
.mode-btn {
  color: var(--text);
  background: linear-gradient(135deg, #eef3fc 0%, #f8f4ee 100%);
  border: 1px solid var(--line);
  box-shadow: none;
}

.mode-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.18);
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.04);
}

button:active,
button.press-feedback {
  transform: translateY(1px) scale(0.985);
  filter: saturate(1.1) brightness(0.98);
}

button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(31, 111, 235, 0.12),
    0 10px 22px rgba(31, 111, 235, 0.18);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.pane {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

h2 {
  font-size: 18px;
}

.meta,
.label {
  color: var(--muted);
  font-size: 13px;
}

.current-block,
.result-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 249, 255, 0.96));
}

.current-block {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.current-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.current-row strong,
.result-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: rgba(31, 111, 235, 0.48);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.08);
}

input.error {
  border-color: rgba(186, 78, 78, 0.6);
  box-shadow: 0 0 0 4px rgba(186, 78, 78, 0.1);
}

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

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

.result-card {
  padding: 12px;
  display: grid;
  gap: 6px;
}

.status {
  margin: 0;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.status.ok {
  color: var(--brand);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  min-width: min(360px, calc(100vw - 32px));
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(20, 31, 48, 0.92);
  color: #fff;
  text-align: center;
  box-shadow: 0 18px 40px rgba(18, 31, 47, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.success {
  background: rgba(31, 111, 235, 0.94);
}

.toast.error {
  background: rgba(186, 78, 78, 0.94);
}

@media (max-width: 960px) {
  .page {
    width: calc(100% - 18px);
    height: 100vh;
    padding: 10px 0 14px;
    overflow: auto;
  }

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

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