:root {
  --mcd-red: #db0007;
  --mcd-yellow: #ffbc0d;
  --mcd-dark: #27251f;
  --bg: #f6f6f6;
  --card: #ffffff;
  --border: #ececec;
  --text-muted: #666;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--mcd-dark);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

button,
.btn,
.link-btn,
.coupon-item {
  -webkit-tap-highlight-color: transparent;
}

button,
.btn {
  touch-action: manipulation;
}

.login-overlay {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(circle at top right, rgba(255, 188, 13, 0.25), transparent 30%),
    radial-gradient(circle at bottom left, rgba(219, 0, 7, 0.12), transparent 28%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
}

.login-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.login-card input {
  width: 100%;
  margin-bottom: 12px;
}

.btn.full {
  width: 100%;
}

.header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.header .btn {
  margin-left: auto;
}

.key-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.key-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
}

.key-item.active {
  border-color: var(--mcd-red);
  background: #fff8f8;
}

.key-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--mcd-red);
  color: var(--mcd-yellow);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 28px;
}

.logo.small {
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-radius: 12px;
}

.header h1,
.share-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.header p,
.hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.row.between {
  justify-content: space-between;
}

select {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  background: #fff;
}

input[type="password"],
input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  cursor: pointer;
}

.btn.primary {
  background: var(--mcd-red);
  color: white;
}

.btn.secondary {
  background: #fff4cc;
  color: var(--mcd-dark);
}

.btn.danger {
  background: #ffe8e8;
  color: #b00000;
}

