* {
  box-sizing: border-box;
}

:root {
  --text: #242424;
  --muted: #777;
  --border: #dedede;
  --background: #ffffff;
  --code: #f6f6f6;
  --accent: #111;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.page {
  position: relative;
  min-height: 100vh;
}

.markdown {
  width: min(720px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 96px 0 96px;
  font-size: 17px;
  line-height: 1.72;
  display: flex;
  flex-direction: column;
  transition: filter 0.35s ease, opacity 0.35s ease;
}

.markdown.locked {
  filter: blur(9px);
  opacity: 0.38;
  user-select: none;
  pointer-events: none;
}

h1,
h2 {
  line-height: 1.25;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 6vw, 48px);
  letter-spacing: -0.035em;
}

h2 {
  margin: 48px 0 14px;
  font-size: 25px;
  letter-spacing: -0.02em;
}

p,
ul,
blockquote,
pre,
img {
  margin-top: 20px;
  margin-bottom: 20px;
}

.markdown p {
  white-space: pre-line;
  line-height: 1.35;
}

.centered-text {
  text-align: center;
  font-weight: 700;
}

.meta {
  margin-top: 0;
  color: var(--muted);
  font-size: 14px;
}

blockquote {
  margin-left: 0;
  padding-left: 18px;
  border-left: 3px solid var(--border);
  color: #555;
}

ul {
  padding-left: 24px;
}

img {
  display: block;
  width: min(75%, 520px);
  max-height: 380px;
  margin: auto auto 0;
  object-fit: cover;
}

pre {
  overflow-x: auto;
  padding: 18px 20px;
  border: 1px solid #ececec;
  border-radius: 6px;
  background: var(--code);
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gate.hidden {
  opacity: 0;
  visibility: hidden;
}

.gate-box {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.08);
}

.gate-box label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
}

.row {
  display: flex;
  gap: 8px;
}

input,
button {
  font: inherit;
}

input {
  min-width: 0;
  flex: 1;
  padding: 11px 12px;
  border: 1px solid #ccc;
  border-radius: 5px;
  outline: none;
}

input:focus {
  border-color: #777;
}

button {
  border: 0;
  cursor: pointer;
}

.row button {
  padding: 11px 16px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
}

.message {
  min-height: 20px;
  margin: 10px 0 0;
  color: #b42318;
  font-size: 14px;
}

.audio-button {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 20;
  width: 52px;
  height: 52px;
  border: 2px solid #111;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-size: 21px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.audio-button.playing {
  background: #111;
  color: #fff;
  transform: scale(1.06);
}

@media (max-width: 560px) {
  .page {
    padding: 0 16px;
  }

  .markdown {
    width: 100%;
    min-height: 100svh;
    padding: 88px 0 40px;
    font-size: 16px;
  }

  h1 {
    margin-bottom: 4px;
    font-size: clamp(28px, 9vw, 40px);
  }

  .markdown p {
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  img {
    width: min(100%, 420px);
    max-height: 300px;
    margin-top: 24px;
  }

  .gate {
    padding: 16px;
  }

  .gate-box {
    padding: 20px;
  }

  .row {
    flex-direction: column;
  }

  .row button {
    width: 100%;
  }

  .audio-button {
    right: 16px;
    top: calc(16px + env(safe-area-inset-top));
  }
}
