* { box-sizing: border-box; }
:root {
  --bg: #fafafa;
  --surface: #fff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #2d2d2d;
  --accent-contrast: #fff;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #212226;
    --border: #34353a;
    --text: #f0f0f0;
    --text-muted: #9a9a9f;
    --accent: #e8e8e8;
    --accent-contrast: #1a1a1a;
  }
}
body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  color: var(--text);
  background: var(--bg);
}
header nav.lang-switch { display: flex; gap: 0.5rem; justify-content: flex-end; margin-bottom: 1rem; }
header nav.lang-switch a {
  text-decoration: none; padding: 0.25rem 0.6rem; border-radius: 6px;
  color: var(--text-muted); font-size: 0.85rem; border: 1px solid var(--border);
}
header nav.lang-switch a.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

h1 { font-size: 1.4rem; }

.hero-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 600;
  margin: 1.5rem 0 1.25rem;
}

.tools-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 2.5rem 0 1rem;
}

.back-link {
  display: inline-block; color: var(--text-muted); text-decoration: none; font-size: 0.9rem; margin-bottom: 0.5rem;
}
.back-link:hover { text-decoration: underline; }

.tiles { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin-top: 1rem; }
.tile {
  display: block; padding: 1.1rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.tile:not(.disabled):hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); transform: translateY(-1px); }
.tile-icon { font-size: 1.5rem; display: block; margin-bottom: 0.4rem; }
.tile h3 { margin: 0 0 0.25rem 0; font-size: 1.05rem; }
.tile p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.tile.disabled { opacity: 0.55; pointer-events: none; }
.badge { display: inline-block; font-size: 0.7rem; background: var(--border); color: var(--text-muted); padding: 0.1rem 0.4rem; border-radius: 4px; margin-left: 0.4rem; }

.chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}
.chat-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.4rem 0.75rem 0.6rem;
  border-top: 1px solid var(--border);
}
.chat-footer.hidden { display: none; }
.chat-reset {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}
.chat-reset:hover { background: var(--bg); color: var(--text); }

.chat-log {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-log:empty { display: none; }
.chat-bubble {
  max-width: 80%;
  padding: 0.5rem 0.8rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-contrast);
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble.thinking { color: var(--text-muted); font-style: italic; }
.chat-bubble.error { color: #c0392b; border-color: #c0392b33; }

.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-log:empty + .chat-input { border-top: none; }
.chat-input textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 160px;
  padding: 0.4rem 0.2rem;
}
.chat-send {
  flex-shrink: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-send:disabled { opacity: 0.5; cursor: default; }

.toolbar { display: flex; gap: 0.5rem; margin: 1rem 0; }
.toolbar input[type=search] {
  flex: 1; padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid #ccc; font-size: 0.95rem;
}
button, .btn {
  padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid #333; background: #333; color: #fff;
  cursor: pointer; font-size: 0.9rem;
}
button.secondary { background: #fff; color: #333; }

.exercise-list { list-style: none; padding: 0; margin: 0; }
.exercise-card {
  padding: 0.75rem; border: 1px solid #e2e2e2; border-radius: 8px; margin-bottom: 0.5rem; background: #fff;
}
.exercise-card .level { font-size: 0.75rem; color: #888; }
.exercise-card h3 { margin: 0.15rem 0 0.4rem 0; font-size: 1rem; }
.exercise-card a.btn { display: inline-block; margin-top: 0.4rem; text-decoration: none; }

.pagination { display: flex; justify-content: space-between; margin-top: 0.75rem; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

.empty { color: #888; padding: 1rem 0; }
