* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Text', 'Microsoft YaHei', sans-serif;
  background: #0a0a0a;
  color: #e8e8e8;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Navigation */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 100;
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.balance {
  font-size: 13px;
  color: #888;
  font-weight: 500;
}

.balance span {
  color: #fff;
  font-weight: 600;
  margin-left: 6px;
}

/* Announcement Bar */
.announcement-bar {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: rgba(200, 133, 63, 0.1);
  border-bottom: 1px solid rgba(200, 133, 63, 0.3);
  height: 40px;
  overflow: hidden;
  z-index: 90;
}

.announcement-content {
  display: flex;
  align-items: center;
  height: 100%;
  white-space: nowrap;
  animation: scroll-left 20s linear infinite;
  padding-left: 100%;
}

.announcement-content span {
  font-size: 13px;
  color: #C8853F;
  font-weight: 500;
}

@keyframes scroll-left {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Buttons */
.btn {
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-primary {
  background: #fff;
  color: #0a0a0a;
}

.btn-primary:hover {
  background: #f5f5f5;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #e8e8e8;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 24px;
}

.btn-generate:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Main Layout */
.main {
  padding-top: 64px;
  min-height: 100vh;
}

.main.with-announcement {
  padding-top: 104px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 32px;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 32px;
}

/* Panels */
.panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 24px;
}

.panel-header {
  margin-bottom: 24px;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Form Elements */
.form-section {
  margin-bottom: 20px;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #aaa;
}

.input,
.select {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #e8e8e8;
  font-size: 14px;
  transition: all 0.2s;
}

.input:focus,
.select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

.input::placeholder {
  color: #555;
}

.select {
  cursor: pointer;
}

/* Messages */
.msg {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  border: 1px solid;
}

.msg.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.msg.success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

/* Section Title */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.templates-section {
  margin-bottom: 24px;
}

/* Template Grid */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.tpl-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 8px;
}

.tpl-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.tpl-item.selected {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.5);
}

.tpl-number {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.tpl-name {
  font-size: 10px;
  color: #888;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.tpl-item.selected .tpl-name {
  color: #b4c6fc;
}

/* Recharge Panel */
.recharge-panel {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.recharge-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.recharge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.recharge-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.recharge-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.recharge-count {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.recharge-price {
  font-size: 16px;
  font-weight: 700;
  color: #C8853F;
}

.recharge-original {
  font-size: 11px;
  color: #666;
  text-decoration: line-through;
  margin-top: 2px;
}

.recharge-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #C8853F 0%, #A86B2C 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(200, 133, 63, 0.3);
}

/* Result Area */
.result-area {
  min-height: 600px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.empty {
  text-align: center;
  color: #555;
}

.empty svg {
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty p {
  font-size: 14px;
}

.result-area img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  background: #121212;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  padding: 32px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-tabs {
  display: flex;
  gap: 8px;
}

.modal-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: #888;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 28px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Responsive */
@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }

  .panel-controls {
    order: 2;
  }

  .panel-result {
    order: 1;
  }
}

@media (max-width: 640px) {
  .nav-inner {
    padding: 0 16px;
  }

  .container {
    padding: 24px 16px;
    gap: 24px;
  }

  .tpl-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .recharge-grid {
    grid-template-columns: 1fr;
  }
}

/* History Grid */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  cursor: pointer;
  user-select: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 24px;
}

.history-header h3 {
  font-size: 16px;
  color: #aaa;
  margin: 0;
}

.history-header svg {
  transition: transform 0.3s;
  color: #888;
}

.history-header.expanded svg {
  transform: rotate(180deg);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.history-grid.show {
  max-height: 2000px;
}

.history-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}

.history-item:hover .history-item-overlay {
  opacity: 1;
}

.history-item-time {
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  margin-bottom: 4px;
}

.history-item-number {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
