@font-face {
  font-family: 'MC';
  src: url('assets/mc.woff2') format('woff2');
  font-display: swap;
  font-weight: 400;
}

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --on-surface: #1f1f1f;
  --on-surface-var: #5f6368;
  --outline: #dadce0;
  --primary: #1a73e8;
  --primary-hover: #1765cc;
  --on-primary: #ffffff;
  --primary-soft: rgba(26, 115, 232, .08);
  --shadow-1: 0 1px 2px rgba(60, 64, 67, .18), 0 1px 3px 1px rgba(60, 64, 67, .08);
  --shadow-2: 0 2px 6px 2px rgba(60, 64, 67, .10), 0 1px 2px rgba(60, 64, 67, .18);
  --shadow-3: 0 8px 24px -8px rgba(60, 64, 67, .28);
  --radius: 24px;
  --font: "Google Sans", "Product Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1c1f;
    --surface-2: #23262a;
    --on-surface: #e8eaed;
    --on-surface-var: #9aa0a6;
    --outline: #35383d;
    --primary: #8ab4f8;
    --primary-hover: #aecbfa;
    --on-primary: #062e6f;
    --primary-soft: rgba(138, 180, 248, .10);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .55);
    --shadow-3: 0 12px 32px -12px rgba(0, 0, 0, .75);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}

input, textarea, code { -webkit-user-select: text; user-select: text; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

svg { width: 20px; height: 20px; flex: none; }

.page {
  width: 100%;
  min-width: 0;
  max-width: clamp(680px, 56vw, 1100px);
  margin: 0 auto;
  padding: clamp(28px, 6vh, 56px) 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero { text-align: center; margin-bottom: 40px; min-width: 0; }

.hero h1 {
  font-size: clamp(26px, 2.6vw, 46px);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -.6px;
}

.hero p {
  margin-top: clamp(10px, 0.9vw, 16px);
  font-size: clamp(13px, 1.02vw, 17px);
  color: var(--on-surface-var);
}

.search {
  display: flex;
  min-width: 0;
  gap: clamp(10px, 0.8vw, 14px);
  align-items: stretch;
  background: var(--surface);
  padding: clamp(10px, 0.85vw, 16px);
  border-radius: clamp(20px, 1.6vw, 28px);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--outline);
}

.field { position: relative; flex: 1; min-width: 0; }

.field input {
  width: 100%;
  height: clamp(52px, 3.5vw, 64px);
  padding: 0 clamp(16px, 1.3vw, 22px);
  font-size: clamp(15px, 1.02vw, 17px);
  font-family: var(--font);
  color: var(--on-surface);
  background: transparent;
  border: 1px solid transparent;
  border-radius: clamp(14px, 1.1vw, 18px);
  outline: none;
  transition: border-color .16s, background .16s;
}

.field input:hover { background: var(--surface-2); }

.field input:focus {
  border-color: var(--primary);
  background: transparent;
}

.field label {
  position: absolute;
  left: clamp(16px, 1.3vw, 22px);
  top: 50%;
  transform: translateY(-50%);
  color: var(--on-surface-var);
  font-size: clamp(15px, 1.02vw, 17px);
  pointer-events: none;
  transition: opacity .14s ease, transform .16s cubic-bezier(.2, 0, 0, 1), color .16s;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  opacity: 0;
  transform: translateY(-50%) scale(.94);
}

.btn-filled {
  height: clamp(52px, 3.5vw, 64px);
  padding: 0 clamp(22px, 1.9vw, 34px);
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: clamp(14px, 1vw, 16px);
  font-weight: 600;
  box-shadow: var(--shadow-1);
  transition: background .16s, box-shadow .16s, transform .1s;
}

.btn-filled:hover { background: var(--primary-hover); box-shadow: var(--shadow-2); }
.btn-filled:active { transform: scale(.98); }
.btn-filled:disabled { opacity: .55; cursor: default; transform: none; }
.btn-filled svg { width: 18px; height: 18px; }

.result {
  margin-top: clamp(20px, 1.7vw, 32px);
  min-width: 0;
  animation: rise .32s cubic-bezier(.2, 0, 0, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.canvas-wrap {
  min-width: 0;
  width: 100%;
  margin: 0 auto;
  border-radius: 20px;
  overflow: hidden;
  background: #1e1e1e;
  box-shadow: var(--shadow-3);
  border: 1px solid var(--outline);
  line-height: 0;
}

.canvas-wrap canvas { display: block; width: 100%; height: auto; cursor: zoom-in; }

.result-meta {
  margin-top: 12px;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: clamp(26px, 1.75vw, 32px);
  max-width: 100%;
  padding: 0 clamp(10px, 0.8vw, 14px);
  border-radius: 999px;
  font-size: clamp(11.5px, 0.8vw, 13.5px);
  color: var(--on-surface-var);
  background: var(--surface);
  border: 1px solid var(--outline);
  overflow: hidden;
}

.pill b {
  color: var(--on-surface);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 12px;
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: clamp(38px, 2.6vw, 46px);
  padding: 0 clamp(14px, 1.1vw, 18px);
  border-radius: 999px;
  font-size: clamp(13px, 0.95vw, 15px);
  font-weight: 500;
  color: var(--primary);
  transition: background .16s;
}

.btn-text:hover { background: var(--primary-soft); }
.btn-text svg { width: 18px; height: 18px; }

.state { margin-top: 28px; }

.state-card {
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.state-title { font-size: 15px; font-weight: 600; }

.state-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--on-surface-var);
  word-break: break-word;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  overflow: auto;
  padding: 24px;
  background: rgba(8, 10, 14, .92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.viewer.show { display: block; }

.viewer img {
  display: block;
  max-width: none;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 24px 80px -24px #000;
  background: #1e1e1e;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  padding: 12px 20px;
  border-radius: 12px;
  background: #303134;
  color: #f1f3f4;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: min(88vw, 520px);
  text-align: center;
  z-index: 90;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 641px) and (max-width: 1024px) {
  .page { max-width: clamp(620px, 78vw, 780px); }
}

@media (max-width: 640px) {
  .page { padding: 32px 16px; }
  .hero { margin-bottom: 26px; }
  .hero h1 { font-size: clamp(22px, 6.2vw, 28px); letter-spacing: -.3px; }
  .hero p { margin-top: 10px; font-size: 13px; }
  .search { flex-direction: column; gap: 10px; padding: 10px; border-radius: 20px; }
  .field input { height: 50px; font-size: 16px; border-radius: 14px; }
  .field label { left: 16px; font-size: 15px; }
  .btn-filled { width: 100%; height: 50px; justify-content: center; font-size: 15px; }
  .result { margin-top: 22px; }
  .canvas-wrap { border-radius: 16px; }
  .result-meta { gap: 6px; }
  .pill { height: 26px; padding: 0 10px; font-size: 11.5px; }
  .result-actions { flex-wrap: wrap; gap: 0; margin-top: 8px; }
  .btn-text { height: 38px; padding: 0 14px; font-size: 13.5px; }
  .state-card { padding: 32px 18px; border-radius: 20px; }
  .viewer { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
