/* Chrome 61 keeps the original canvas dimensions and these layout fallbacks. */
button, input, label { -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { button:focus, input:focus, .upload:focus-within { outline: 2px solid #6d8854; outline-offset: 3px; } }
@media (hover: none) { button:focus, input:focus, label:focus-within, .upload:focus-within { outline: none; } }
.intro h1 { font-size: 54px; font-size: clamp(42px, 5.4vw, 70px); }
.frame-options { grid-gap: 10px; }
.brand-en { margin-left: 13px; }
.upload > span + span { margin-left: 16px; }
.upload .arrow { margin-left: auto; }
.upload small { margin-top: 3px; }
.wall-option { margin-right: 18px; }
.wall-option .swatch { margin-right: 8px; }
.result-header .close-result { margin-left: 15px; }
.supports-flex-gap .brand-en,
.supports-flex-gap .upload > span + span,
.supports-flex-gap .upload small,
.supports-flex-gap .wall-option,
.supports-flex-gap .wall-option .swatch,
.supports-flex-gap .result-header .close-result { margin-left: 0; margin-right: 0; margin-top: 0; }
.supports-flex-gap .upload .arrow { margin-left: auto; }

html { touch-action: manipulation; }
body { -webkit-touch-callout: none; }
body.modal-open { overflow: hidden; }
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop { position: fixed; z-index: 99; top: 0; right: 0; bottom: 0; left: 0; background: rgba(23, 37, 31, .72); }
.result-dialog[hidden], .about-dialog[hidden], .note-dialog[hidden] { display: none !important; }
.result-dialog, .about-dialog, .note-dialog {
  display: block;
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100vw - 28px);
  max-width: 420px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 25px 75px rgba(19, 41, 30, .2);
  border-radius: 16px;
}
.result-download, .result-note {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  font-size: 12px;
  cursor: pointer;
}
.result-download { border: 1px solid #234331; border-radius: 9px; }
.result-note { margin-top: 9px; background: transparent; border: 1px solid #b5c2b4; border-radius: 9px; color: #234331; }
.result-download:disabled, .result-note:disabled { opacity: .55; cursor: wait; }
.result-download[hidden], .result-note[hidden] { display: none !important; }
.result-status { min-height: 18px; color: #52745b; font-size: 11px; margin: 10px 0 0; }
.result-status[data-state=success] { padding: 11px 13px; border: 1px solid #c7d8c9; border-radius: 9px; background: #e8f0e8; color: #234331; font-size: 13px; font-weight: 600; }
.save-feedback[hidden] { display: none !important; }
.save-feedback { position: fixed; z-index: 101; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; min-width: 218px; max-width: calc(100vw - 28px); padding: 12px 16px; border-radius: 13px; background: #234331; color: #fff; box-shadow: 0 10px 30px rgba(16, 39, 24, .28); pointer-events: none; }
.save-feedback-icon { display: flex; flex: none; align-items: center; justify-content: center; width: 30px; height: 30px; margin-right: 11px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 50%; font-size: 19px; line-height: 1; }
.save-feedback strong, .save-feedback small { display: block; white-space: nowrap; }
.save-feedback strong { font-size: 14px; font-weight: 600; line-height: 1.3; }
.save-feedback small { margin-top: 2px; color: rgba(255, 255, 255, .82); font-size: 11px; line-height: 1.3; }
.about-dialog { padding: 24px; border: 1px solid #dce1d9; background: #f8f7f3; color: #1a302c; }
.about-dialog .result-header { margin-bottom: 7px; }
.about-dialog .result-header h2 { font-size: 24px; line-height: 1.3; }
.about-dialog .about-intro { color: #64716a; font-size: 12px; line-height: 1.6; margin: 0 0 20px; }
.about-benefits { padding: 17px 19px 7px; background: #edf0e8; border: 1px solid #dce1d9; border-radius: 12px; }
.about-benefits ul { padding: 0; margin: 12px 0 0; list-style: none; color: #345443; font-size: 13px; }
.about-benefits li { display: flex; align-items: center; min-height: 42px; border-top: 1px solid #dce1d9; }
.about-benefits li span { width: 31px; color: #829586; font: 10px Georgia, serif; }
.about-dialog .about-credit { margin: 17px 0 0; color: #8a958b; font-size: 10px; line-height: 1.4; }
.note-dialog { padding: 22px; border: 1px solid #dce1d9; background: #f8f7f3; color: #1a302c; }
.note-dialog .result-header h2 { font-size: 24px; line-height: 1.3; }
.note-dialog label { display: block; margin: 12px 0 6px; color: #64716a; font-size: 11px; }
.note-dialog input, .note-dialog textarea { display: block; width: 100%; padding: 10px 11px; border: 1px solid #cad4ca; border-radius: 9px; background: #fff; color: #1a302c; font-size: 16px; line-height: 1.5; resize: vertical; }
.note-dialog .note-help { margin: 12px 0; color: #64716a; font-size: 11px; line-height: 1.6; }
.note-dialog .result-download { border: 1px solid #234331; }
.stage-header { display: none; }
.editor { padding: 18px; border: 1px solid #dce1d9; border-radius: 18px; background: #f8f7f3; }
.upload { padding-right: 16px; border-radius: 12px; }
.upload .upload-copy { flex: 1; min-width: 0; }
.upload .upload-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload .arrow, .quick-note .arrow { display: block; flex: none; width: 18px; color: #52745b; font-size: 16px; font-weight: 400; line-height: 1; text-align: center; }
.frame-option { border-radius: 12px; overflow: hidden; }
.frame-option canvas { border-radius: 8px; }
.color-field { border-radius: 10px; }
.color-field input[type=color]::-webkit-color-swatch { border-radius: 7px; }
.palette-options { padding: 4px 5px 4px; }
.editor-tabs button:focus { outline: none; }
.editor-tabs button:focus-visible { outline: 2px solid #6d8854; outline-offset: 2px; }
.discovery-link { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 40px; margin: 8px 0 0; padding: 0 2px; border: 0; background: transparent; color: #52745b; font-size: 11px; text-align: left; }
.discovery-link span { padding-right: 3px; font-size: 14px; }
.photo-discovery { min-height: 38px; margin-top: 7px; padding: 0 1px; border-top: 1px solid #e0e5dd; color: #64776a; }
.photo-discovery span { padding: 0; color: #3f654d; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.frame-discovery { margin: 14px 0 12px; border-top: 1px solid #dce1d9; }
.range-adjust { display: flex; align-items: center; margin-top: 8px; }
.mat-group .range-adjust { margin: 8px 0 0; }
.range-adjust button { flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0 0 2px; border: 1px solid #cbd5ca; border-radius: 50%; background: #f4f6ef; color: #345443; font-size: 20px; font-weight: 300; line-height: 1; }
.range-adjust button:disabled { opacity: .38; }
.range-adjust input[type=range] { flex: 1; min-width: 0; height: 42px; margin: 0 12px; background: transparent; }
.range-adjust input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #859982, #ccd4c9); }
.range-adjust input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #859982, #ccd4c9); }
.range-adjust input[type=range]::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -11px; border-width: 4px; }
.range-adjust input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-width: 4px; }
.angle-control input[type=range] { display: block; width: calc(100% - 48px); height: 44px; margin: 7px 24px 0; background: transparent; touch-action: none; }
.angle-control input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #859982, #ccd4c9); }
.angle-control input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #859982, #ccd4c9); }
.angle-control input[type=range]::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -11px; border-width: 4px; }
.angle-control input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-width: 4px; }

@media(max-width:850px) {
  .intro { padding: 25px 0 21px; }
  .intro h1 { font-size: 43px; }
  .intro > p:last-child { font-size: 12px; }
  .stage-wrap { padding: 8px 8px 10px; }
  .editor { padding-top: 25px; }
  footer { padding-bottom: 28px; padding-bottom: calc(28px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))); }
}
@media(max-width:390px) {
  .intro h1 { font-size: 40px; }
  .wall-option { margin-right: 12px; }
}

/* Keep the live artwork visible while the mobile controls scroll underneath. */
@media(max-width:850px) {
  .stage-wrap { position: -webkit-sticky; position: sticky; top: 0; z-index: 20; background: #f8f7f3; padding: 7px 8px 8px; border-bottom: 1px solid #dce1d9; box-shadow: 0 5px 14px rgba(31, 55, 37, .07); }
  .stage-wrap canvas { width: auto; height: 250px; max-width: 100%; margin: 0 auto; }
  .stage-caption { padding: 5px 3px 0; }
  .editor { position: relative; z-index: 1; }
}
@media(max-width:390px) {
  .stage-wrap canvas { height: 216px; }
}

/* App-style inspector: one section at a time, with export always visible. */
.editor-toolbar { display: flex; align-items: center; gap: 10px; padding: 0 0 14px; border-bottom: 1px solid #dce1d9; }
.editor-tabs { display: flex; flex: 1; min-width: 0; padding: 3px; background: #e9ece5; border: 1px solid #dce1d9; border-radius: 8px; }
.editor-tabs button { flex: 1; min-width: 0; min-height: 38px; border: 0; border-radius: 5px; background: transparent; color: #64716a; font-size: 12px; padding: 0 3px; }
.editor-tabs button[aria-selected=true] { background: #fff; color: #234331; box-shadow: 0 1px 3px rgba(24, 52, 34, .12); }
.editor-toolbar .save { flex: none; width: 76px; min-height: 44px; margin: 0; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.editor-toolbar .save span { font-size: 18px; line-height: 1; }
.editor-toolbar .save:disabled { opacity: .42; cursor: default; }
.panel-scroll { min-height: 320px; }
.tab-panel[hidden], .quick-note[hidden] { display: none !important; }
.tab-panel.control-group { margin: 0; border: 0; }
.tab-panel.control-group legend { padding: 16px 0 14px; }
.photo-panel { padding-top: 20px; }
.panel-hint { margin: 12px 1px 0; color: #64716a; font-size: 11px; line-height: 1.6; }
.quick-note { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 46px; margin-top: 9px; padding: 0 16px; border: 1px solid #cbd5ca; border-radius: 10px; background: #fff; color: #234331; font-size: 12px; text-align: left; }
.editor .status { min-height: 18px; margin: 8px 1px 0; }

@media(max-width:850px) {
  html, body { width: 100%; height: 100%; overflow: hidden; }
  .shell { width: 100%; max-width: none; height: 100vh; height: 100dvh; padding: 0; overflow: hidden; }
  .topbar, .intro, footer { display: none; }
  main, .workspace { height: 100%; }
  .workspace { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .stage-wrap { position: relative; top: auto; flex: 1; width: 100%; min-height: 0; z-index: 1; margin-bottom: -24px; padding: 0; border: 0; box-shadow: none; background: #e8e9e1; overflow: hidden; touch-action: none; }
  .stage-wrap canvas { display: block; width: 100%; height: 100%; max-width: none; margin: 0; object-fit: cover; transform-origin: center center; will-change: transform; }
  .stage-header { position: absolute; z-index: 2; top: 43px; top: max(43px, calc(env(safe-area-inset-top, 0px) + 13px)); left: 16px; right: 16px; height: 34px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
  .stage-title { color: #294033; font-family: "Songti SC", "STSong", Georgia, serif; font-size: 15px; letter-spacing: .04em; text-shadow: 0 1px 7px rgba(255, 255, 255, .85); }
  .about-trigger { position: absolute; z-index: 2; left: 14px; bottom: 38px; width: 34px; height: 34px; border: 1px solid rgba(55, 81, 62, .38); border-radius: 50%; background: rgba(248, 247, 243, .88); color: #345443; font-family: Georgia, serif; font-size: 17px; font-style: italic; }
  .stage-wrap[data-tone=dark] .stage-title { color: #fbfaf4; text-shadow: 0 1px 7px rgba(0, 0, 0, .75); }
  .stage-wrap[data-tone=dark] .about-trigger { color: #f8f7f3; background: rgba(30, 43, 36, .82); border-color: rgba(255, 255, 255, .45); }
  .stage-caption { display: none; }
  .editor { position: relative; z-index: 2; flex: none; display: flex; flex-direction: column; width: 100%; height: 340px; min-height: 0; padding: 0 14px env(safe-area-inset-bottom, 0px); border: 0; border-top: 1px solid #dce1d9; border-radius: 24px 24px 0 0; background: #f8f7f3; box-shadow: 0 -5px 20px rgba(30, 50, 35, .07); overflow: hidden; }
  .editor-toolbar { flex: none; padding: 9px 0 8px; }
  .editor-tabs button { min-height: 36px; font-size: 12px; }
  .editor-toolbar .save { min-height: 42px; }
  .panel-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 0 8px; }
  .editor .status { flex: none; min-height: 15px; margin: 3px 1px 5px; font-size: 10px; }
  .save-feedback { bottom: calc(340px + 16px); }
  .photo-panel { padding-top: 18px; }
  .tab-panel.control-group legend { padding: 13px 0 10px; }
  .frame-option { padding: 5px; }
  .frame-option strong { padding: 5px 1px 0; }
  .mat-options { margin-top: 13px; }
}
@media(max-width:850px) and (max-height:700px) {
  .editor { height: 300px; }
  .save-feedback { bottom: calc(300px + 16px); }
  .stage-header { top: 27px; top: max(27px, calc(env(safe-area-inset-top, 0px) + 8px)); }
}
