header .name {
  font-size: 16.9px;
  line-height: 1.2;
  white-space: nowrap;
}
header nav { flex: 0 1 auto; }

.scrapbook-frame {
  --scale: 1;
  max-width: 1540px;
  margin-inline: auto;
}

.studio {
  width: 1540px;
  margin: 0;
  zoom: var(--scale);
}

body:not(.editing) .item { touch-action: auto; }
body:not(.editor-preview) .toggle { display: none; }

.item .movie { aspect-ratio: 16 / 9; }
.video-frame { position: relative; }
.video-play {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}
.video-play[hidden] { display: none; }
.video-play:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }
.video-play > span {
  display: grid;
  place-items: center;
  width: 58px;
  aspect-ratio: 1;
  border: 1px solid #fff9;
  border-radius: 50%;
  background: #201b19a6;
}
.video-play > span::after {
  content: "";
  margin-left: 4px;
  border-block: 9px solid transparent;
  border-left: 14px solid white;
}
.video-play:hover > span { background: #201b19e0; }
.play-status { margin-block: 8px; font-size: 13px; }

@media (min-width: 701px) and (max-width: 1199px) and (orientation: portrait) {
  body:not(.editor-preview) .item[data-id="p1"] { left: 6% !important; width: 59% !important; }
  body:not(.editor-preview) .item[data-id="n1"] { left: 72% !important; width: 26% !important; }
  body:not(.editor-preview) .item[data-id="p2"] { left: 45% !important; width: 47% !important; }
  body:not(.editor-preview) .item[data-id="poster"] { left: 8% !important; width: 34% !important; }
  body:not(.editor-preview) .item[data-id="n2"] { left: 52% !important; }
  body:not(.editor-preview) .item[data-id="v1"] { left: 24% !important; width: 68% !important; }
  .note { font-size: 26px; }
  .note.small { font-size: 20px; }
}

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  header {
    padding: 24px 18px;
    height: auto;
    min-height: 88px;
    flex-wrap: wrap;
    row-gap: 10px;
  }
  header .name { font-size: 15.6px; }
  header nav { gap: 12px; max-width: none; }
  .studio {
    width: auto;
    zoom: 1;
    display: flex;
    flex-direction: column;
    gap: 44px;
    padding: 20px 20px 60px;
    min-height: auto !important;
    overflow: visible;
  }
  .studio .item {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 0;
    margin: 0;
    transform: none !important;
    align-self: stretch;
    order: var(--mobile-order, 0);
  }
  .studio .item.note { font-size: 20px; }
  .studio .item.note.small { font-size: 15px; }
  .studio .item[data-kind="poster"] img { max-width: 480px; }
  .studio .drawing, .studio .hint, body.editor-preview .toggle { display: none; }
  .footer { margin-top: 0; }
}

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.85rem 4.4%;
  background: #e9e5da;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.admin-bar p { margin: 0.35rem 0 0; line-height: 1.5; }
.admin-bar a { color: inherit; text-underline-offset: 0.2em; }
.admin-mobile-help { display: none; }
.editing .video-play,
.editing .item[data-kind="video"] video { pointer-events: none; }

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .admin-help { display: none; }
  .admin-mobile-help { display: block; }
}

.note[data-font="serif"] { font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif; }
.note[data-font="sans"] { font-family: "Hiragino Sans", "Yu Gothic", Arial, sans-serif; font-style: normal; }
.note[data-font="rounded"] { font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif; font-style: normal; }
.note[data-font="mono"] { font-family: "IBM Plex Mono", Menlo, monospace; font-style: normal; }

#note-editor {
  width: min(29rem, calc(100% - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}
#note-editor::backdrop { background: #26262166; }
#note-editor h2 { margin: 0 0 1rem; font-size: 1.125rem; }
#note-editor label { display: grid; gap: 0.4rem; font-size: 0.875rem; }
#note-editor textarea, #note-editor select, #note-editor button {
  padding: 0.5rem;
  border: 1px solid #9b978f;
  border-radius: 4px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}
#note-editor textarea { resize: vertical; }
.note-format, .note-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.note-actions { justify-content: flex-end; }
#note-editor button[value="apply"] { background: var(--ink); color: white; }
.toolbar button:disabled { opacity: 0.45; cursor: default; }
#pen-settings:not([hidden]), #pen-settings label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
}
#pen-settings input[type="range"] { width: 80px; }
#pen-settings output { min-width: 2.5rem; }
.editing.drawing-mode .drawing { touch-action: none; }

