:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --accent: #06b6d4;
  --bg: #f0fdfa;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* NAV */
nav {
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .logo { color: #fff; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; }
nav .logo span { opacity: .7; font-weight: 400; }
nav ul { list-style: none; display: flex; gap: 1.5rem; }
nav ul a { color: rgba(255,255,255,.85); font-weight: 500; font-size: .95rem; transition: color .2s; }
nav ul a:hover, nav ul a.active { color: #fff; }

/* HERO */
.hero {
  text-align: center;
  padding: 4rem 1rem 3rem;
  background: linear-gradient(180deg, rgba(13,148,136,.08), transparent);
}
.hero h1 { font-size: 2.8rem; font-weight: 800; margin-bottom: .5rem; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { font-size: 1.15rem; color: var(--text-light); max-width: 520px; margin: 0 auto; }

/* CARDS GRID */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.card .icon { font-size: 2rem; margin-bottom: .75rem; }
.card h3 { font-size: 1.15rem; margin-bottom: .4rem; }
.card p { color: var(--text-light); font-size: .9rem; margin-bottom: 1rem; }
.card .btn { display: inline-block; padding: .5rem 1.2rem; background: var(--primary); color: #fff; border-radius: 8px; font-weight: 600; font-size: .9rem; transition: background .2s; }
.card .btn:hover { background: var(--primary-dark); color: #fff; }

/* TOOL PAGE */
.tool-container {
  max-width: 800px;
  margin: 2rem auto 3rem;
  padding: 0 1.5rem;
  flex: 1;
}
.tool-container h1 { font-size: 1.8rem; margin-bottom: .25rem; }
.tool-container .subtitle { color: var(--text-light); margin-bottom: 1.5rem; }

textarea {
  width: 100%;
  min-height: 180px;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Fira Code', monospace;
  font-size: .85rem;
  resize: vertical;
  transition: border-color .2s;
}
textarea:focus { outline: none; border-color: var(--primary); }

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  padding: .75rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 1rem;
  transition: opacity .2s;
}
button.primary:hover { opacity: .9; }

/* RESULTS */
.results {
  margin-top: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.results:empty { display: none; }
.result-header {
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.result-header .score { font-size: 1.6rem; font-weight: 800; }
.result-body { padding: 1.5rem; }
.check-item {
  display: flex;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.check-item:last-child { border-bottom: none; }
.check-item .status { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.check-item .info h4 { font-size: .95rem; }
.check-item .info p { font-size: .85rem; color: var(--text-light); }

/* ROBOTS BUILDER */
.builder-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.builder-section h3 { margin-bottom: .75rem; font-size: 1rem; }
.rule-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .5rem;
  align-items: center;
}
.rule-row select, .rule-row input {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
}
.rule-row input { flex: 1; }
.rule-row button {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: .4rem .75rem;
  cursor: pointer;
  font-size: .85rem;
}
button.secondary {
  background: var(--bg);
  border: 2px dashed var(--border);
  padding: .5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-light);
  font-size: .9rem;
  margin-top: .5rem;
}
button.secondary:hover { border-color: var(--primary); color: var(--primary); }

.output-box {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1.5rem;
  border-radius: var(--radius);
  font-family: 'Fira Code', monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  position: relative;
  margin-top: 1rem;
}
.output-box .copy-btn {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: rgba(255,255,255,.1);
  border: none;
  color: #fff;
  padding: .4rem .75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
}
.output-box .copy-btn:hover { background: rgba(255,255,255,.2); }

/* HEADING TREE */
.heading-tree { padding: 1rem 1.5rem; }
.heading-node {
  padding: .4rem .5rem;
  margin: .2rem 0;
  border-radius: 6px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.heading-node .tag {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  min-width: 32px;
  text-align: center;
}
.h1-tag { background: var(--primary); }
.h2-tag { background: var(--accent); }
.h3-tag { background: #8b5cf6; }
.h4-tag { background: #f59e0b; }
.h5-tag { background: #ef4444; }
.h6-tag { background: #64748b; }

/* FOOTER */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: .85rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
}
footer .tip-btn {
  display: inline-block;
  margin-top: .5rem;
  padding: .4rem 1rem;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
}
.tip-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.tip-modal.show { display: flex; }
.tip-modal .modal-body {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 400px;
  text-align: center;
}
.tip-modal .modal-body code {
  display: block;
  padding: .5rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: .75rem;
  word-break: break-all;
  margin: .75rem 0;
}
.tip-modal .close-btn {
  background: var(--border);
  border: none;
  padding: .4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

@media (max-width: 640px) {
  nav { padding: 0 1rem; }
  nav ul { gap: .75rem; }
  nav ul a { font-size: .8rem; }
  .hero h1 { font-size: 2rem; }
  .cards { grid-template-columns: 1fr; }
}
