/* ============================================
   Trim — Design System
   ============================================ */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --surface: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  --accent: #111827;
  --accent-hover: #374151;
  --link: #2563eb;
  --link-hover: #1d4ed8;

  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;

  --editor-bg: #1a1a2e;
  --editor-text: #e2e8f0;
  --editor-border: #2d2d44;
  --editor-gutter: rgba(255,255,255,0.04);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);

  --transition: 150ms ease;
  --max-width: 1080px;
}

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

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

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--link-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* ---- Navigation ---- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.nav-link {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* ---- Layout ---- */

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ---- Landing Page ---- */

.hero {
  padding: 4rem 0 1.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.625rem;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.hero p {
  font-size: 1.0625rem;
  max-width: 440px;
  line-height: 1.55;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 2.5rem;
}

.tool-card {
  display: block;
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

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

.tool-card h3 {
  color: var(--text);
  margin-bottom: 0.1875rem;
}

.tool-card p {
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* ---- Tool Page Header ---- */

.tool-header {
  margin-bottom: 1.5rem;
}

.tool-header h1 {
  margin-bottom: 0.25rem;
}

.tool-header p {
  font-size: 0.9375rem;
}

/* ---- Editor Panels ---- */

.editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.editor-single {
  grid-template-columns: 1fr;
}

@media (max-width: 720px) {
  .editor-container {
    grid-template-columns: 1fr;
  }
}

.editor-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--editor-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--editor-bg);
}

.editor-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.875rem;
  background: var(--editor-gutter);
  border-bottom: 1px solid var(--editor-border);
  min-height: 36px;
}

.editor-panel-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  padding: 0.875rem 1rem;
  background: transparent;
  border: none;
  color: var(--editor-text);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  resize: none;
  outline: none;
  min-height: 320px;
  tab-size: 2;
}

.editor-textarea::placeholder {
  color: rgba(255,255,255,0.18);
}

.editor-output {
  flex: 1;
  width: 100%;
  padding: 0.875rem 1rem;
  color: var(--editor-text);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  min-height: 320px;
  user-select: text;
}

/* ---- Action Bar ---- */

.action-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.action-bar-right {
  margin-left: auto;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

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

.btn:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 0.375rem 0.5rem;
}

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

.btn-sm {
  padding: 0.3125rem 0.625rem;
  font-size: 0.75rem;
}

.btn-editor {
  background: rgba(255,255,255,0.06);
  color: var(--text-tertiary);
  border-color: transparent;
  font-size: 0.6875rem;
  padding: 0.25rem 0.5rem;
}

.btn-editor:hover {
  background: rgba(255,255,255,0.1);
  color: var(--editor-text);
}

/* ---- Status Messages ---- */

.status {
  font-size: 0.8125rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.status-success {
  color: var(--success);
}

.status-error {
  color: var(--error);
}

/* ---- Form Elements ---- */

.input {
  padding: 0.4375rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.input:focus {
  border-color: var(--link);
  outline: none;
}

.input:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  outline-offset: -1px;
}

.select {
  padding: 0.4375rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

/* ---- Result Displays ---- */

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.375rem;
  gap: 0.75rem;
}

.result-row .label {
  margin-bottom: 0;
  flex-shrink: 0;
  min-width: 56px;
}

.result-row .value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text);
  word-break: break-all;
  flex: 1;
  user-select: all;
}

/* ---- Color Tool Specific ---- */

.color-preview {
  width: 100%;
  height: 100px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: background var(--transition);
  margin-bottom: 1rem;
}

.color-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .color-inputs {
    grid-template-columns: 1fr;
  }
}

.color-input-group {
  display: flex;
  flex-direction: column;
}

.color-input-group .input {
  width: 100%;
}

/* ---- Regex Specific ---- */

.regex-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.regex-input-row .input {
  flex: 1;
}

.regex-flags {
  display: flex;
  gap: 0.125rem;
}

.regex-flags label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  color: var(--text-tertiary);
}

.regex-flags input {
  display: none;
}

.regex-flags input:checked + span {
  color: var(--text);
  font-weight: 600;
}

.regex-flags label:has(input:checked) {
  border-color: var(--text);
  background: var(--surface);
}

.highlight-area {
  padding: 0.875rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--editor-text);
  min-height: 200px;
}

.hl-match {
  background: rgba(37, 99, 235, 0.25);
  border-bottom: 2px solid #4d8aff;
  padding: 1px 0;
  border-radius: 2px;
}

.match-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-top: 0.75rem;
}

.match-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.match-table td {
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid var(--surface);
  font-family: var(--font-mono);
}

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

.match-highlight {
  background: rgba(37, 99, 235, 0.15);
  border-bottom: 2px solid var(--link);
  padding: 1px 0;
}

.match-info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
}

.matches-list {
  margin-top: 0.5rem;
}

.matches-list .result-row {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* ---- UUID/Batch output ---- */

.batch-output {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.batch-output .result-row {
  margin-bottom: 0;
}

/* ---- Epoch Specific ---- */

.epoch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .epoch-grid {
    grid-template-columns: 1fr;
  }
}

.epoch-section h2 {
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
}

/* ---- Footer ---- */

.footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ---- Utilities ---- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.w-full { width: 100%; }
.text-sm { font-size: 0.8125rem; }
.hidden { display: none; }

/* ---- Cheatsheet CTA banner ---- */
.cta-banner {
  margin: 2.5rem auto 0;
  max-width: 640px;
  padding: 1.5rem 2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
.cta-banner h3 {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}
.cta-banner p {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.cta-banner .btn-cta {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}
.cta-banner .btn-cta:hover {
  background: var(--accent-hover);
}
