/* Shared additions for the CKS multi-tool pages. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.header-actions {
  gap: 16px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
}

.lang-switcher {
  position: relative;
  flex: none;
}

.lang-switcher summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

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

.lang-switcher summary::marker {
  content: "";
}

.lang-switcher summary::after {
  content: none;
}

.lang-switcher[open] summary::after {
  content: none;
}

.lang-switcher summary:hover {
  border-color: #aebed5;
  color: var(--accent);
}

.lang-switcher[open] summary {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(36, 89, 211, .1);
}

.lang-globe {
  width: 16px;
  height: 16px;
  flex: none;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  min-width: 178px;
  max-width: calc(100vw - 32px);
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(25, 52, 100, .14);
}

.lang-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.lang-menu a:hover {
  background: var(--wash);
  color: var(--accent);
}

.lang-menu a[aria-current="page"] {
  background: var(--wash);
  color: var(--accent);
  font-weight: 700;
}

.lang-check {
  width: 14px;
  height: 14px;
  flex: none;
}

.tool-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--wash);
}

.tool-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}

.tool-link:hover {
  color: var(--accent);
}

.tool-link.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(25, 52, 100, .08);
}

.new-badge {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 8px;
  line-height: 1.3;
  letter-spacing: .04em;
}

.qr-intro .intro-note {
  min-width: 280px;
}

.qr-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(25, 52, 100, .06);
}

.qr-builder {
  min-width: 0;
  padding: 34px;
}

.qr-source-card {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faff;
}

.source-tabs,
.qr-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.source-tabs {
  margin-bottom: 18px;
  padding-bottom: 2px;
}

.tab-button {
  flex: none;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tab-button:hover {
  border-color: #aebed5;
  color: var(--ink);
}

.tab-button[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.source-panel[hidden],
.qr-panel[hidden] {
  display: none !important;
}

.qr-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.qr-textarea,
.qr-input {
  width: 100%;
  border: 1px solid #c9d4e4;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: var(--ink);
}

.qr-textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.7;
}

.qr-input[type="text"] {
  min-height: 44px;
}

.qr-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 22px;
  border: 2px dashed #bccbe0;
  border-radius: 10px;
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.qr-drop strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.qr-drop span {
  color: var(--muted);
  font-size: 12px;
}

.qr-helper {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.qr-source-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.qr-source-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.qr-source-status.is-error {
  color: #a43d27;
}

.qr-source-status.is-success {
  color: #26734d;
}

.qr-tabs {
  gap: 18px;
  margin-top: 24px;
  border-bottom: 1px solid var(--line);
}

.qr-tabs .tab-button {
  padding: 11px 1px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.qr-tabs .tab-button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.qr-panel {
  padding-top: 22px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.template-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.template-option:hover {
  border-color: #aebed5;
}

.template-option.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(36, 89, 211, .12);
}

.template-swatch {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--swatch-a) 50%, var(--swatch-b) 50%);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.control-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.control-block:first-child,
.control-block:nth-child(2) {
  padding-top: 0;
  border-top: 0;
}

.control-block.full {
  grid-column: 1 / -1;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.segment {
  position: relative;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: block;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.segment input:checked + span {
  border-color: var(--accent);
  background: var(--wash);
  color: var(--accent);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.color-control {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.color-control input[type="color"] {
  width: 36px;
  height: 36px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.color-control code {
  display: block;
  color: var(--muted);
  font: 600 11px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.color-control strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
}

.toggle-copy strong {
  display: block;
  font-size: 13px;
}

.toggle-copy span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c8d3e2;
  cursor: pointer;
  transition: background .15s;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  content: "";
  transition: transform .15s;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.upload-logo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-preview {
  width: 52px;
  height: 52px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  object-fit: contain;
}

.logo-preview[hidden] {
  display: none !important;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row output {
  min-width: 72px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.qr-preview-panel {
  align-self: stretch;
  padding: 30px 26px;
  border-left: 1px solid var(--line);
  background: #f4f7fc;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-head h2 {
  margin: 0;
  font-size: 18px;
}

.preview-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #2a9d67;
  box-shadow: 0 0 0 4px rgba(42, 157, 103, .12);
}

.reset-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.canvas-stage {
  position: relative;
  display: grid;
  min-height: 320px;
  margin-top: 20px;
  padding: 18px;
  overflow: hidden;
  place-items: center;
  border: 1px solid #d7e1ee;
  border-radius: 12px;
  background: repeating-conic-gradient(#edf2f7 0% 25%, #fff 0% 50%) 0 0 / 18px 18px;
}

#qrCanvas {
  display: block;
  width: min(100%, 330px);
  height: auto;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(22, 43, 77, .12);
}

.preview-caption {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.export-box {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-row .button {
  width: 100%;
}

.export-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.export-width label {
  font-size: 13px;
  font-weight: 700;
}

.export-width select {
  width: 130px;
  padding: 9px 10px;
}

.download-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.qr-security {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #d7e1ee;
  border-radius: 10px;
  background: #fff;
}

.qr-security strong {
  display: block;
  font-size: 12px;
}

.qr-security p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.qr-faq {
  grid-template-columns: 1fr 2fr;
}

@media (max-width: 800px) {
  .qr-faq {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .qr-faq .faq-intro,
  .qr-faq .faq-list {
    max-width: none;
  }
}

.button-small {
  padding: 8px 12px;
  font-size: 12px;
}

.button:disabled {
  filter: none;
}

@media (max-width: 1050px) {
  .tool-nav {
    gap: 2px;
  }

  .tool-link {
    padding: 7px 9px;
    font-size: 12px;
  }

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

@media (max-width: 900px) {
  .header-inner {
    height: auto;
    min-height: 82px;
    padding-top: 12px;
    padding-bottom: 12px;
    align-items: flex-start;
  }

  .header-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
  }

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

  .qr-preview-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .canvas-stage {
    min-height: 300px;
  }
}

@media (max-width: 800px) {
  .tool-nav {
    max-width: calc(100vw - 130px);
    overflow-x: auto;
    justify-content: flex-start;
  }

  .qr-builder,
  .qr-preview-panel {
    padding: 26px;
  }
}

@media (max-width: 620px) {
  .header-inner {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand theme"
      "nav nav";
    align-items: center;
    gap: 8px 12px;
    height: auto;
    padding: 10px 16px 12px;
  }

  .brand {
    grid-area: brand;
    width: 134px;
    min-width: 134px;
    flex: none;
  }

  .header-actions {
    display: contents;
    width: 100%;
  }

  .theme-picker {
    grid-area: theme;
    justify-self: end;
    align-self: center;
  }

  .header-tools {
    grid-area: theme;
    justify-self: end;
    align-self: center;
    gap: 8px;
  }

  .tool-nav {
    grid-area: nav;
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .template-grid,
  .settings-grid,
  .color-grid {
    grid-template-columns: 1fr 1fr;
  }

  .control-block.full {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .brand {
    max-width: 134px;
  }

  .tool-link {
    font-size: 11px;
  }

  .new-badge {
    display: none;
  }

  .qr-builder,
  .qr-preview-panel {
    padding: 22px 17px;
  }

  .template-grid,
  .settings-grid,
  .color-grid,
  .export-row {
    grid-template-columns: 1fr;
  }

  .qr-source-card {
    padding: 15px;
  }

  .qr-tabs {
    gap: 14px;
  }

  .canvas-stage {
    min-height: 260px;
    padding: 12px;
  }

  .lang-switcher summary {
    padding: 7px 8px;
    font-size: 12px;
  }
}

/* ===== IG 切圖 ===== */
.grid-hint {
  margin-top: 9px;
}

