:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #202322;
  --muted: #69706d;
  --line: #d9ded9;
  --accent: #19705a;
  --accent-strong: #0d5846;
  --danger: #b3261e;
  --sheet: #f1f3f1;
  --slot: #dce3de;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
}

h2 {
  font-size: 15px;
}

.topbar p,
.status,
.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.actions,
.pdf-actions {
  display: flex;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.sheet-wrap {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 14px;
  background: #e8ece8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sheet {
  width: min(100%, 720px);
  aspect-ratio: 595 / 842;
  height: auto;
  background: white;
  border-radius: 2px;
  box-shadow: 0 10px 28px rgba(25, 30, 28, 0.16);
}

.panel {
  display: grid;
  gap: 12px;
}

.panel-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.ghost {
  border-color: var(--line);
}

.button.full {
  width: 100%;
}

.button:disabled,
.button.disabled,
.tool:disabled,
input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button input {
  display: none;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: var(--slot);
  padding: 0;
  cursor: pointer;
}

.thumb.active {
  border-color: var(--accent);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .remove {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.thumb.dragging {
  opacity: 0.6;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tool {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.control {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 700;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.toggle.compact {
  margin: 0 0 12px;
}

.edit-title-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle.inline {
  margin: 0;
  gap: 6px;
  font-size: 13px;
}

.toggle.inline input {
  width: 16px;
  height: 16px;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 10px;
  align-items: center;
}

.number-input {
  width: 78px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 14px;
  text-align: right;
}

.pdf-actions {
  flex-direction: column;
  margin-top: 10px;
}

.status {
  margin-top: 12px;
  line-height: 1.45;
}

.preview-section {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.preview-section iframe {
  width: 100%;
  height: min(72vh, 760px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
}

.footer-inner {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-inner a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.terms-page {
  width: min(860px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.terms-header {
  margin-bottom: 22px;
}

.terms-header a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.terms-header h1 {
  margin-top: 16px;
}

.terms-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 34px);
}

.terms-content h2 {
  margin: 28px 0 8px;
  font-size: 17px;
}

.terms-content h2:first-child {
  margin-top: 0;
}

.terms-content p,
.terms-content li {
  color: var(--text-secondary, #4a5568);
  font-size: 14px;
  line-height: 1.85;
}

.terms-content ul {
  padding-left: 1.3em;
}

.terms-date {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  .app {
    width: min(100vw - 20px, 680px);
    padding-top: 12px;
  }

  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 25px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sheet-wrap {
    padding: 8px;
  }

  .panel {
    gap: 10px;
  }

  .footer-inner {
    width: min(100vw - 20px, 680px);
    min-height: auto;
    padding: 18px 0;
    align-items: flex-start;
    flex-direction: column;
  }
}
