/* Category, docs, contact, legal and settings pages. Builds on tc-site.css (+ structural rules in tc-legacy.css). */
:root { --header-h: 86px; }
@media (max-width: 1023px) { :root { --header-h: 68px; } }

/* Shared: intro accents on light tiles, meta badges, page body tile */
.tc-intro h1 .accent { color: var(--accent); }
.tc-intro__meta, .tc-docs-head__badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tc-intro__meta .tc-badge, .tc-docs-head__badges .tc-badge { padding: 5px 11px; font-size: 12px; }
.tc-pagebody__tile { padding: 32px; }
.tc-pagebody { margin-bottom: 0; }
@media (max-width: 640px) { .tc-pagebody__tile { padding: 20px 16px; } }

/* Category page */
.tc-intro--category { padding-top: 36px; }
.tc-category-tools { padding: 24px 24px 0; }
.tc-category-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.tc-category-bar p { font-size: 13px; color: var(--muted); }
.tc-category-bar .tc-search { flex: 1; max-width: 360px; min-width: min(100%, 220px); }
.tc-search { position: relative; display: block; }
.tc-search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: #9da7b6; pointer-events: none; }
.tc-search input { width: 100%; height: 42px; padding: 0 12px 0 34px; border: 1px solid var(--tc-line-strong); border-radius: 10px; background: #fff; font-size: 13px; color: var(--tc-text); }
.tc-search input:focus-visible { outline: 3px solid var(--tc-sky); outline-offset: 0; border-color: var(--tc-blue-600); }
.tc-category-tools .tc-tools { margin: 0 -24px; }
.tc-category-tools .tc-tool[hidden] { display: none; }
.tc-catalog__empty { padding: 40px 0; text-align: center; color: var(--muted); }
@media (max-width: 640px) { .tc-category-tools { padding: 16px 12px 0; } .tc-category-tools .tc-tools { margin: 0 -12px; } }

/* Docs + legal: two-column body with a sticky TOC */
.tc-docs-head { padding-bottom: 30px; }
.tc-docs-quick { padding: 0; }
.tc-docs-quick .tc-qlinks { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0; margin: 0; }
.tc-docs-quick .tc-qlink { min-height: 92px; padding: 18px 20px; border: 0; border-right: 1px solid var(--border); border-radius: 0; background: #fff; color: var(--text); transform: none; }
.tc-docs-quick .tc-qlink:last-child { border-right: 0; }
.tc-docs-quick .tc-qlink:hover { background: var(--tc-blue-50); transform: none; }
.tc-docs-quick .tc-qlink small { color: var(--muted); }
.tc-docs-quick .tc-qlink__ico { background: var(--tc-blue-50); color: var(--accent); }
.tc-docs { display: grid; grid-template-columns: 236px minmax(0,1fr); gap: 0; align-items: start; padding: 0; }
.tc-toc { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; margin: 0; padding: 26px 16px; border: 0; border-right: 1px solid var(--border); border-radius: 0; background: transparent; box-shadow: none; }
.tc-toc__title { margin: 0 0 8px; padding: 0 10px; font-family: var(--tc-mono); font-size: 10px; font-weight: 500; letter-spacing: .09em; color: var(--accent); }
.tc-toc__title + a { margin-top: 0; }
.tc-toc a { padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.tc-toc a:hover { background: var(--tc-surface); color: var(--text); }
.tc-toc a.is-active { background: var(--tc-blue-50); color: var(--tc-blue-700); font-weight: 600; }
.tc-doc-main, .tc-docs > .tc-doc-section, .tc-docs > section { min-width: 0; }
.tc-doc-main { padding: 8px 40px 40px; }
.tc-docs > .tc-doc-section { padding: 0 40px; }
.tc-docs > .tc-doc-section:first-of-type { padding-top: 12px; }
.tc-docs > .tc-doc-section:last-child { padding-bottom: 40px; }
.tc-doc-section { padding-top: 32px; scroll-margin-top: calc(var(--header-h) + 16px); }
.tc-doc-section + .tc-doc-section { border-top: 1px solid var(--border); margin-top: 32px; }
.tc-doc-section h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 24px; letter-spacing: -.03em; color: var(--text); }
.tc-doc-section h3 { scroll-margin-top: calc(var(--header-h) + 16px); }
.tc-h2ico { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--tc-blue-50); color: var(--accent); }
.tc-h2ico svg { width: 18px; height: 18px; }
.tc-prose { max-width: 72ch; }
.tc-docs .tc-prose { max-width: none; }
.tc-docs .tc-prose > p, .tc-docs .tc-prose > ul, .tc-docs .tc-prose > ol { max-width: 72ch; }
.tc-prose pre { margin: 12px 0; padding: 16px 18px; border-radius: var(--tc-radius); background: var(--code-bg); color: var(--code-text); font-size: 12.5px; line-height: 1.75; overflow-x: auto; }
.tc-prose pre code { padding: 0; background: none; color: inherit; font-size: inherit; }
.tc-prose strong { color: var(--text); }
/* Code blocks: dark editor with language tabs + copy (P14) */
.tc-codeblock { margin: 14px 0; border: 0; border-radius: var(--tc-radius); background: var(--code-bg); box-shadow: none; }
.tc-codeblock__bar { gap: 4px; min-height: 48px; padding: 6px 8px 6px 12px; border-bottom: 1px solid rgba(255,255,255,.1); background: transparent; }
.tc-codeblock__tab { padding: 7px 12px; border-radius: 999px; font-family: var(--tc-font); font-size: 12px; color: #a6acb8; }
.tc-codeblock__tab.is-active { background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); color: #fff; }
.tc-codeblock__label { font-family: var(--tc-mono); font-size: 11px; color: #859bb3; }
.tc-codeblock__copy { padding: 7px 12px; border-radius: 999px; border-color: rgba(255,255,255,.16); font-family: var(--tc-font); font-size: 12px; transition: transform 150ms; }
.tc-codeblock__copy:active { transform: scale(.9); }
.tc-codeblock pre { font-family: var(--tc-mono); font-size: 12.5px; line-height: 1.8; color: var(--code-text); }
/* Tables scroll on phones; paths never wrap mid-word */
.tc-table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--border); border-radius: var(--tc-radius); }
.tc-table { font-size: 13px; }
.tc-table th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tc-table code { white-space: nowrap; }
.tc-method { display: inline-block; padding: 2px 7px; border-radius: 5px; font-family: var(--tc-mono); font-size: 10px; font-weight: 700; }
.tc-method--get { background: #e6f7ef; color: #047857; }
.tc-method--post { background: var(--tc-blue-50); color: var(--tc-blue-700); }
.tc-callout--note, .tc-callout--tip, .tc-callout--warn { border-radius: var(--tc-radius); }
.tc-apibar { top: calc(var(--header-h) + 8px); border-radius: 999px; }
.tc-apitool, .tc-apiempty { border-radius: var(--tc-radius); }
@media (max-width: 1023px) {
  .tc-docs { grid-template-columns: 1fr; }
  .tc-toc { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .tc-toc__title { width: 100%; margin-top: 8px !important; }
  .tc-docs-quick .tc-qlinks { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tc-docs-quick .tc-qlink:nth-child(2) { border-right: 0; }
  .tc-docs-quick .tc-qlink:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .tc-doc-main { padding: 0 18px 28px; }
  .tc-docs > .tc-doc-section { padding: 0 18px; }
  .tc-docs > .tc-doc-section:last-child { padding-bottom: 28px; }
  .tc-doc-section h2 { font-size: 20px; }
  .tc-docs-quick .tc-qlinks { grid-template-columns: 1fr; }
  .tc-docs-quick .tc-qlink { border-right: 0; border-bottom: 1px solid var(--border); min-height: 72px; }
  .tc-docs-quick .tc-qlink:last-child { border-bottom: 0; }
}
/* Legal: a disclosure-like TOC on phones, sticky on desktop (same markup as docs) */
.tc-legal .tc-toc a { font-size: 12.5px; }

/* Contact */
.contact-layout { gap: 0 !important; grid-template-columns: minmax(0,1.7fr) minmax(0,1fr) !important; }
.contact-panel { padding: 32px !important; border-right: 1px solid var(--border); }
.contact-panel h2 { font-size: 22px !important; }
.contact-aside { padding: 32px 28px; align-content: start; }
.tc-info-card { display: block; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--tc-radius); background: #fff; transition: background .15s, border-color .15s; }
.tc-info-card:hover { background: var(--tc-blue-50); border-color: var(--tc-blue-100); }
.tc-pagebody__tile:has(.contact-layout) { padding: 0; }
.tc-field label, .tc-field .tc-label { font-size: 12px; font-weight: 600; color: var(--muted); }
#contact-form button[type="submit"] .tc-spinner { margin-right: 4px; }
@media (max-width: 899px) { .contact-layout { grid-template-columns: 1fr !important; } .contact-panel { border-right: 0; border-bottom: 1px solid var(--border); } }
@media (max-width: 640px) { .contact-panel { padding: 22px 18px !important; } .contact-aside { padding: 22px 18px; } }

/* Settings */
.settings-stack { display: grid; gap: 20px; }
.settings-stack .tc-panel { border: 1px solid var(--border); border-radius: var(--tc-radius); box-shadow: none; background: #fff; }

/* Docs/legal sections are content inside one body tile (the old cards are flattened) */
.tc-doc-main { display: block; }
.tc-doc-section, .tc-doc-main > .tc-doc-section:first-child { padding: 32px 0 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
.tc-doc-section + .tc-doc-section { padding-top: 32px; }
.tc-docs-quick .tc-qlinks { width: 100%; max-width: none; }
.tc-callout { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; }
.tc-callout svg { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.tc-callout strong { margin-right: 3px; }
.tc-callout--note, .tc-callout--tip { border-color: var(--tc-blue-100); background: var(--tc-blue-50); color: #1c406c; }
.tc-callout--warn { border-color: #f5dfae; background: #fffaeb; color: #7a4d06; }
.contact-panel { box-shadow: none !important; border-radius: 0 !important; background: transparent !important; }
.tc-info-card { display: grid; gap: 4px; }
.tc-info-card .tc-ico { width: 40px; height: 40px; margin-bottom: 8px; border-radius: 10px; }
.tc-info-card .tc-ico svg { width: 20px; height: 20px; }
.tc-info-card strong, .tc-info-card h3 { font-size: 14px; }
.tc-info-card p, .tc-info-card span:not(.tc-ico) { font-size: 12.5px; color: var(--muted); }
.tc-docs > .tc-doc-section { padding: 32px 40px 0; }
@media (max-width: 640px) { .tc-docs > .tc-doc-section { padding: 24px 18px 0; } }

/* Settings (/settings/): each section is its own tile with a numbered eyebrow; same markup, ids and scripts. */
.tc-settings { counter-reset: tc-set; }
.settings-section { padding: 32px 36px; min-width: 0; }
.settings-section h2 { counter-increment: tc-set; font-size: 22px; letter-spacing: -.03em; margin: 0 0 6px; }
.settings-section h2::before { content: "// " counter(tc-set, decimal-leading-zero) " //"; display: block; margin-bottom: 10px; font-family: var(--tc-mono); font-size: 11px; font-weight: 500; letter-spacing: .06em; color: var(--accent); opacity: .7; }
.settings-section > p, .settings-heading p { max-width: 64ch; font-size: 14px; line-height: 1.7; color: var(--muted); }
.settings-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.account-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0; margin: 22px 0 0; border: 1px solid var(--border); border-radius: var(--tc-radius); overflow: hidden; }
.account-grid > div { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--border); }
.account-grid > div:last-child { border-right: 0; }
.account-grid dt { margin-bottom: 6px; font-family: var(--tc-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.account-grid dd { margin: 0; font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.account-grid .credit-total { font-size: 28px; font-weight: 800; letter-spacing: -.03em; color: var(--tc-blue-600); line-height: 1.1; }
.account-grid .tc-help { display: block; margin-top: 6px; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.settings-section .tc-table-wrap, #api-keys-container .tc-table { margin-top: 4px; }
#api-keys-container { min-width: 0; overflow-x: auto; }
#api-keys-container table { width: 100%; border-collapse: collapse; font-size: 13px; }
#api-keys-container th { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); text-align: left; font-family: var(--tc-mono); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
#api-keys-container td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
#api-keys-container tr:last-child td { border-bottom: 0; }
.api-key-hidden { font-family: var(--tc-mono); font-size: 12px; overflow-wrap: anywhere; color: var(--muted); }
.empty-state { padding: 36px 16px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--tc-radius); color: var(--muted); }
.empty-state h3 { margin: 12px 0 4px; font-size: 16px; color: var(--text); }
.empty-state p { margin: 0 0 16px; font-size: 13px; }
.settings-section .tc-lang-select { max-width: 320px; margin-top: 14px; }
.danger-zone { border-color: #f2c4c4; background: linear-gradient(180deg, #fffafa, #fff); }
.danger-zone h2, .danger-heading { color: var(--tc-danger); }
.danger-zone h2::before { color: var(--tc-danger); }
.danger-button { color: var(--tc-danger) !important; border-color: #f0c9c9 !important; background: #fff !important; }
.danger-button:hover { background: #fdf2f2 !important; border-color: var(--tc-danger) !important; }
/* Settings dialogs: same look as the format popup (fade + scale), shown by the existing script (display: flex) */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 1100; align-items: center; justify-content: center; padding: 16px; background: rgba(12,13,16,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: tc-overlay-in 180ms var(--tc-ease-out); }
.modal-content { width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; padding: 28px; border: 1px solid var(--tc-line); border-radius: var(--tc-radius-lg); background: #fff; box-shadow: 0 40px 80px -20px rgba(0,0,0,.45), 0 0 0 10px rgba(255,255,255,.06); animation: tc-dialog-in 220ms var(--tc-ease-out); }
.modal-content h3 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.03em; }
.modal-content p { font-size: 14px; line-height: 1.7; color: var(--muted); }
.modal-content .tc-field { display: grid; gap: 7px; margin: 18px 0; }
.modal-actions, .key-reveal { display: flex; flex-wrap: wrap; gap: 10px; }
.key-reveal { margin: 8px 0 18px; }
.key-reveal .tc-input { flex: 1; min-width: 0; font-family: var(--tc-mono); font-size: 12px; }
.modal-content ul { margin: 8px 0 0; padding-left: 18px; }
@keyframes tc-overlay-in { from { opacity: 0; } }
@keyframes tc-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.96); } }
.toast { display: none; position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 2000; max-width: calc(100vw - 32px); padding: 14px 18px; border: 1px solid var(--tc-line); border-radius: var(--tc-radius); background: #fff; box-shadow: 0 16px 40px -12px rgba(16,24,40,.25); font-size: 14px; }
.toast p { margin: 0; }
.toast.success { border-color: #b7e4cf; }
.toast.error { border-color: #f2c4c4; color: #9b1c1c; }
.loading-spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--tc-line); border-top-color: var(--tc-blue-600); border-radius: 50%; animation: tc-spin 1s linear infinite; }
@media (max-width: 900px) { .account-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .account-grid > div:nth-child(2) { border-right: 0; } .account-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); } }
@media (max-width: 640px) {
  .settings-section { padding: 24px 18px; }
  .account-grid { grid-template-columns: 1fr; }
  .account-grid > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .account-grid > div:last-child { border-bottom: 0; }
  .settings-heading { align-items: stretch; }
  .settings-heading .tc-btn { width: 100%; }
  #api-keys-container table { min-width: 560px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-content { max-width: none; border-radius: var(--tc-radius-lg) var(--tc-radius-lg) 0 0; padding: 24px 18px max(24px, env(safe-area-inset-bottom)); }
}
.api-key-hidden { white-space: nowrap; }

/* Docs overview steps: use the full column (not the 72ch prose measure), cards may shrink and their code wraps inside
   them, so nothing spills into the next card; every card fills its cell (full width, same width on phones). */
.tc-docs .tc-prose > ol.tc-steps { max-width: none; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
.tc-steps .tc-step { min-width: 0; display: flex; }
.tc-steps .tc-step > a { flex: 1; width: 100%; min-width: 0; box-sizing: border-box; }
.tc-steps .tc-step code { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
@media (max-width: 1199px) { .tc-docs .tc-prose > ol.tc-steps { grid-template-columns: 1fr; } }
/* Sections end on their content (the "Next: …" links are gone): no trailing margin, so every gap is the same */
.tc-doc-section > :last-child, .tc-doc-section > :last-child > :last-child { margin-bottom: 0; }