.link-btn {
  border: none;
  background: none;
  color: var(--mcd-red);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.upload-box {
  border: 2px dashed #ddd;
  border-radius: 14px;
  padding: 32px 16px;
  text-align: center;
  background: #fafafa;
}

.upload-box.dragover {
  border-color: var(--mcd-yellow);
  background: #fffbe6;
}

.preview {
  margin-top: 16px;
  text-align: center;
}

.preview img {
  max-width: 220px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

.message {
  margin-top: 12px;
  min-height: 20px;
}

.message.ok {
  color: #067647;
}

.message.ok .link-success-panel {
  color: var(--mcd-dark);
}

.message.err {
  color: #b00000;
}

.table-wrap {
  overflow: visible;
}

.link-success-panel {
  margin-top: 4px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f6fff9 0%, #ffffff 100%);
  border: 1px solid #cfeedd;
}

.link-success-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.link-success-head > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.link-success-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e7f8ef;
  color: #067647;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.link-success-title {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.link-url-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  color: #333;
  font-family: Consolas, "Courier New", monospace;
}

.link-url-input:focus {
  outline: 2px solid rgba(219, 0, 7, 0.15);
  border-color: #ffb3b3;
}

.link-cards {
  display: grid;
  gap: 12px;
}

.link-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.link-card.is-active {
  border-color: #f3c7c7;
  background: linear-gradient(180deg, #fffdfd 0%, #ffffff 100%);
}

.link-card.is-done {
  opacity: 0.88;
  background: #fafafa;
}

.link-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.link-card-title-wrap {
  flex: 1;
  min-width: 0;
}

.link-card-title {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

.link-card-code {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.link-card-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.link-card-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.link-card-time {
  font-size: 12px;
  color: var(--text-muted);
}

.copy-link-btn.copied,
.btn.copied {
  background: #e7f8ef !important;
  color: #067647 !important;
}

.link-search-box {
  margin: 12px 0;
}

.link-search-box input[type="search"] {
  flex: 2;
  min-width: 180px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

.link-card-status-detail {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.badge.active {
  background: #e7f8ef;
  color: #067647;
}

.badge.destroyed {
  background: #f3f3f3;
  color: #666;
}

.copy-link {
  color: var(--mcd-red);
  cursor: pointer;
  word-break: break-all;
}

.share-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #f6f6f6;
}

.pending-tip {
  text-align: center;
  color: #999;
  margin: 28px 0 20px;
  font-size: 14px;
}

.btn.claim-btn {
  background: #ffbc0d;
  color: #222;
  font-weight: 700;
  border-radius: 999px;
  padding: 14px 20px;
}

.btn.claim-btn:hover {
  background: #f5b000;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: end center;
  padding: 16px;
  z-index: 20;
}

.confirm-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px 24px;
}

.confirm-card h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.confirm-alert {
  display: flex;
  gap: 10px;
  background: #fff3f0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.alert-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffbc0d;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.confirm-alert p {
  margin: 0;
  color: #db0007;
  font-size: 14px;
  line-height: 1.5;
}

.confirm-rules {
  margin: 0 0 18px;
  padding-left: 18px;
  color: #444;
  font-size: 14px;
  line-height: 1.7;
}

.confirm-rules .danger {
  color: #db0007;
}

.confirm-extra-warn {
  margin: 0 0 18px;
  color: #db0007;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.share-container {
  width: min(420px, 100%);
}

.center {
  text-align: center;
}

.share-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.share-header > div:last-child {
  min-width: 0;
  flex: 1;
}

.timer {
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  color: var(--mcd-red);
  margin: 8px 0 4px;
}

.qr-frame {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 16px 0;
}

.qr-frame img {
  width: 100%;
  display: block;
  border-radius: 8px;
}

.warning {
  text-align: center;
  color: #b00000;
  font-size: 13px;
}

.usage-guide {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #eee;
  text-align: center;
}

.usage-guide-title {
  margin: 0 0 12px;
  color: #db0007;
  font-size: 15px;
  font-weight: 700;
}

.usage-guide-img {
  width: 100%;
  display: block;
  border-radius: 12px;
  margin: 0 auto 12px;
}

.usage-guide-text {
  margin: 0;
  color: #444;
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
}

.usage-guide-text .hl {
  color: #db0007;
  font-weight: 700;
}

.invalid-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #ffe8e8;
  color: #b00000;
  display: grid;
  place-items: center;
  font-size: 28px;
}

.recognize-box {
  margin: 16px 0;
  text-align: left;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.recognize-title {
  margin: 0 0 8px;
  font-weight: 600;
}

.recognize-content {
  margin: 8px 0 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
  max-height: 160px;
  overflow: auto;
}

.preview .btn {
  margin: 4px;
}

.btn.small {
  padding: 8px 12px;
  font-size: 12px;
}

.coupon-picker {
  margin: 16px 0;
  text-align: left;
}

.coupon-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.coupon-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.coupon-item:hover {
  border-color: #ffd56a;
  background: #fffdf5;
}

.coupon-item.selected {
  border-color: var(--mcd-red);
  background: #fff8f8;
}

.coupon-item input {
  margin-top: 4px;
}

.coupon-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #f3f3f3;
  flex-shrink: 0;
}

.coupon-info {
  flex: 1;
  min-width: 0;
}

.coupon-info strong {
  display: block;
  margin-bottom: 4px;
}

.coupon-info .hint {
  line-height: 1.5;
}

.coupon-badge {
  display: inline-block;
  margin-right: 6px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff4cc;
  color: #7a5d00;
  font-size: 12px;
}

.coupon-badge.suggest {
  background: #e7f8ef;
  color: #067647;
}

.link-count-box {
  margin: 16px 0;
  text-align: left;
}

.batch-keys-box {
  margin: 14px 0 8px;
  display: grid;
  gap: 10px;
}

.batch-keys-box textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.monitor-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.monitor-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fafafa;
}

.monitor-item.is-error {
  border-color: #f0b4b4;
  background: #fff5f5;
}

.monitor-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.monitor-coupons {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #555;
  font-size: 13px;
  line-height: 1.6;
}

.package-key-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
}

.package-key-item input {
  width: auto;
  min-width: 0;
}

.link-card-meta {
  font-size: 12px;
  color: #888;
  margin: 4px 0 0;
}

.link-count-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.link-count-box input[type="number"] {
  width: 100%;
  max-width: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}

.batch-result {
  margin-top: 4px;
}

.batch-links {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.batch-link-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.batch-link-index {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff4cc;
  color: #7a5d00;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.usage-text {
  color: #067647;
  font-weight: 600;
}

.log-detail {
  max-width: 420px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .container {
    padding: 16px 12px calc(32px + env(safe-area-inset-bottom));
  }

  .header {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
  }

  .header > div:not(.logo) {
    flex: 1;
    min-width: 0;
  }

  .header .btn {
    margin-left: 0;
    width: 100%;
    min-height: 44px;
  }

  .header h1,
  .share-header h1 {
    font-size: 20px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 12px;
  }

  .card h2 {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row.between {
    gap: 8px;
  }

  input[type="password"],
  input[type="text"] {
    min-width: 0;
    width: 100%;
    font-size: 16px;
  }

  .btn {
    min-height: 44px;
    width: 100%;
  }

  .btn.small {
    min-height: 40px;
    width: auto;
  }

  .key-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .key-actions {
    justify-content: flex-end;
  }

  .key-actions .btn {
    width: auto;
    flex: 1;
  }

  .upload-box {
    padding: 24px 12px;
  }

  .preview img {
    max-width: min(220px, 100%);
  }

  .preview .btn {
    display: block;
    width: 100%;
    margin: 6px 0;
  }

  .coupon-picker .row.between {
    flex-direction: column;
    align-items: stretch;
  }

  .coupon-picker .row.between .btn {
    width: 100%;
  }

  .coupon-list {
    max-height: none;
  }

  .coupon-item {
    padding: 10px;
  }

  .link-count-box input[type="number"] {
    max-width: none;
    width: 100%;
  }

  .link-success-head {
    flex-wrap: wrap;
  }

  .link-success-head .btn {
    width: 100%;
  }

  .link-card-url-row,
  .batch-link-item {
    flex-direction: column;
    align-items: stretch;
  }

  .link-card-url-row .btn,
  .batch-link-item .btn {
    width: 100%;
  }

  .link-card-foot .btn {
    width: 100%;
  }

  .login-overlay,
  .share-body {
    padding: 12px;
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .confirm-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .confirm-card {
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .confirm-actions {
    grid-template-columns: 1fr;
  }

  .timer {
    font-size: 36px;
  }

  .share-container {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .logo {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .header h1,
  .share-header h1 {
    font-size: 18px;
  }

  .timer {
    font-size: 32px;
  }
}
