.root {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fff5f5 0%, #ffe3e3 35%, #f8f9fa 100%);
  color: #212529;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: #dc3545;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  padding: 40px 20px 20px;
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto 60px;
}

.page-header {
  text-align: center;
  color: #333333;
  margin-bottom: 30px;
}

.page-header-title {
  font-size: 2.5em;
  margin-bottom: 10px;
  background: linear-gradient(45deg, #dc3545, #c82333);
  -webkit-background-clip: text;
  color: transparent;
  font-weight: 700;
}

.page-header-subtitle {
  color: #6c757d;
  font-size: 1.1em;
  margin-top: 10px;
}

.toolbar {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.toolbar a {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 53, 69, 0.1);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.toolbar a:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.25);
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(220, 53, 69, 0.15);
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.35);
  background: rgba(255, 255, 255, 0.98);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(220, 53, 69, 0.1);
}

.card-title {
  font-size: 1.4em;
  font-weight: 700;
  background: linear-gradient(45deg, #dc3545, #c82333);
  -webkit-background-clip: text;
  color: transparent;
  margin: 0;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.metric-display {
  text-align: center;
  margin: 15px 0;
}

.metric-value {
  font-size: 3em;
  font-weight: 800;
  background: linear-gradient(45deg, #dc3545, #c82333);
  -webkit-background-clip: text;
  color: transparent;
  line-height: 1.2;
}

.metric-label {
  color: #6c757d;
  font-size: 0.9em;
  margin-top: 5px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin: 15px 0;
}

.metric-item {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(220, 53, 69, 0.15);
  border-radius: 12px;
  padding: 15px;
  text-align: center;
  transition: all 0.15s ease;
}

.metric-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

.metric-item-value {
  font-size: 1.8em;
  font-weight: 700;
  color: #dc3545;
}

.metric-item-label {
  color: #6c757d;
  font-size: 0.9em;
  margin-top: 5px;
}

.btn-primary {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(220, 53, 69, 0.35);
  border: none;
  border-radius: 12px;
  font-weight: 600;
  padding: 12px 24px;
  font-size: 1em;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 53, 69, 0.2);
  color: #dc3545;
  border-radius: 12px;
  font-weight: 600;
  padding: 10px 20px;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(220, 53, 69, 0.15);
}

.form-grid {
  display: grid;
  gap: 15px;
}

.form-grid.two-columns {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

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

label {
  font-weight: 600;
  color: #444;
}

textarea,
input,
select {
  border-radius: 12px;
  border: 1px solid rgba(220, 53, 69, 0.2);
  padding: 12px 14px;
  font-size: 0.95em;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  resize: vertical;
  min-height: 120px;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: rgba(220, 53, 69, 0.45);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

textarea.output {
  background: rgba(248, 249, 250, 0.85);
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.result {
  background: rgba(248, 249, 250, 0.85);
  border-radius: 12px;
  padding: 16px;
  font-family: "Roboto Mono", "Fira Code", monospace;
  font-size: 0.9em;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-box {
  min-height: 120px;
  border-radius: 12px;
  border: 1px dashed rgba(220, 53, 69, 0.3);
  background: rgba(248, 249, 250, 0.6);
  padding: 16px;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.preview-muted {
  color: #adb5bd;
  border-color: rgba(173, 181, 189, 0.6);
  background: rgba(248, 249, 250, 0.3);
}

.helper {
  font-size: 0.85em;
  color: #6c757d;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  font-size: 0.8em;
  font-weight: 600;
}

.nav-back {
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.section-title {
  font-size: 1.1em;
  font-weight: 700;
  margin: 6px 0;
  color: #c82333;
}

.status-badge {
  border-radius: 999px;
  background: rgba(255, 193, 7, 0.2);
  color: #856404;
  padding: 6px 14px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75em;
}

footer {
  margin-top: auto;
  padding: 30px 20px;
  text-align: center;
  font-size: 0.85em;
  color: #6c757d;
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.regex-preview {
  font-family: "Roboto Mono", "Fira Code", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  min-height: 140px;
}

.regex-highlight {
  background: rgba(220, 53, 69, 0.2);
  border-bottom: 2px solid rgba(220, 53, 69, 0.45);
  padding: 0 2px;
  border-radius: 4px;
}

.regex-zero-width {
  display: inline-block;
  width: 2px;
  background: rgba(25, 135, 84, 0.8);
  margin: 0 1px;
  height: 1.2em;
  vertical-align: text-bottom;
}

@media (max-width: 720px) {
  .card {
    padding: 20px;
  }

  textarea,
  input {
    min-height: 100px;
  }

  .page-header-title {
    font-size: 2em;
  }
}
