:root {
  --bg: #edf4ff;
  --bg-strong: #dfeafc;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(109, 141, 229, 0.18);
  --line-strong: rgba(109, 141, 229, 0.42);
  --text: #20355f;
  --muted: rgba(32, 53, 95, 0.66);
  --accent: #5f7fe4;
  --accent-soft: #87a4ff;
  --accent-deep: #385dc7;
  --shadow: 0 20px 50px rgba(101, 133, 214, 0.16);
}

@font-face {
  font-family: "The Seasons Bold";
  src:
    url("../fonts/the-seasons-bold.woff2") format("woff2"),
    url("../fonts/the-seasons-bold.woff") format("woff");
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  min-height: 100%;
  overflow: auto;
  font-family: "Avenir Next", "Helvetica Neue", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(135, 164, 255, 0.28), transparent 28%),
    radial-gradient(circle at bottom right, rgba(187, 217, 255, 0.42), transparent 34%),
    linear-gradient(180deg, #f7fbff 0%, #edf4ff 52%, #e6f0ff 100%);
}

.page-shell {
  width: min(1660px, calc(100% - 32px));
  min-height: calc(100vh - 20px);
  margin: 10px auto;
  display: grid;
  grid-template-columns: 290px minmax(540px, 760px) 320px;
  justify-content: center;
  align-items: stretch;
  gap: 12px;
}

