html {
  overscroll-behavior-y: none;
}

/* no rubber-band bounce revealing the paper's end */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#top {
  position: sticky;
  top: 0;
  z-index: 1;
}

#bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 16px;
  background: var(--bar);
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

#bar button,
#bar input {
  font: inherit;
  font-size: 14px;
  height: 30px;
  border: 1px solid transparent;
  background: none;
  border-radius: 4px;
  color: inherit;
}

#bar button {
  min-width: 30px;
  padding: 0 6px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

#bar button:hover,
#bar button[aria-expanded="true"] {
  background: var(--hover);
}

#bar button[aria-pressed="true"] {
  background: var(--on-bg);
  color: var(--on-fg);
}

#bar :focus-visible {
  outline: 2px solid var(--on-fg);
  outline-offset: 1px;
}

.sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 6px;
}

.dd {
  position: relative;
  display: flex;
  align-items: center;
}

#bar .dd-btn {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 150px;
  padding: 0 8px;
  text-align: left;
}

#bar .dd-btn span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dd-btn::after,
.size-box::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
  opacity: .6;
}

.size-box {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: text;
}

.size-box:hover {
  background: var(--hover);
}

#bar .size-box input {
  width: 32px;
  padding: 0 0 0 8px;
  text-align: center;
  border: 0;
  outline: none;
  background: none;
}

.size-box::after {
  pointer-events: none;
}

.menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  background: var(--bar);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 2;
}

.menu [role="option"] {
  padding: 6px 14px 6px 30px;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  font-size: 15px;
}

.menu .active {
  background: var(--hover);
}

.menu [aria-selected="true"] {
  color: var(--on-fg);
}

.menu [aria-selected="true"]::before {
  content: "✓";
  position: absolute;
  left: 10px;
  font-family: system-ui, sans-serif;
}

#editor {
  flex: 1;
  align-self: center;
  width: 100%;
  max-width: 816px;
  margin-top: 24px;
  padding: 72px 72px;
  box-sizing: border-box;
  background: var(--paper);
  color: var(--text);
  outline: none;
  font-family: Arial, sans-serif;
  font-size: 12pt;
  line-height: 1.5;
  white-space: pre-wrap;
  tab-size: 0.5in;
  /* half-inch stops like Word/Docs */
  box-shadow: 0 1px 3px var(--shadow);
}

#editor ul {
  margin: 0;
  padding-left: 1.5em;
}

@media (max-width: 600px) {
  #editor {
    margin: 0;
    padding: 24px 16px;
  }
}


/* Keep text steady during theme changes while surfaces continue to fade. */
.theming #bar,
.theming #bar *,
.theming #editor,
.theming #editor * {
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease !important;
}

@page {
  margin: 1in;
}

@media print {
  #top {
    position: static;
  }

  #bar {
    display: none;
  }

  body,
  #editor {
    background: #fff;
    color: #000;
  }

  #editor {
    margin: 0;
    padding: 0;
    max-width: none;
    box-shadow: none;
  }
}
