:root {
  --primary: #1e293b;
  --primary-hover: #0f172a;
  --primary-light: rgba(30, 41, 59, 0.06);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --ring: rgba(30, 41, 59, 0.12);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --transition: 0.2s ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

.header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.logo::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--text);
  border-radius: 50%;
}

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

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--primary-light);
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-btn {
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-dropdown-btn::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--text-muted);
  margin-top: 2px;
  transition: transform var(--transition);
}

.nav-dropdown:hover .nav-dropdown-btn {
  color: var(--text);
  background: var(--primary-light);
}

.nav-dropdown:hover .nav-dropdown-btn::after {
  transform: rotate(180deg);
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 230px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  margin-top: 6px;
}

.nav-dropdown:hover .nav-dropdown-content {
  display: block;
}

.nav-dropdown-content a {
  display: block;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-dropdown-content a:hover {
  background: var(--primary-light);
  color: var(--text);
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 48px 0;
}

.main h1 {
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.4px;
}

.main > .container > p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 36px;
  max-width: 560px;
}

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

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

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

.tool-card h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.tool-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  flex: 1;
  line-height: 1.5;
}

.tool-card .button {
  align-self: flex-start;
}

.hero {
  text-align: center;
  padding: 64px 0 48px;
}

.hero h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 16px;
}

.hero p {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 24px;
  line-height: 1.7;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.hero-badge strong {
  color: var(--text);
  font-weight: 700;
}

.category-section {
  margin-bottom: 40px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.category-header .icon {
  font-size: 18px;
  line-height: 1;
}

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

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
}

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

.tool-card-icon {
  font-size: 24px;
  line-height: 1;
  margin-bottom: 10px;
}

.tool-card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.tool-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex: 1;
  line-height: 1.5;
}

.tool-card .button {
  align-self: flex-start;
  padding: 7px 16px;
  font-size: 12px;
}

.tool-container {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-sm);
}

.tool-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tool-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.tool-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

.form-group {
  margin-bottom: 22px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: all var(--transition);
  font-family: inherit;
}

.form-control:hover {
  border-color: var(--border-hover);
}

.form-control:focus {
  outline: none;
  border-color: var(--text);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring);
}

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

textarea.form-control {
  resize: vertical;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  min-height: 140px;
  padding: 14px 16px;
}

textarea.form-control:focus {
  background: var(--surface);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  background-color: var(--bg);
}

input[type="range"].form-control {
  padding: 0;
  border: none;
  background: none;
  accent-color: var(--text);
  height: 6px;
  cursor: pointer;
}

input[type="range"].form-control:focus {
  box-shadow: none;
  background: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  background: var(--primary);
  color: white;
}

.button:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow);
}

.button:active {
  transform: scale(0.97);
}

.button.secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.button.secondary:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg);
}

.button.success {
  background: var(--success);
  color: white;
}

.button.success:hover {
  background: #059669;
}

.button.danger {
  background: var(--error);
  color: white;
}

.button.danger:hover {
  background: #dc2626;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.25s ease;
  margin-bottom: 16px;
}

.alert.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #bbf7d0;
}

.alert.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

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

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  margin-top: auto;
}

.footer p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 3px 0;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  color: var(--text);
}

.stats-box {
  padding: 12px 16px;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 16px;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-inline .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 150px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.checkbox-group label:hover {
  border-color: var(--border-hover);
  background: var(--bg);
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--text);
  cursor: pointer;
}

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

.password-display .form-control {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 18px;
  letter-spacing: 2px;
  text-align: center;
  font-weight: 600;
}

.color-preview {
  width: 100%;
  height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  transition: background 0.3s ease;
}

.diff-output {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.diff-output textarea {
  height: 300px;
}

.regex-flags {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.regex-flags label {
  font-weight: 400;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .header .container {
    height: 56px;
  }

  .logo {
    font-size: 16px;
  }

  .logo::before {
    width: 8px;
    height: 8px;
  }

  .nav-link, .nav-dropdown-btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  .main {
    padding: 24px 0;
  }

  .main h1 {
    font-size: 22px;
  }

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

  .tool-container {
    padding: 20px;
  }

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

  .diff-output {
    grid-template-columns: 1fr;
  }

  .button-group {
    flex-direction: column;
  }

  .button-group .button {
    width: 100%;
  }

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

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .nav-dropdown-content {
    left: auto;
    right: 0;
    transform: none;
    min-width: 200px;
  }

  .tool-container {
    padding: 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