.shell-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.selector-panel,
.preview-panel,
.output-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.panel-topline,
.preview-header,
.settings-heading,
.preview-actions,
.status-line,
.cache-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-tag {
  color: var(--accent-deep);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.panel-mini {
  color: var(--muted);
  font-size: 11px;
}

.panel-copy h1 {
  font-family: "The Seasons Bold", "Times New Roman", serif;
  font-size: clamp(28px, 2vw, 36px);
  font-weight: 400;
  line-height: 1;
}

.panel-copy p,
.settings-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(109, 141, 229, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.settings-heading strong {
  font-size: 15px;
}

.settings-heading span,
.preview-copy strong,
.status-line span:last-child,
.cache-meta span {
  color: var(--muted);
  font-size: 12px;
}

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

.vip-grid-4 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vip-btn,
.header-btn,
.micro-btn,
.dir-btn,
input[type="file"]::file-selector-button {
  min-height: 36px;
  border: 1px solid rgba(95, 127, 228, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(235, 243, 255, 0.94));
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.vip-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
}

.header-btn,
.micro-btn,
.dir-btn,
input[type="file"]::file-selector-button {
  padding: 7px 12px;
  font-size: 12px;
}

.vip-btn:hover,
.header-btn:hover,
.micro-btn:hover,
.dir-btn:hover,
input[type="file"]::file-selector-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, #ffffff 0%, #e5efff 100%);
  box-shadow: 0 10px 20px rgba(116, 149, 235, 0.16);
}

.vip-btn.active {
  transform: translateY(-1px);
  border-color: var(--lang-accent-deep);
  background: linear-gradient(180deg, var(--lang-accent) 0%, var(--lang-accent-deep) 100%);
  color: #ffffff;
  box-shadow:
    0 10px 22px color-mix(in srgb, var(--lang-accent) 30%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.vip-btn.active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}

.vip-btn:focus-visible,
.language-trigger:focus-visible,
.header-btn:focus-visible,
.micro-btn:focus-visible,
.dir-btn:focus-visible,
.copy-image-btn:focus-visible {
  outline: 2px solid var(--lang-accent, var(--accent));
  outline-offset: 2px;
}

.header-btn.primary {
  background: linear-gradient(180deg, #84a3ff 0%, #5f7fe4 100%);
  color: #ffffff;
  border-color: rgba(84, 112, 204, 0.22);
}

input[type="file"],
input[type="text"] {
  width: 100%;
  border: 1px solid rgba(109, 141, 229, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 14px;
}

input[type="text"]::placeholder {
  color: rgba(32, 53, 95, 0.38);
}

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

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

.value-display {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.uid-values {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.value-display strong,
.cache-meta strong {
  color: var(--text);
}

.cache-group {
  margin-top: auto;
}

.language-group {
  gap: 10px;
}

.language-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.language-section {
  --lang-accent: var(--accent);
  --lang-accent-deep: var(--accent-deep);
  --lang-accent-soft: #e6efff;
  border: 1px solid rgba(109, 141, 229, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.language-section.is-open {
  border-color: var(--lang-accent);
  background: linear-gradient(180deg, #ffffff 0%, var(--lang-accent-soft) 100%);
  box-shadow:
    0 10px 24px color-mix(in srgb, var(--lang-accent) 14%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--lang-accent) 24%, transparent);
}

.language-trigger {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.language-section.is-open .language-trigger {
  background: linear-gradient(90deg, color-mix(in srgb, var(--lang-accent) 14%, #ffffff) 0%, rgba(255, 255, 255, 0.35) 100%);
}

.language-identity,
.language-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flag {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--lang-accent) 20%, #ffffff);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 18px;
  line-height: 1;
}

.language-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.language-text strong {
  font-size: 13px;
}

.language-section.is-open .language-text strong {
  color: var(--lang-accent-deep);
}

.language-text small {
  color: var(--muted);
  font-size: 11px;
}

.usage-badge {
  min-width: 34px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--lang-accent) 14%, #ffffff);
  color: var(--lang-accent-deep);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.language-section.is-open .usage-badge {
  background: var(--lang-accent);
  color: #ffffff;
}

.language-arrow {
  color: var(--lang-accent-deep);
  font-size: 14px;
  transition: transform 160ms ease;
}

.language-section.is-open .language-arrow {
  transform: rotate(180deg);
}

.language-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 180ms ease;
}

.language-section.is-open .language-body {
  max-height: 220px;
}

.language-body .vip-grid {
  padding: 0 12px 12px;
}

.cache-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(135, 164, 255, 0.18);
}

.cache-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #87a4ff 0%, #5f7fe4 100%);
  transition: width 180ms ease;
}

.preview-panel {
  overflow: hidden;
}

.canvas-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border: 1px solid rgba(109, 141, 229, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(238, 246, 255, 0.94));
}

#certificateCanvas {
  width: min(100%, 430px);
  max-height: calc(100vh - 150px);
  height: auto;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(125, 151, 218, 0.18);
  background: #ffffff;
}

.state-overlay {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(241, 247, 255, 0.78);
  border-radius: 8px;
}

.hidden {
  display: none;
}

.state-card {
  min-width: 220px;
  padding: 20px 22px;
  border: 1px solid rgba(109, 141, 229, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
  box-shadow: var(--shadow);
}

.state-card p,
.state-card h2 {
  color: var(--text);
}

.state-card p {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid rgba(95, 127, 228, 0.18);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.coords {
  margin-top: auto;
  padding: 10px 12px;
  border: 1px solid rgba(109, 141, 229, 0.12);
  border-radius: 8px;
  background: rgba(242, 247, 255, 0.86);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.copy-image-btn {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(95, 127, 228, 0.26);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #edf4ff 100%);
  color: var(--accent-deep);
  font-family: "The Seasons Bold", "Times New Roman", serif;
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(116, 149, 235, 0.14);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.copy-image-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, #ffffff 0%, #e5efff 100%);
  box-shadow: 0 14px 28px rgba(116, 149, 235, 0.18);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1360px) {
  .page-shell {
    width: min(1160px, calc(100% - 24px));
    grid-template-columns: 270px minmax(440px, 1fr) 300px;
    gap: 12px;
  }

  #certificateCanvas {
    width: min(100%, 380px);
  }
}

@media (max-width: 1120px) {
  .page-shell {
    grid-template-columns: 1fr;
    width: min(760px, calc(100% - 24px));
  }

  .cache-group {
    margin-top: 0;
  }

  #certificateCanvas {
    width: min(100%, 440px);
    max-height: none;
  }
}
