:root {
  --header-bg: #347a76;
  --text: #050505;
  --paper-bg: #f4e6bd;
  --control-bg: rgba(52, 122, 118, 0.5);
  --button-teal: #2f7b79;
  --button-magenta: #98225f;
  --reset-gray: #77736f;
  --field-bg: #e8ecec;
  --field-border: #c8c8c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  background-color: var(--paper-bg);
  background-image: url("../../paper.png");
  background-repeat: repeat;
  background-size: 512px 512px;
}

button,
select {
  font: inherit;
}

.site-header {
  min-height: 100px;
  padding: 12px 56px;
  background: var(--header-bg);
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(120px, 1fr) 52px;
  align-items: center;
  gap: 28px;
}

.brand-block {
  min-width: 0;
}

.logo-link {
  display: block;
  width: min(230px, 100%);
}

.logo {
  display: block;
  width: 100%;
  height: auto;
}

.ad-space {
  height: 1px;
  background: transparent;
}

.help-button {
  width: 48px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  justify-self: end;
  color: var(--header-bg);
  background: #fff;
  text-decoration: none;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 44px;
  padding: 31px 36px 72px;
}

.tool-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 290px;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.primary-button,
.save-button {
  width: 100%;
  min-height: 51px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  cursor: pointer;
  font-size: clamp(22px, 1.7vw, 27px);
  line-height: 1.1;
}

.primary-button {
  background: var(--button-teal);
}

.save-button {
  margin-top: -4px;
  background: var(--button-magenta);
}

.width-card {
  position: relative;
  min-height: 450px;
  padding: 14px 29px 8px;
  border-radius: 8px;
  background: var(--control-bg);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.reset-button {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--reset-gray);
  cursor: pointer;
  font-size: clamp(20px, 1.5vw, 25px);
}

.width-label {
  margin: 0 0 8px;
  text-align: center;
  font-size: clamp(22px, 1.7vw, 27px);
  line-height: 1.1;
}

.select-wrap {
  display: block;
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 29px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 18px solid #000;
  pointer-events: none;
  transform: translateY(-40%);
}

#widthSelect,
#slantSelect,
#textureScaleSelect,
.texture-select-button {
  width: 100%;
  min-height: 44px;
  padding: 0 62px 0 20px;
  border: 2px solid var(--field-border);
  border-radius: 11px;
  color: #000;
  background: var(--field-bg);
  appearance: none;
  text-align: center;
  font-size: clamp(23px, 1.7vw, 29px);
  cursor: pointer;
}

.texture-select {
  position: relative;
  margin-top: 10px;
}

.texture-select::after {
  content: "";
  position: absolute;
  top: 22px;
  right: 29px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 18px solid #000;
  pointer-events: none;
  transform: translateY(-40%);
}

.texture-select-button {
  display: block;
}

.texture-select-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 190px;
  border: 2px solid #000;
  border-radius: 8px;
  background: var(--field-bg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  display: none;
  overflow-y: auto;
}

.texture-select.is-open .texture-select-menu {
  display: block;
}

