:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #151817;
  --muted: #64706a;
  --line: #dfe4df;
  --accent: #007f73;
  --accent-strong: #005f56;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(26, 34, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 56px);
  background: rgba(246, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.app-brand,
.app-topbar nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand {
  text-decoration: none;
}

.app-brand span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 900;
}

.app-topbar nav a,
.app-topbar nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.app-main {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px) 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: var(--ink);
  color: var(--surface);
}

.button.secondary {
  background: var(--surface);
}

.button.is-success {
  border-color: var(--accent);
  background: #e8f7f1;
  color: var(--accent);
}

.button.danger {
  width: 100%;
  border-color: var(--danger);
  background: var(--surface);
  color: var(--danger);
}

.button.wide {
  width: 100%;
}

.auth-panel,
.form-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 22px;
  align-items: start;
}

.stack,
.card-editor,
.side-panel,
.empty-state,
.public-card,
.card-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(26, 34, 30, 0.07);
}

.stack,
.card-editor,
.side-panel,
.empty-state,
.public-card {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.notice.error {
  padding: 12px;
  border-radius: 8px;
  background: #fff0ed;
  color: var(--danger);
  font-weight: 800;
}

label,
fieldset {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

label small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  font-weight: 900;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font: inherit;
}

input[type="color"] {
  width: 80px;
  min-height: 44px;
  padding: 4px;
}

input[type="range"] {
  padding: 0;
}

textarea {
  resize: vertical;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.empty-state {
  max-width: 620px;
}

.card-list {
  display: grid;
  gap: 14px;
}

.card-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.card-row .qr-thumb,
.side-panel img {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.image-previews {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.avatar-preview {
  position: relative;
  inset: auto;
  width: 72px;
  height: 72px;
  object-fit: cover;
  transform: none;
  border-radius: 50%;
}

.cover-preview {
  position: relative;
  inset: auto;
  width: 100%;
  height: 72px;
  object-fit: cover;
  transform: none;
  border-radius: 8px;
}

.crop-tool {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.crop-frame {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  background: #eef2ee;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.crop-frame img,
.public-cover img,
.public-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% * var(--crop-scale, 1));
  height: calc(100% * var(--crop-scale, 1));
  object-fit: contain;
  object-position: center;
  transform: translate(
    calc(-50% + var(--crop-translate-x, 0%)),
    calc(-50% + var(--crop-translate-y, 0%))
  );
}

.crop-frame img {
  display: block;
}

.avatar-crop {
  width: 150px;
  height: 150px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(26, 34, 30, 0.12);
}

.cover-crop {
  width: 100%;
  height: 160px;
  border-radius: 8px;
}

.crop-controls {
  display: grid;
  gap: 10px;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-grid span {
  padding: 9px 10px;
  border-radius: 8px;
  background: #f0f3ef;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.meta-grid strong {
  color: var(--ink);
}

.card-actions,
.side-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.side-panel {
  position: sticky;
  top: 94px;
}

.side-panel a {
  overflow-wrap: anywhere;
}

.public-card {
  --card-accent: var(--accent);
  position: relative;
  overflow: hidden;
  width: min(460px, 100%);
  margin: 0 auto;
  padding: 0 0 22px;
  text-align: center;
}

.public-cover {
  position: relative;
  overflow: hidden;
  height: 150px;
  background: linear-gradient(135deg, var(--card-accent), #151817);
}

.public-cover img {
  display: block;
}

.public-identity {
  display: grid;
  gap: 12px;
  padding: 0 22px;
  transform: translateY(-56px);
  margin-bottom: -56px;
}

.public-avatar {
  display: grid;
  width: 116px;
  height: 116px;
  margin: 0 auto;
  place-items: center;
  border: 5px solid var(--surface);
  border-radius: 50%;
  background: var(--card-accent);
  color: var(--surface);
  font-size: 2rem;
  font-weight: 900;
}

.public-logo-frame {
  position: relative;
  display: block;
  overflow: hidden;
  width: 116px;
  height: 116px;
  margin: 0 auto;
  border: 5px solid var(--surface);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.public-logo {
  display: block;
}

.public-card .button.primary {
  border-color: var(--card-accent);
  background: var(--card-accent);
}

.public-actions {
  display: grid;
  gap: 10px;
  padding: 0 22px;
}

.public-actions a {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.public-note {
  margin: 0 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: left;
}

@media (max-width: 820px) {
  .app-topbar,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-panel,
  .form-shell,
  .card-row {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .card-actions {
    width: 100%;
  }

  .card-actions .button {
    flex: 1;
  }
}
