:root {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #5558e3;
  --primary-light: #eef2ff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fef2f2;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Consolas, monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  font-size: 28px;
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

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

/* Main */
.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Forms */
.convert-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row .form-group {
  min-width: 200px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.required {
  color: var(--danger);
}

input, select {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

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

.path-input-wrapper {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.path-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.path-prefix {
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-right: 1px solid var(--border);
  line-height: 42px;
  white-space: nowrap;
}

.path-input-wrapper input {
  border: none;
  border-radius: 0;
  font-family: var(--mono);
  font-size: 13px;
}

.path-input-wrapper input:focus {
  box-shadow: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  white-space: nowrap;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  align-self: flex-start;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-icon.btn-danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* Spinner */
.spinner {
  animation: spin 0.8s linear infinite;
}

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

/* Links Table */
.links-table-wrapper {
  overflow-x: auto;
}

.links-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.links-table thead {
  background: var(--bg-hover);
}

.links-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.links-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.links-table tbody tr {
  transition: background 0.1s;
}

.links-table tbody tr:hover {
  background: var(--bg-hover);
}

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

/* Table cell content */
.cell-name {
  font-weight: 600;
  color: var(--text);
}

.cell-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.cell-url {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 12px;
}

.cell-format {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.cell-sub-url {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cell-sub-url code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--bg-hover);
  padding: 3px 6px;
  border-radius: 4px;
}

.cell-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

/* Empty State */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state p {
  margin-top: 12px;
  font-size: 14px;
}

.empty-hint {
  font-size: 12px !important;
  color: var(--text-muted);
  margin-top: 4px !important;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.feature {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.feature-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.feature h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.feature p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  min-width: 260px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.25s ease;
}

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

.toast.toast-out {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

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

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

.toast-warning {
  border-left-color: var(--warning);
}

.toast-icon {
  font-size: 16px;
  line-height: 1;
}

.toast-body {
  flex: 1;
}

.toast-body strong {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}

.toast-body span {
  color: var(--text-secondary);
  font-size: 12px;
  word-break: break-all;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.toast-close:hover {
  color: var(--text);
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner {
    padding: 12px 16px;
  }

  .main {
    padding: 16px;
    gap: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  .convert-form {
    padding: 16px;
  }

  .card-header {
    padding: 16px;
  }

  .links-table {
    font-size: 12px;
  }

  .links-table th, .links-table td {
    padding: 8px 10px;
  }

  .cell-url {
    max-width: 120px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }
}