.texture-option {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  outline: 0;
  color: #000;
  background: var(--field-bg);
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.texture-file-button {
  width: 100%;
  min-height: 44px;
  margin-top: 0;
  padding: 0 20px;
  border: 2px solid var(--field-border);
  border-radius: 11px;
  color: #000;
  background: var(--field-bg);
  cursor: pointer;
  font-size: clamp(20px, 1.5vw, 25px);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.texture-scale-wrap {
  margin-top: 10px;
}

.status {
  min-height: 1.2em;
  margin: 0 0 8px;
  color: #111;
  font-size: 16px;
}

.preview-section {
  min-width: 0;
}

.preview-wrap {
  position: relative;
}

.coffee-banner {
  margin-top: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  color: #111;
  background: transparent;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: right;
  gap: 14px;
}

.coffee-button {
  width: 164px;
  height: 45px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: #ff5f5f;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.coffee-logo {
  display: block;
  max-width: 118px;
  width: 100%;
  height: auto;
}

.checker-toggle {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  min-height: 38px;
  min-width: 72px;
  padding: 0 14px;
  border: 2px solid #aaa;
  border-radius: 8px;
  color: #fff;
  background: #333;
  cursor: pointer;
  font-size: 16px;
}

.checker-toggle.is-dark {
  color: #000;
  background: var(--field-bg);
}

.zoom-controls {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  display: flex;
  gap: 8px;
}

.zoom-button {
  width: 38px;
  height: 38px;
  padding: 6px;
  border: 2px solid var(--field-border);
  border-radius: 8px;
  background: var(--field-bg);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.zoom-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-board {
  width: 100%;
  height: 525px;
  border: 3px solid #c6c6c6;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-position: 0 0, 0 24px, 24px -24px, -24px 0;
  background-size: 48px 48px;
  display: grid;
  place-items: center;
  overflow-x: scroll;
  overflow-y: auto;
}

.preview-board.is-dark {
  background-color: #242424;
  background-image:
    linear-gradient(45deg, #555 25%, transparent 25%),
    linear-gradient(-45deg, #555 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #555 75%),
    linear-gradient(-45deg, transparent 75%, #555 75%);
}

.preview-board svg {
  display: block;
  max-width: 82%;
  max-height: 82%;
  height: auto;
}

.seo-summary {
  margin: 0 0 16px;
  padding: 0;
  color: #333;
}

.seo-summary summary {
  width: fit-content;
  padding: 7px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--button-teal);
  cursor: pointer;
  font-size: 16px;
  line-height: 1.2;
  list-style: none;
}

.seo-summary summary::-webkit-details-marker {
  display: none;
}

.seo-summary h2 {
  margin: 12px 0 6px;
  color: var(--header-bg);
  font-size: 24px;
}

.seo-summary p {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.help-shell {
  min-height: calc(100vh - 210px);
  padding: 48px 44px;
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: 44px;
  align-items: start;
}

.help-content {
  min-width: 0;
}

.help-content h1 {
  margin: 0 0 18px;
  color: var(--header-bg);
  font-size: 44px;
}

.help-content p,
.back-link {
  color: #333;
  font-size: 22px;
}

.back-link {
  color: #064f8d;
  display: inline-block;
  line-height: 0;
}

.back-link img {
  display: block;
  width: 150px;
  height: auto;
}

.help-video {
  width: 100%;
  margin: 28px 0 24px;
  border: 2px solid #333;
  aspect-ratio: 793 / 446;
}

.help-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.help-side {
  min-height: 1px;
}

.site-footer {
  margin: 0 36px 32px;
  padding-top: 8px;
  border-top: 2px solid var(--header-bg);
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.footer-nav a {
  color: #333;
  font-size: 16px;
  text-decoration: none;
}

.footer-nav a + a::before {
  content: "/";
  margin-right: 12px;
  color: #333;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .site-header {
    grid-template-columns: 1fr 48px;
    gap: 18px;
  }

  .ad-space {
    display: none;
  }

  .help-button {
    grid-column: 2;
    grid-row: 1;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .help-shell {
    grid-template-columns: 1fr;
  }

  .help-side {
    display: none;
  }

  .tool-panel {
    max-width: none;
  }

  .width-card {
    min-height: 444px;
  }

  .preview-board {
    height: 323px;
  }
}

@media (max-width: 640px) {
  .site-header,
  .app-shell,
  .help-shell {
    padding-inline: 20px;
  }

  .site-header {
    min-height: 0;
    padding-top: 8px;
    padding-bottom: 8px;
    grid-template-columns: 1fr 52px;
  }

  .help-button {
    width: 44px;
    font-size: 34px;
  }

  .app-shell {
    gap: 28px;
    padding-top: 28px;
  }

  .primary-button,
  .save-button {
    min-height: 48px;
  }

  .width-card {
    padding: 14px 20px 18px;
  }

  .select-wrap::after {
    right: 26px;
  }
}
