:root {
  color-scheme: dark;
  --bg: #101514;
  --surface: #18211e;
  --surface-2: #22312c;
  --text: #eef6f1;
  --muted: #aab8b1;
  --line: #31423b;
  --accent: #58c4a5;
  --accent-strong: #8bdcbe;
  --danger: #ff8585;
  --danger-soft: #3b2526;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
  font-size: 16px;
}

button,
.secondary-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.app-shell {
  width: min(720px, calc(100% - 20px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.topbar,
.quick-actions,
.dialog-header,
.viewer-header,
.dialog-actions,
.pass-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 10vw, 58px);
  line-height: 0.96;
}

h2 {
  margin-bottom: 8px;
}

.pass-card,
.dialog,
.viewer-dialog,
.scanner-dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quick-actions {
  margin-bottom: 12px;
}

.primary-action,
.quick-actions .secondary-button {
  flex: 1;
  min-height: 58px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 46px;
  padding: 0 11px;
}

textarea {
  min-height: 74px;
  padding-top: 10px;
  resize: vertical;
}

.sr-only-file {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.scan-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.scan-text-button {
  white-space: nowrap;
}

.secondary-button,
.icon-button,
.secondary-button:hover,
.icon-button:hover {
  background: var(--line);
  color: var(--text);
}

.icon-button {
  width: 46px;
  min-width: 46px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.ghost {
  background: transparent;
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.card-grid {
  display: grid;
  gap: 12px;
}

.pass-card {
  position: relative;
  display: grid;
  min-height: 200px;
  overflow: hidden;
  padding: 16px;
}

.pass-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--card-a), var(--card-b));
  opacity: 0.16;
}

.pass-main,
.pass-actions {
  position: relative;
}

.pass-main p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pass-main h2 {
  min-height: 52px;
  overflow-wrap: anywhere;
  font-size: 25px;
  line-height: 1.14;
}

.barcode-mini {
  height: 46px;
  margin-top: 16px;
  padding: 7px;
  border-radius: 7px;
  background: #fff;
  color: #1d2622;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.barcode-render {
  width: 100%;
  min-height: 152px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.barcode-render svg,
.barcode-mini svg {
  width: 100%;
  display: block;
}

.barcode-render svg {
  height: clamp(112px, 32vw, 164px);
}

.barcode-mini svg {
  height: 100%;
}

.pass-actions {
  align-self: end;
  margin-top: 18px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.dialog,
.viewer-dialog,
.scanner-dialog {
  width: min(640px, calc(100% - 20px));
  padding: 0;
  color: var(--text);
}

.dialog::backdrop,
.viewer-dialog::backdrop,
.scanner-dialog::backdrop {
  background: rgba(6, 10, 9, 0.72);
}

.card-form,
.viewer,
.scanner {
  display: grid;
  gap: 15px;
  padding: 18px;
}

.viewer-dialog {
  width: min(860px, calc(100% - 20px));
}

.viewer {
  gap: 18px;
}

.scanner-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 4 / 3;
  background: #050807;
}

.scanner-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.scanner-guide {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 40%;
  height: 20%;
  border: 2px solid var(--accent-strong);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.32);
}

.scanner-status {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.compatibility-notice {
  border: 1px solid color-mix(in srgb, var(--danger) 44%, var(--line));
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.viewer-barcode {
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
}

.no-barcode {
  color: #1d2622;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.viewer-code {
  margin: 0;
  color: var(--text);
  font-size: clamp(20px, 8vw, 34px);
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
  overflow-wrap: anywhere;
}

.viewer-note {
  margin: 0;
  color: var(--muted);
  text-align: center;
  white-space: pre-wrap;
}

@media (max-width: 560px) {
  .topbar,
  .quick-actions,
  .dialog-actions,
  .pass-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .icon-button,
  .quick-actions > *,
  .scan-input-row > *,
  .pass-actions > * {
    width: 100%;
  }

  .scan-input-row {
    grid-template-columns: 1fr;
  }
}
