:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #d7e0eb;
  --border-strong: #b6c6d9;
  --text: #152336;
  --text-muted: #52647a;
  --hv-navy: #1b365d;
  --hv-navy-deep: #122540;
  --festive-red: #c81e2b;
  --festive-red-hover: #a81622;
  --festive-red-soft: #fef2f2;
  --pine-green: #166534;
  --pine-green-soft: #ecfdf3;
  --amber-text: #854d0e;
  --amber-bg: #fefce8;
  --amber-border: #fde047;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-card: 0 6px 24px rgba(18, 37, 64, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(27, 54, 93, 0.06), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(200, 30, 43, 0.05), transparent 34%),
    var(--bg);
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.container {
  width: min(920px, calc(100% - 2rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--hv-navy-deep) 0%, var(--hv-navy) 65%, #234674 100%);
  color: #ffffff;
  padding: 1.75rem 0 1.9rem;
  border-bottom: 4px solid var(--festive-red);
}

.header-snow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 14% 28%, rgba(255, 255, 255, 0.45) 50%, transparent 100%),
    radial-gradient(2.5px 2.5px at 31% 65%, rgba(255, 255, 255, 0.35) 50%, transparent 100%),
    radial-gradient(2px 2px at 56% 22%, rgba(255, 255, 255, 0.4) 50%, transparent 100%),
    radial-gradient(3px 3px at 78% 58%, rgba(255, 255, 255, 0.3) 50%, transparent 100%),
    radial-gradient(2px 2px at 91% 25%, rgba(255, 255, 255, 0.45) 50%, transparent 100%),
    radial-gradient(1.5px 1.5px at 67% 80%, rgba(255, 255, 255, 0.35) 50%, transparent 100%);
}

.header-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #bfdbfe;
}

h1 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  line-height: 1.15;
}

.header-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  flex-wrap: wrap;
}

.header-tagline {
  margin: 0;
  color: #dbeafe;
  font-size: 0.98rem;
  max-width: 56ch;
}

.avatar-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #f8fafc;
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  transition: transform 0.22s ease, background-color 0.22s ease, border-color 0.22s ease;
}

.avatar-counter strong {
  color: #ffffff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.avatar-counter.is-updated {
  background: rgba(200, 30, 43, 0.35);
  border-color: rgba(255, 255, 255, 0.55);
  transform: scale(1.04);
}

.counter-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Main */
.main-content {
  flex: 1;
  padding: 1.75rem 0 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--hv-navy);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--hv-navy);
  background: #eaf0f8;
  border: 1px solid #d0deee;
}

.pill-success {
  color: var(--pine-green);
  background: var(--pine-green-soft);
  border-color: #bbf7d0;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  outline: none;
  border-color: var(--hv-navy);
  background: #f0f5fc;
  box-shadow: 0 0 0 3px rgba(27, 54, 93, 0.1);
}

.dropzone.is-dragover {
  border-color: var(--festive-red);
  background: var(--festive-red-soft);
}

.dropzone.is-error {
  border-color: var(--festive-red);
  background: #fff7f7;
}

.dropzone-icon {
  color: var(--hv-navy);
  margin-bottom: 0.55rem;
}

.dropzone-title {
  margin: 0;
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--text);
}

.dropzone-hint {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 0.08rem 0.34rem;
  font-size: 0.78rem;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
}

/* Feedback alerts */
.feedback {
  margin-top: 0.9rem;
  padding: 0.78rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 500;
}

.feedback.error {
  background: var(--festive-red-soft);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.feedback.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* Selected preview */
.selected-preview {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 0.95rem;
}

.thumb-frame {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background:
    repeating-conic-gradient(#e5ebf3 0% 25%, #ffffff 0% 50%) 50% / 12px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.thumb-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.file-meta {
  flex: 1;
  min-width: 0;
}

.file-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-name-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.status-badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  color: var(--pine-green);
  background: var(--pine-green-soft);
  border: 1px solid #bbf7d0;
}

.file-details {
  margin: 0.25rem 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.warning-list {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.7rem 0.5rem 1.4rem;
  border-radius: 8px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
  font-size: 0.82rem;
}

/* Buttons */
.form-actions {
  margin-top: 1.15rem;
  display: flex;
  justify-content: flex-start;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.82rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--festive-red);
  border: 1px solid #9f1239;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(200, 30, 43, 0.24);
  transition: background-color 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--festive-red-hover);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.42rem 0.72rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  flex-shrink: 0;
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: #ffffff;
}

.btn-secondary {
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.42rem 0.78rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

.btn-secondary:hover {
  background: #eaf0f8;
}

.btn-download {
  width: 100%;
  padding: 0.76rem 1.15rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--pine-green);
  border: 1px solid #14532d;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
}

.btn-download:hover {
  background: #14532d;
}

/* Result layout */
.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
}

.column-label {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.canvas-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background:
    repeating-conic-gradient(#e7edf5 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
  min-height: 210px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#preview-canvas {
  display: block;
  max-width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(18, 37, 64, 0.14);
  cursor: grab;
  touch-action: none;
}

#preview-canvas.is-dragging {
  cursor: grabbing;
}

.controls-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.range-control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.range-control input[type="range"] {
  width: 100%;
  accent-color: var(--festive-red);
}

.toggle-row {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.9rem;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.check-control input {
  accent-color: var(--hv-navy);
}

/* HV Forum 1:1 Mockup */
.hv-post-mock {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  border: 1px solid #c5d1df;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f7fa;
  font-size: 0.82rem;
}

.hv-author {
  padding: 0.7rem;
  background: #e9eff6;
  border-right: 1px solid #c5d1df;
}

.hv-username {
  font-weight: 700;
  color: var(--hv-navy);
  font-size: 0.88rem;
}

.hv-rank {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.hv-avatar-slot {
  width: 140px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 0.5rem;
}

.hv-avatar-slot img {
  display: block;
  max-width: 140px;
  max-height: 80px;
  image-rendering: auto;
}

.hv-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.hv-message {
  padding: 0.7rem 0.85rem;
  background: #ffffff;
}

.hv-post-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-bottom: 0.45rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #e5ebf3;
}

.hv-message p {
  margin: 0;
  color: var(--text);
}

.export-box {
  margin-top: 0.9rem;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.export-specs {
  margin: 0 0 0.7rem;
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* Rules card */
.rules-card {
  background: #fafcff;
}

.rules-card h3 {
  margin: 0 0 0.65rem;
  font-size: 0.98rem;
  color: var(--hv-navy);
}

.rules-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  display: grid;
  gap: 0.35rem;
}

.rules-list code {
  background: #eaf0f8;
  color: var(--hv-navy);
  padding: 0.06rem 0.32rem;
  border-radius: 4px;
  font-size: 0.84rem;
}

/* Footer */
.site-footer {
  padding: 1rem 0 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

@media (max-width: 760px) {
  .result-grid {
    grid-template-columns: 1fr;
  }

  .hv-post-mock {
    grid-template-columns: 1fr;
  }

  .hv-author {
    border-right: 0;
    border-bottom: 1px solid #c5d1df;
  }

  .selected-preview {
    flex-wrap: wrap;
  }
}
