:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --accent: #f5b400;
  --accent-dark: #d99a00;
  --blue: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body {
  min-width: 320px;
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
}

h1 span {
  color: var(--muted);
  font-weight: 600;
}

h2 {
  font-size: 22px;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(100%, 430px);
  padding: 34px;
}

.stack {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: #374151;
  font-size: 14px;
  font-weight: 800;
}

.required {
  color: var(--danger);
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

input[type="file"] {
  padding: 10px 12px;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(245, 180, 0, 0.22);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  color: #111827;
  background: var(--accent);
}

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

.secondary-button {
  color: #fff;
  background: var(--blue);
}

.ghost-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.danger-button {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.danger-button:hover {
  background: #8f1d14;
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.button-row,
.model-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 28px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.panel {
  padding: 22px;
}

.section-head,
.model-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.compact-head {
  align-items: flex-start;
}

.result-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.qr-frame {
  width: min(100%, 240px);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fafafa);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.qr-code {
  width: 100%;
  height: 100%;
  padding: 4px;
  object-fit: contain;
  background: #fff;
}

.qr-placeholder {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.qr-placeholder strong {
  color: var(--ink);
  font-size: 15px;
}

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

.qr-placeholder-icon {
  width: 54px;
  height: 54px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background:
    linear-gradient(90deg, #17202a 8px, transparent 8px) 12px 12px / 18px 18px no-repeat,
    linear-gradient(#17202a 8px, transparent 8px) 12px 12px / 18px 18px no-repeat,
    linear-gradient(90deg, #17202a 8px, transparent 8px) 28px 28px / 18px 18px no-repeat,
    linear-gradient(#17202a 8px, transparent 8px) 28px 28px / 18px 18px no-repeat,
    #fff8df;
}

.qr-frame.is-loading .qr-placeholder-icon {
  animation: qrPulse 1s ease-in-out infinite;
}

.qr-meta {
  margin: -6px 0 0;
}

button:disabled,
a[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

@keyframes qrPulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.share-link {
  overflow-wrap: anywhere;
  color: var(--blue);
  font-size: 14px;
}

.models-panel {
  margin-top: 18px;
}

.search-input {
  width: min(360px, 100%);
}

.model-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.model-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--soft);
}

.model-info {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.model-info strong,
.model-info span,
.model-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-info span {
  color: #374151;
  font-size: 14px;
}

.model-info small {
  color: var(--muted);
  font-size: 12px;
}

.admin-modal[hidden] {
  display: none !important;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.admin-modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
}

.modal-open {
  overflow: hidden;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: 16px;
  }

  .topbar,
  .section-head,
  .model-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .panel,
  .login-panel {
    padding: 18px;
  }

  .model-actions,
  .toolbar,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .model-actions > *,
  .toolbar > *,
  .button-row > *,
  .topbar .ghost-button {
    width: 100%;
  }
}