.layout-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.layout-option {
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}

.layout-option strong {
  display: block;
  margin-bottom: 1px;
  color: var(--ink);
  font-size: 13px;
}

.layout-option:hover {
  border-color: #aebed5;
}

.layout-option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--wash);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.layout-option[aria-pressed="true"] strong {
  color: var(--accent);
}

.setting-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-zoom-row input[type="range"] {
  flex: 1;
  width: auto;
}

.reset-view {
  flex: none;
  padding: 4px 0;
  white-space: nowrap;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-field input {
  flex: none;
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.color-field span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.generate-btn {
  width: 100%;
  margin-top: 6px;
}

.generate-hint {
  margin-bottom: 0;
}

select:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.editor-heading h3 {
  margin: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.editor-heading p {
  margin: 7px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.grid-stage-wrap {
  display: flex;
  justify-content: center;
}

.grid-stage {
  position: relative;
  width: 100%;
  max-width: 760px;
  aspect-ratio: 3045 / 1350;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.grid-stage.is-dragging {
  cursor: grabbing;
}

.grid-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.grid-stage #guideCanvas {
  pointer-events: none;
}

.profile-preview {
  margin-top: 28px;
}

.ig-card {
  max-width: 520px;
  margin: 18px auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.ig-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.ig-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f09433, #dc2743, #bc1888);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.ig-top strong {
  display: block;
  font-size: 13px;
}

.ig-top span {
  color: var(--muted);
  font-size: 11px;
}

.ig-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  background: #dbdbdb;
}

.ig-cell {
  position: relative;
  background: #fff;
}

.ig-cell canvas {
  display: block;
  width: 100%;
  height: auto;
}

.ig-num {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.tile-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
  padding: 0;
  list-style: none;
}

.tile-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.tile-thumb {
  position: relative;
  aspect-ratio: 4 / 5;
  background: #f4f7fc;
}

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

.tile-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.tile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
}

.tile-info strong {
  font-size: 13px;
}

.tile-info span {
  color: var(--muted);
  font-size: 11px;
}

.tile-item .download {
  width: 100%;
  border-radius: 0;
  padding: 10px;
}

.posting-note {
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 520px) {
  .editor-heading {
    flex-direction: column;
  }

  .tile-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout-option {
    font-size: 10px;
  }
}