.youtube-card, .item[data-kind="youtube"] iframe {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #292924;
  color: #f5f3eb;
}
.youtube-card button {
  padding: 0.55em 0.8em;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
}
.youtube-link { display: inline-block; margin-top: 0.5em; color: var(--ink); font-size: 0.875rem; }
.editing .youtube-card button,
.editing .item[data-kind="youtube"] iframe,
.editing .item[data-kind="youtube"] .youtube-link { pointer-events: none; }

.editing .item:hover::before, .editing .item.selected::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -12px;
  left: 8px;
  width: 26px;
  height: 21px;
  border: 1px solid #aaa198;
  border-radius: 5px;
  background: repeating-linear-gradient(to bottom, #777064 0 1px, transparent 1px 4px)
    center / 12px 9px no-repeat, #faf9f4;
  cursor: grab;
}
.editing.drawing-mode .item::before { display: none; }
.editing.archive-move .item:not([data-latest-post]) { cursor: ns-resize; }
.editing.archive-move .item:not([data-latest-post]) .handle { display: none; }
.editing.archive-move .item:not([data-latest-post])::before { cursor: ns-resize; }
#move-archive[aria-pressed="true"] { background: #e9e5da; border-color: #e9e5da; color: #292924; }

.scrapbook-frame {
  width: var(--layout-width, 100%);
  max-width: var(--layout-max-width, 1540px);
}
.layout-size { display: flex; align-items: center; gap: 0.45rem; font-size: 12px; }
.layout-size input { width: 84px; }
.layout-size output { min-width: 2.7rem; }
.hint {
  margin: 0;
  color: #736e61;
  font: italic 17px/1.3 Georgia, "Times New Roman", serif;
  letter-spacing: 0.025em;
}
.note[data-font="jp-yumincho"] { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-style: normal; }
.note[data-font="jp-yugothic"] { font-family: "Yu Gothic", "Hiragino Sans", sans-serif; font-style: normal; }
.note[data-font="en-georgia"] { font-family: Georgia, "Yu Mincho", serif; font-style: normal; }
.note[data-font="en-baskerville"] { font-family: Baskerville, "Yu Mincho", serif; font-style: normal; }
.note[data-font="en-helvetica"] { font-family: Helvetica, Arial, "Hiragino Sans", sans-serif; font-style: normal; }
.note[data-font="en-avenir"] { font-family: Avenir, "Hiragino Sans", sans-serif; font-style: normal; }
.note[data-font="en-palatino"] { font-family: Palatino, "Yu Mincho", serif; font-style: normal; }

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .scrapbook-frame { width: 100%; max-width: 100%; }
  .studio .hint { display: block !important; position: static; order: -1; }
}

/* In the editor, keep the selection and resize handle close to the text. */
body.editor-preview .studio .item.note {
  width: max-content !important;
  min-width: 0 !important;
  max-width: 90%;
  overflow-wrap: anywhere;
}

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  body.editor-preview .studio .item.note { width: 100% !important; }
}

.inline-note {
  min-width: 1em;
  min-height: 1lh;
  cursor: text;
  user-select: text;
  touch-action: auto;
  outline: none;
}

.youtube-card { position: relative; overflow: hidden; }
.youtube-card > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.youtube-card > button { position: relative; z-index: 1; }
#new-post { max-width: min(420px, 90vw); padding: 24px; }
#new-post label { display: grid; gap: 6px; }
#new-post input, #new-post textarea { max-width: 100%; font: inherit; }

header .site-title { margin: 0; }
.site-subtitle { display: block; margin-top: 4px; font: italic 0.8em/1.2 Georgia, serif; color: #6e695e; letter-spacing: 0.02em; }

body .studio .item.note[data-vertical] {
  width: max-content !important;
  min-width: 0;
  max-width: 90%;
}
.note[data-vertical] > :is(.note-copy, .inline-note) {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  inline-size: max-content;
  min-inline-size: 1em;
  max-inline-size: 22em;
  max-block-size: 100%;
  overflow-wrap: anywhere;
  overflow-x: auto;
}

.note[data-font="shippori-mincho"],
:is(#note-editor, #new-post) .note-input[data-font="shippori-mincho"] {
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-style: normal;
}

.note[data-font="biz-ud-mincho"],
:is(#note-editor, #new-post) .note-input[data-font="biz-ud-mincho"] {
  font-family: "BIZ UDMincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-style: normal;
}
