/* ============ CSS Variables ============ */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --accent: #f472b6;
  --bg-start: #f8fafc;
  --bg-end: #e0e7ff;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-solid: #ffffff;
  --text: #1e293b;
  --text-muted: #94a3b8;
  --success: #10b981;
  --danger: #ef4444;
  --shadow: 0 4px 24px rgba(99, 102, 241, 0.12);
  --shadow-hover: 0 8px 32px rgba(99, 102, 241, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ============ App Layout ============ */
.app {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* 背景装饰 */
.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s ease-in-out infinite;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  top: -100px;
  right: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, var(--accent), var(--primary-light));
  bottom: -50px;
  left: -50px;
  animation-delay: -5s;
}

.blob-3 {
  width: 200px;
  height: 200px;
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  top: 50%;
  left: 50%;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(20px, -30px) scale(1.05); }
  50% { transform: translate(-10px, 20px) scale(0.95); }
  75% { transform: translate(15px, 10px) scale(1.02); }
}

/* ============ Header ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.75rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* ============ Main Content ============ */
.main {
  position: relative;
  z-index: 1;
  padding: 2rem 1rem 4rem;
}

.container {
  max-width: 560px;
  margin: 0 auto;
}

/* ============ Cards ============ */
.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

/* ============ Input Card ============ */
.input-card {
  position: relative;
}

.card-icon {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  color: var(--primary);
  opacity: 0.6;
}

.text-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: none;
  transition: border-color 0.2s, background 0.2s;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary-light);
  background: var(--surface-solid);
}

.text-input::placeholder {
  color: var(--text-muted);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

.char-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ============ Buttons ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-text:hover {
  color: var(--danger);
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(99, 102, 241, 0.1);
  border: none;
  border-radius: 8px;
  color: var(--primary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, transform 0.2s;
}

.btn-action:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: scale(1.1);
}

.btn-action.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ============ Upload Card ============ */
.upload-card {
  border: 2px dashed rgba(99, 102, 241, 0.3);
  background: rgba(255, 255, 255, 0.5);
  transition: border-color 0.3s, background 0.3s;
}

.upload-card.drag-over {
  border-color: var(--primary);
  border-style: solid;
  background: rgba(99, 102, 241, 0.05);
}

.upload-card.drag-over .upload-icon {
  transform: scale(1.1);
  color: var(--primary);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  transition: transform 0.3s, color 0.3s;
}

.upload-text {
  font-size: 0.9375rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.upload-browse {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.upload-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.upload-progress {
  display: none;
  margin-top: 1rem;
  align-items: center;
  gap: 0.75rem;
}

.upload-progress.active {
  display: flex;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  transition: width 0.2s ease;
  border-radius: 2px;
}

.progress-text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--primary);
  min-width: 36px;
  text-align: right;
}

/* ============ History Section ============ */
.history-section {
  margin-top: 2rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0 0.25rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.section-title svg {
  color: var(--primary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state.visible {
  display: flex;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* ============ History Item ============ */
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.06);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
}

.history-item:hover .btn-action {
  opacity: 1;
}

.history-item.removing {
  animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.item-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  color: white;
  font-size: 1.125rem;
}

.item-icon.file-icon {
  background: linear-gradient(135deg, var(--secondary), var(--accent));
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-preview {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.item-type {
  padding: 0.125rem 0.5rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
}

.item-size {
  color: var(--text-muted);
}

.item-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: var(--surface-solid);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  font-size: 0.9375rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast-icon {
  font-size: 1.125rem;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.hiding {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 90%;
  max-width: 400px;
  background: var(--surface-solid);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-header h3 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.modal-body ul {
  list-style: none;
  margin: 1rem 0;
}

.modal-body li {
  padding: 0.375rem 0;
  color: var(--text-muted);
}

.modal-hint {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 0.875rem;
}

kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8125rem;
}

/* ============ Paste Hint ============ */
.paste-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}

.paste-hint.visible {
  opacity: 1;
  transform: translateY(0);
}

.paste-hint svg {
  flex-shrink: 0;
  color: var(--primary);
  opacity: 0.6;
}

/* ============ Responsive ============ */
@media (max-width: 480px) {
  .header {
    padding: 0.875rem 1rem;
  }

  .main {
    padding: 1.5rem 0.75rem 3rem;
  }

  .card {
    padding: 1.25rem;
  }

  .text-input {
    padding: 0.875rem 0.875rem 0.875rem 2.75rem;
  }

  .history-item {
    flex-wrap: wrap;
  }

  .item-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
  }

  .btn-action {
    opacity: 1;
  }
}
