:root {
  --bg: #f4f1ea;
  --panel: #fffdfa;
  --panel-strong: #f7efe2;
  --ink: #1f1d1a;
  --muted: #665f55;
  --line: #d9cdbd;
  --accent: #b84c2a;
  --accent-deep: #8f3215;
  --danger: #8f1d2c;
  --warning: #8f5d00;
  --success: #236c43;
  --shadow: 0 16px 40px rgba(63, 42, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(184, 76, 42, 0.16), transparent 26%),
    radial-gradient(circle at top right, rgba(35, 108, 67, 0.12), transparent 24%),
    linear-gradient(180deg, #f9f4eb 0%, var(--bg) 100%);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 36px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2 {
  margin: 0;
}

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

h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

.page-shell {
  padding: 0 36px 36px;
}

.grid {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

.grid.two-up {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid rgba(217, 205, 189, 0.8);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(10px);
}

.panel.narrow {
  max-width: 520px;
  margin: 8vh auto 0;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.muted {
  color: var(--muted);
}

.compact {
  margin-top: 6px;
}

.banner {
  margin: 0 36px 18px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
}

.banner.warning {
  background: rgba(255, 233, 194, 0.82);
  border-color: rgba(143, 93, 0, 0.25);
}

.banner.success {
  background: rgba(202, 239, 218, 0.88);
  border-color: rgba(35, 108, 67, 0.24);
}

.banner.error {
  background: rgba(250, 212, 219, 0.9);
  border-color: rgba(143, 29, 44, 0.22);
}

.banner.info {
  background: rgba(213, 230, 247, 0.88);
  border-color: rgba(32, 87, 127, 0.2);
}

.stack-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

label span {
  font-weight: 600;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
}

textarea {
  resize: vertical;
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 10px 24px rgba(184, 76, 42, 0.2);
}

button:hover,
.link-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.danger-button {
  background: linear-gradient(135deg, #b53749 0%, var(--danger) 100%);
  box-shadow: 0 10px 24px rgba(143, 29, 44, 0.18);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.stats article {
  background: var(--panel-strong);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(217, 205, 189, 0.8);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.account-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.account-card {
  border: 1px solid rgba(217, 205, 189, 0.8);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  gap: 14px;
}

.inline-meta,
.button-row,
.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-grid {
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(184, 76, 42, 0.1);
  color: var(--accent-deep);
  font-size: 13px;
}

.pill.soft {
  background: rgba(31, 29, 26, 0.08);
  color: var(--muted);
}

.table-shell {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(217, 205, 189, 0.7);
}

th {
  color: var(--muted);
  font-size: 13px;
}

.code-block {
  margin: 0;
  padding: 14px;
  border-radius: 16px;
  background: #171411;
  color: #f8f4ee;
  overflow: auto;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.code-block.tall {
  min-height: 320px;
  max-height: 520px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.46);
}

.qr-preview {
  display: block;
  width: 100%;
  max-width: 760px;
  border-radius: 20px;
  border: 4px solid #fff;
  box-shadow: 0 12px 36px rgba(63, 42, 17, 0.18);
  margin: 0 auto 18px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.qr-preview:hover {
  transform: scale(1.02);
  box-shadow: 0 18px 48px rgba(63, 42, 17, 0.24);
}

.qr-preview.expanded {
  max-width: 900px;
}

body.modal-open {
  overflow: hidden;
}

.image-modal[hidden] {
  display: none;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 12, 8, 0.72);
  backdrop-filter: blur(6px);
}

.image-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 1080px);
  max-height: 92vh;
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 253, 250, 0.98);
  box-shadow: 0 24px 60px rgba(17, 12, 8, 0.3);
}

.image-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-modal-preview {
  width: 100%;
  max-height: calc(92vh - 92px);
  object-fit: contain;
  border-radius: 18px;
  border: 1px solid rgba(217, 205, 189, 0.9);
  background: #fff;
}

.friend-picker {
  display: grid;
  gap: 12px;
}

.friend-picker-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.friend-picker-title {
  display: inline-block;
  font-weight: 600;
  margin-bottom: 4px;
}

.friend-search {
  display: grid;
  gap: 8px;
}

.friend-picker-list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(217, 205, 189, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
}

.friend-picker-current-targets {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(247, 239, 226, 0.65);
  line-height: 1.5;
}

.friend-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 40px;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(217, 205, 189, 0.95);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.friend-option span {
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
  white-space: nowrap;
}

.friend-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  inset: 0;
}

.friend-option:hover {
  border-color: rgba(143, 50, 21, 0.35);
  box-shadow: 0 8px 18px rgba(63, 42, 17, 0.08);
}

.friend-option.selected {
  border-color: #2f6fed;
  background: #2f6fed;
  box-shadow: 0 10px 20px rgba(47, 111, 237, 0.22);
}

.friend-option.selected span {
  color: #fff;
}

.friend-picker-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 16px;
}

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

.check-row input {
  width: auto;
}

.ops-meta {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 720px) {
  .topbar,
  .page-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .banner {
    margin-left: 18px;
    margin-right: 18px;
  }

  .panel-header {
    flex-direction: column;
  }

  .button-grid,
  .button-row,
  .inline-meta {
    flex-direction: column;
  }

  button,
  .link-button {
    width: 100%;
  }
}
