/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #fafbfc;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-secondary: #4a5568;
  --color-accent: #e85d04;
  --color-accent-hover: #d45203;
  --color-border: #e2e8f0;
  --color-muted: #a0aec0;
  --color-locked-bg: #edf2f7;
  --color-locked-text: #a0aec0;
  --color-success: #2f855a;
  --color-info: #2b6cb0;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition: 0.2s ease;
  --font-stack: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-stack);
  background: linear-gradient(180deg, #fafbfc 0%, #f0f2f5 100%);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Layout === */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* === Header === */
.header {
  text-align: center;
  padding: 3.5rem 0 2.5rem;
}

.title {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 0.3rem;
}

.subtitle {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  max-width: 540px;
  margin: 0 auto 1.8rem;
  line-height: 1.7;
}

/* === Auth Section === */
.auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-height: 2.8rem;
}

.auth-section .welcome-msg {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.6rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-stack);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-outline:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: #fff5f0;
}

.btn-sm {
  padding: 0.4rem 1.1rem;
  font-size: 0.85rem;
}

.btn-danger-text {
  background: transparent;
  color: #c53030;
  border: 1px solid #feb2b2;
  cursor: pointer;
}
.btn-danger-text:hover {
  background: #fff5f5;
  border-color: #fc8181;
}

/* === Tools Section === */
.tools-section {
  margin-top: 0.5rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-icon {
  font-size: 1.3rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* === Tool Card === */
.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent);
}

.tool-card.locked {
  background: var(--color-locked-bg);
  cursor: not-allowed;
  opacity: 0.7;
  user-select: none;
}

.tool-card.locked:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--color-border);
}

.tool-card .card-icon-wrap {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
}

.tool-card .card-body {
  flex: 1;
  min-width: 0;
}

.tool-card .card-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}

.tool-card .card-desc {
  font-size: 0.83rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.tool-card .card-badge {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.tool-card .card-badge.locked-badge {
  background: #e2e8f0;
  color: #a0aec0;
}

.tool-card .card-badge.unlocked-badge {
  background: #c6f6d5;
  color: #276749;
}

/* Card icon color themes — 6 novel tools */
.card-icon-nh { background: #fef3c7; color: #92400e; }
.card-icon-polisher { background: #dbeafe; color: #1e40af; }
.card-icon-expander { background: #d1fae5; color: #065f46; }
.card-icon-bible { background: #ede9fe; color: #5b21b6; }
.card-icon-coach { background: #fce7f3; color: #9d174d; }
.card-icon-doctor { background: #e0e7ff; color: #3730a3; }

/* Card icon color themes — 2 utility tools */
.card-icon-pubg { background: #fed7aa; color: #9a3412; }
.card-icon-cantonese { background: #d1fae5; color: #065f46; }

/* === Usage Stats === */
.usage-section {
  margin-top: 2.5rem;
}

.usage-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.usage-table th,
.usage-table td {
  padding: 0.9rem 1.2rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.usage-table th {
  background: #f7fafc;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usage-table td {
  font-size: 0.95rem;
  color: var(--color-text);
}

.usage-table tbody tr:last-child td {
  border-bottom: none;
}

.usage-table tbody tr:hover {
  background: #f7fafc;
}

.usage-table .usage-value {
  font-weight: 700;
  color: var(--color-accent);
  text-align: right;
}

.usage-table .usage-label {
  font-weight: 500;
}

.usage-empty {
  text-align: center;
  padding: 2.5rem;
  color: var(--color-muted);
  font-size: 0.95rem;
}

/* === Token Usage Panel (aggregate) === */
.token-month {
  color: #888;
  font-size: 13px;
  margin: -8px 0 16px 0;
}

.token-summary {
  margin-bottom: 20px;
}

.token-total-card {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.token-total-item {
  flex: 1;
  min-width: 120px;
  background: #f6f8fa;
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
}

.token-total-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.token-total-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
}

.token-table-wrap {
  overflow-x: auto;
}

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

.token-table th,
.token-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid #eee;
}

.token-table th {
  background: #f6f8fa;
  color: #555;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.token-table td:first-child,
.token-table th:first-child {
  text-align: left;
}

.token-table tbody tr:hover {
  background: #f0f4ff;
}

/* === Footer === */
.footer {
  text-align: center;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.85rem;
}

/* === Utility === */
.hidden {
  display: none !important;
}

/* === Loading === */
.loading-spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* === Responsive === */
@media (max-width: 640px) {
  .container {
    padding: 1rem 1rem 2rem;
  }
  .header {
    padding: 2rem 0 1.5rem;
  }
  .title {
    font-size: 1.8rem;
  }
  .subtitle {
    font-size: 1rem;
  }
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .tool-card {
    padding: 1.1rem;
  }
  .tool-card .card-icon-wrap {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
  .tool-card .card-title {
    font-size: 0.95rem;
  }
}
