:root {
  color-scheme: light;
  --bg: #f3f7f5;
  --panel: #fff;
  --ink: #17231f;
  --muted: #53665d;
  --line: #d8e4dd;
  --tint: #e2f5ee;
  --brand: #075e54;
  --on: #fff;
  font:
    16px/1.45 "Segoe UI",
    Arial,
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111d19;
  --panel: #1b2a24;
  --ink: #edf7f2;
  --muted: #b6c8bf;
  --line: #374b41;
  --tint: #254637;
  --brand: #85dbc0;
  --on: #0c2920;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
}
header,
.bar,
.foot,
.tools,
.styles,
.pageActions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
header {
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 64px;
}
.grow {
  flex: 1;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.45rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 750;
  letter-spacing: -0.05em;
}
.logo img {
  width: 32px;
}
.logo + span {
  padding-left: 1rem;
  border-left: 1px solid var(--line);
  margin-left: 0.6rem;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 32vw;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0.48rem 0.7rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
button:hover,
button[aria-pressed="true"],
.current {
  background: var(--tint);
  border-color: var(--brand);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on);
}
.primary:hover {
  background: var(--brand);
  filter: brightness(1.13);
}
:focus-visible {
  outline: 3px solid #258bd4;
  outline-offset: 2px;
}
#welcome {
  min-height: 80dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.opening {
  background: var(--panel);
  border: 2px dashed var(--line);
  border-radius: 24px;
  text-align: center;
  padding: clamp(2rem, 7vw, 5rem);
  max-width: 620px;
}
.opening h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.05em;
  margin: 0.7rem 0;
}
.opening p,
#hint,
#fontResult {
  color: var(--muted);
}
.drag .opening {
  border-color: var(--brand);
  background: var(--tint);
}
#workspace {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) 245px;
  height: calc(100dvh - 65px);
}
aside,
.bar,
.foot {
  background: var(--panel);
}
aside {
  padding: 1rem;
  overflow: auto;
}
aside h2 {
  font-size: 1rem;
  letter-spacing: -0.02em;
  margin: 0.1rem 0 1rem;
}
.pages {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}
#thumbnails {
  overflow: auto;
  flex: 1;
}
.thumb {
  display: grid;
  gap: 0.25rem;
  place-items: center;
  width: 100%;
  margin-bottom: 0.5rem;
  color: var(--muted);
}
.thumb canvas {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
}
.pageActions {
  flex-wrap: wrap;
  margin-top: 8px;
}
.stage {
  display: flex;
  min-height: 0;
  flex-direction: column;
  min-width: 0;
}
.bar,
.foot {
  padding: 0.55rem;
  flex-wrap: wrap;
}
.bar {
  border-bottom: 1px solid var(--line);
}
.foot {
  border-top: 1px solid var(--line);
}
#scroller {
  overflow: auto;
  flex: 1;
  padding: 24px;
  position: relative;
  overscroll-behavior: contain;
}
#paper {
  margin: auto;
  position: relative;
  background: white;
  box-shadow: 0 4px 18px #00180e24;
  isolation: isolate;
}
#paper > canvas,
#paper > .hits {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hit {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: transparent;
  min-width: 3px;
  min-height: 3px;
}
.hit:hover,
.hit.selected {
  background: #2994e51a;
  outline: 1.5px solid #167cc8;
}
.mode-add .hits {
  cursor: crosshair;
}
.mode-add .hit,
.mode-pan .hit {
  pointer-events: none;
}
.mode-pan {
  cursor: grab;
  touch-action: none;
}
.properties {
  border-left: 1px solid var(--line);
}
label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.84rem;
  font-weight: 600;
}
#props {
  display: grid;
  gap: 0.8rem;
}
input:not([type="checkbox"]),
select {
  min-width: 0;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.44rem;
}
input[type="color"] {
  height: 36px;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.styles {
  flex-wrap: wrap;
}
.styles label,
.check {
  display: flex;
  align-items: center;
}
.styles label {
  font-size: 0.78rem;
}
.check input,
.styles input {
  accent-color: var(--brand);
}
#fontResult,
#hint {
  font-size: 0.85rem;
}
#notice {
  position: fixed;
  bottom: 1.15rem;
  left: 50%;
  transform: translateX(-50%);
  background: #17362c;
  color: white;
  padding: 0.75rem 1.2rem;
  border-radius: 12px;
  box-shadow: 0 4px 18px #0003;
  max-width: 90vw;
  width: max-content;
  z-index: 6;
}
dialog {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem;
  max-width: min(90vw, 440px);
}
dialog::backdrop {
  background: #071d1766;
}
dialog h2 {
  margin-top: 0;
}
#zoom,
#pageNumber {
  font-size: 0.85rem;
}
@media (max-width: 900px) {
  #workspace {
    grid-template-columns: minmax(0, 1fr) 220px;
  }
  .pages {
    display: none;
  }
  .stage {
    grid-column: 1;
  }
}
@media (max-width: 640px) {
  header {
    padding: 0.5rem;
    gap: 0.2rem;
  }
  .logo + span {
    max-width: 16vw;
    padding: 0;
    border: 0;
    margin: 0;
  }
  .logo {
    font-size: 1.15rem;
  }
  .logo img {
    width: 25px;
  }
  .tools {
    gap: 0.15rem;
  }
  header button {
    padding: 0.35rem;
  }
  .tools .primary {
    font-size: 0.75rem;
  }
  #workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - 64px);
  }
  .stage {
    height: 60dvh;
  }
  .properties {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .bar {
    gap: 0.2rem;
  }
  .bar button {
    font-size: 0.78rem;
    padding: 0.4rem;
  }
  .bar .grow {
    display: none;
  }
  #scroller {
    padding: 12px;
  }
  .properties form {
    max-width: 500px;
  }
  #notice {
    bottom: 0.5rem;
  }
}
