/* Palette and type stack come from /tokens.css (single source of truth). */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

a { color: var(--teal); }

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 20px 8px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* ---- shared tool bar (spec: SHARED-TOOLBAR-SPEC.md at the repo root) ------ */
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 10;
  background: var(--panel); color: var(--ink); border: 1px solid var(--teal);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }
/* The bar sits on the site chrome column (1180px), constant on every tool
   page regardless of the tool's own content width, so the lockup lands in
   the same place as the homepage nav and DropCheck's bar. */
.tool-bar { display: block; max-width: 1180px; margin: 0 auto; width: 100%; padding: 16px clamp(20px, 5vw, 80px) 0; }
.tb-crumb { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.tb-crumb a { color: var(--muted); text-decoration: none; }
.tb-crumb a:hover, .tb-crumb a:focus-visible { color: var(--teal); }
.tb-brand { display: flex; align-items: center; gap: 8px; }
.tb-brand svg { display: block; flex: 0 0 auto; }
.tb-brand b { font-size: 12.5px; font-weight: 700; letter-spacing: .03em; color: var(--ink); }
.tb-brand span { color: var(--muted); font-weight: 400; }
.tb-brand:hover b, .tb-brand:focus-visible b { color: var(--teal); }
.tb-sep { opacity: .6; }
.tb-here { color: var(--ink); }
.tb-row { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin-top: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--hair); }
.tb-wordmark { margin: 0; font-size: 22px; letter-spacing: .02em; }
.tb-tools { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.tb-tools a { color: var(--muted); font-size: 12.5px; text-decoration: none; }
.tb-tools a:hover, .tb-tools a:focus-visible { color: var(--teal); }
.tb-badge {
  margin-left: auto; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}
.tb-badge.tb-ai { color: var(--teal); border-color: rgba(0, 212, 200, .4); }
.tb-badge.tb-file { color: var(--ok); border-color: rgba(79, 209, 139, .4); }
.tool-tagline { max-width: 1180px; margin: 10px auto 0; padding: 0 clamp(20px, 5vw, 80px); color: var(--muted); font-size: 13px; width: 100%; }
@media (max-width: 640px) {
  .tb-badge { margin-left: 0; }
  .tb-wordmark { font-size: 19px; }
}

.monogram { flex: 0 0 auto; display: block; line-height: 0; }
.monogram svg { width: 76px; height: 58px; }

.head-text h1 { margin: 0; font-size: 22px; letter-spacing: .02em; }
.head-text p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

textarea {
  width: 100%;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 15px;
  resize: vertical;
  min-height: 96px;
}
textarea:focus { outline: none; border-color: var(--teal); }
textarea::placeholder { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
}
.chip:hover, .chip:focus-visible { border-color: var(--gold); color: var(--gold); }

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

#generate {
  background: var(--teal);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 11px 28px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
#generate:hover:not(:disabled) { filter: brightness(1.1); }
#generate:disabled { opacity: .45; cursor: default; }

#charcount { color: var(--muted); font-size: 12px; }

.quota-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.diagram-note {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.export-caption {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.status.error { border-color: rgba(255, 181, 71, .5); color: var(--gold); }
.status.limit { border-color: rgba(255, 181, 71, .5); color: var(--gold); }

.loader-trace { flex: 0 0 auto; }
.loader-trace path {
  stroke-dasharray: 70 250;
  stroke-dashoffset: 320;
  animation: route 1.6s linear infinite;
}
.loader-trace rect { animation: blink 1.6s ease-in-out infinite; }
@keyframes route { to { stroke-dashoffset: 0; } }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .loader-trace path { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
  .loader-trace rect { animation: none; opacity: .7; }
}

#result { margin-top: 22px; }
#diagram-title { font-size: 17px; margin: 0 0 10px; color: var(--ink); }
#diagram svg { display: block; width: 100%; height: auto; }

.exports { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.ghost {
  background: transparent;
  border: 1px solid var(--teal);
  color: var(--teal);
  border-radius: 8px;
  padding: 9px 20px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}
.exports .ghost { margin-top: 0; }
.ghost:hover { background: rgba(0, 212, 200, .08); }

/* fullscreen diagram viewer (Expand button): pan/pinch/zoom surface */
.ehc-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 14, 26, .97);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.ehc-overlay:active { cursor: grabbing; }
.ehc-overlay-stage { position: absolute; top: 0; left: 0; will-change: transform; }
.ehc-overlay-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  background: var(--panel);
  border: 1px solid var(--teal);
  color: var(--teal);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}
.ehc-overlay-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  pointer-events: none;
}

button:focus-visible, a:focus-visible, .chip:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

footer {
  padding: 18px 20px 26px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
footer a { color: var(--teal); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 16px; }
  .head-text h1 { font-size: 19px; }
  .actions { flex-direction: column; align-items: stretch; gap: 8px; }
  #generate { width: 100%; }
  #charcount { text-align: right; }
}
