:root {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #1c241d;
  background: #f3f5f1;
  font-synthesis: none;
  --ink: #1c241d;
  --muted: #5a675d;
  --border: #dce2db;
  --accent: #d6f499;
  --accent-ink: #24370e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }

button {
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 37px;
  padding: 7px 12px;
  cursor: pointer;
}

button:not(:disabled):hover { border-color: #90a38e; background: #f4f7f1; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible { outline: 2px solid #367442; outline-offset: 3px; }
button.primary { color: var(--accent-ink); background: var(--accent); border-color: #bee281; }
button.primary:not(:disabled):hover { background: #c7ec80; border-color: #8eab64; }
.wide { width: 100%; }
.muted { color: var(--muted); font-size: .875rem; line-height: 1.5; }

.app-header {
  min-height: 66px;
  padding: 12px max(22px, calc((100vw - 1500px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #f4f7f2;
  background: #151b15;
}

.brand { display: flex; align-items: center; gap: 6px; font-size: 1rem; font-weight: 690; }
.brand > span:last-child { color: #c2cbbf; font-weight: 400; }
.brand-mark {
  display: grid;
  place-items: center;
  margin-right: 4px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 800;
}

.privacy { font-size: .875rem; color: #d3dcd1; }
main { max-width: 1544px; margin: auto; padding: 29px 22px 30px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.intro h1 { font-size: clamp(1.85rem, 4vw, 2.8rem); font-weight: 740; letter-spacing: -.045em; line-height: 1.13; }
.intro p { margin-top: 8px; color: var(--muted); line-height: 1.45; }
.intro button { min-height: 44px; min-width: 124px; white-space: nowrap; }
.notice { margin-bottom: 14px; padding: 9px 13px; border-radius: 7px; background: #e4efd8; color: #2e4523; }
.notice.error { background: #f8e7e2; color: #812e25; }

.workspace {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 265px;
  min-height: 560px;
  height: calc(100dvh - 206px);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.pages, .viewer, .settings { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pages { border-right: 1px solid var(--border); }
.settings { border-left: 1px solid var(--border); }
.panel-header, .toolbar {
  display: flex;
  align-items: center;
  min-height: 57px;
  padding: 8px 14px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.panel-header { justify-content: space-between; }
.panel-header h2, .edit-actions h3 { font-size: .95rem; font-weight: 700; }
#page-count { color: var(--muted); font-size: .85rem; }
#empty-pages { padding: 14px; }
.thumbnails { display: grid; align-content: start; gap: 10px; padding: 12px; overflow: auto; }
.thumbnail { display: grid; justify-items: center; align-content: center; gap: 7px; min-height: 114px; padding: 8px; background: #f4f6f3; }
.thumbnail[aria-current='true'] { background: #e9f3df; border-color: #7ba064; color: #254024; }
.thumbnail canvas { width: auto; height: auto; max-width: 95px; max-height: 100px; background: #fff; }
.page-label { font-size: .78rem; }
.filename { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 650; }
.toolbar button { padding-inline: 9px; }
.zoom { display: flex; align-items: center; gap: 4px; }
.zoom output { width: 45px; text-align: center; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; padding: 22px 17px; background: #e8ece7; scrollbar-gutter: stable both-edges; }
.viewer-body.dragging { box-shadow: inset 0 0 0 3px #79a365; }
.drop-zone {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 100%;
  gap: 12px;
  padding: 22px;
  text-align: center;
  border-radius: 12px;
  border: 1px dashed #aab9a8;
  background: #f3f6f2;
}

.file-icon { display: grid; place-items: center; width: 54px; height: 62px; margin-bottom: 3px; color: #36553b; background: #e0ebde; border: 1px solid #c1d3be; border-radius: 8px; font-size: .8rem; font-weight: 750; }
.drop-zone h2 { font-size: 1.35rem; letter-spacing: -.025em; }
.drop-zone p { color: var(--muted); line-height: 1.45; }
.drop-zone .primary { margin-top: 6px; min-width: 112px; }
.sheet { position: relative; margin: 0 auto; background: white; box-shadow: 0 3px 14px #25392926; }
.sheet > canvas { display: block; position: absolute; width: 100%; height: 100%; }
.placements { position: absolute; inset: 0; }
.placement, .placement:not(:disabled):hover { position: absolute; padding: 0; min-height: 0; border: 0; border-radius: 0; background: transparent; touch-action: none; user-select: none; cursor: grab; }
.placement:active { cursor: grabbing; }
.placement.selected { outline: 2px solid #438251; z-index: 1; }
.placement img { display: block; width: 100%; height: 100%; pointer-events: none; }
.resize-handle { display: none; position: absolute; right: 0; bottom: 0; width: 24px; height: 24px; transform: translate(50%, 50%); place-items: center; cursor: nwse-resize; }
.placement.selected .resize-handle { display: grid; }
.resize-handle::before { content: ''; width: 12px; height: 12px; background: #438251; border: 1px solid white; border-radius: 3px; }

.settings-body { display: grid; gap: 10px; padding: 14px; overflow: auto; }
.signature-preview { display: grid; place-items: center; min-height: 102px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #f5f7f4; }
.signature-preview img { max-width: 100%; max-height: 86px; object-fit: contain; }
.saved-actions { display: grid; gap: 6px; }
.saved-actions button { min-height: 34px; border-color: transparent; text-align: left; color: #38613a; }
.edit-actions { padding-top: 14px; margin-top: 3px; border-top: 1px solid var(--border); }
.edit-actions p { margin: 6px 0 10px; }
.edit-size { display: flex; gap: 6px; }
.edit-size button { min-width: 39px; }
.danger { color: #8c362d; margin-left: auto; }

@media (max-width: 920px) {
  .workspace { grid-template-columns: 125px minmax(0, 1fr) 210px; }
  .panel-header, .toolbar, .settings-body { padding-inline: 10px; }
}

@media (max-width: 700px) {
  .app-header { padding-inline: 14px; }
  .privacy { font-size: .75rem; }
  main { padding: 18px 12px 24px; }
  .intro { align-items: start; gap: 8px; }
  .intro button { min-width: auto; }
  .intro p { font-size: .9rem; }
  .workspace { display: flex; height: auto; flex-direction: column; }
  .pages, .settings { border: 0; }
  .pages { border-bottom: 1px solid var(--border); }
  .settings { border-top: 1px solid var(--border); }
  .thumbnails { display: flex; padding: 8px; gap: 6px; }
  .thumbnails:empty { display: none; }
  .thumbnail { min-width: 75px; min-height: 66px; padding: 5px; gap: 4px; }
  .thumbnail canvas { max-width: 59px; max-height: 50px; }
  .viewer { height: 51dvh; min-height: 320px; }
  .viewer-body { padding: 12px; }
  .panel-header, .toolbar { min-height: 46px; }
}
