
:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --line: #dddddd;
  --accent: #111111;
  --danger: #9f1d20;
  --surface: #fafafa;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  width: min(100% - 32px, 780px);
  margin: 0 auto;
  padding: 28px 0 56px;
}

nav {
  display: flex;
  gap: 18px;
  align-items: baseline;
  margin-bottom: 26px;
  font-size: 0.88rem;
}

.brand {
  color: var(--fg);
  font-weight: 700;
}

.about-link { color: var(--muted); }

form {
  display: grid;
  gap: 14px;
}

textarea {
  width: 100%;
  min-height: min(64vh, 680px);
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
  color: var(--fg);
  padding: 16px;
  font: inherit;
  line-height: 1.45;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

button {
  justify-self: start;
  border: 1px solid var(--fg);
  border-radius: 0;
  background: var(--fg);
  color: var(--bg);
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

button:active {
  background: var(--muted);
  border-color: var(--muted);
}

.error {
  margin: 0 0 18px;
  color: var(--danger);
}

.markdown { overflow-wrap: break-word; }
.markdown > *:first-child { margin-top: 0; }

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.15;
  margin: 1.7em 0 0.55em;
}

.markdown h1 { font-size: 2rem; }
.markdown h2 { font-size: 1.45rem; }
.markdown h3 { font-size: 1.15rem; }

.markdown pre,
.markdown code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.markdown pre {
  overflow: auto;
  border-left: 3px solid var(--line);
  background: var(--surface);
  padding: 12px 14px;
}

.markdown blockquote {
  margin-left: 0;
  padding-left: 18px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.markdown img { max-width: 100%; }

.markdown ul,
.markdown ol { padding-left: 1.35em; }

.markdown li + li { margin-top: 0.18em; }
.markdown .contains-task-list { padding-left: 1.1em; }
.markdown .task-list-item { list-style: none; }

.markdown .task-list-item-checkbox {
  margin: 0 0.45em 0 -1.1em;
  accent-color: var(--fg);
  pointer-events: none;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
}

.markdown th,
.markdown td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px 6px 0;
  text-align: left;
}

.mermaid-diagram {
  position: relative;
  margin: 1.45rem 0;
  border: 1px solid var(--line);
  background: #ffffff;
}

.mermaid-source { margin: 0; }

.mermaid-frame {
  position: relative;
  height: clamp(260px, 56vh, 620px);
  overflow: hidden;
  background: #ffffff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.mermaid-frame:active { cursor: grabbing; }
.mermaid-frame.is-grabbing { cursor: grabbing; }

.mermaid-frame:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.mermaid-open,
.mermaid-close {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  padding: 4px 8px;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: pointer;
}

.mermaid-open {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.mermaid-open:hover,
.mermaid-close:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.mermaid-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  user-select: none;
}

.mermaid-content svg {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}

.mermaid-error {
  padding: 12px 14px;
  color: var(--muted);
}

.mermaid-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #ffffff;
}

.mermaid-fullscreen[hidden] { display: none; }

.mermaid-fullscreen-bar {
  display: flex;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.mermaid-fullscreen-frame {
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.mermaid-fullscreen-frame:active { cursor: grabbing; }
.mermaid-fullscreen-frame.is-grabbing { cursor: grabbing; }

@media (max-width: 520px) {
  html { font-size: 16px; }

  .shell {
    width: min(100% - 24px, 780px);
    padding-top: 18px;
  }

  textarea {
    min-height: 68vh;
    padding: 12px;
  }
}
