/* Image Studio — full-viewport editor shell plus readable supporting content. */
:root {
  --brand: #a94631;
  --brand-dark: #80331f;
  --brand-soft: #f9e8e1;
  --accent: #bd8739;
  --studio-ink: #302722;
  --studio-muted: #756b65;
  --studio-line: #e6dcd3;
  --studio-canvas: #f5f0e9;
  --studio-primary: #a94631;
  --studio-primary-dark: #80331f;
  --studio-primary-soft: #f9e8e1;
  --studio-surface: #fffdf9;
  --studio-success: #287a5d;
  --studio-success-soft: #e7f3eb;
  --studio-shadow: 0 0.25rem 0.8rem rgba(54, 37, 27, 0.12);
  --studio-radius: 0.7rem;
}

[hidden] { display: none !important; }

.studio-page {
  display: flex;
  min-width: 320px;
  flex-direction: column;
  color: var(--studio-ink);
  background: var(--studio-surface);
}

.studio-page main { flex: 1; }
.studio-page .site-footer { margin-top: 0; }

.editor-app {
  border-top: 0.35rem solid #463a34;
  background: var(--studio-surface);
}

.editor-header {
  position: relative;
  z-index: 10;
  display: flex;
  min-height: 3.65rem;
  align-items: center;
  gap: clamp(0.7rem, 2vw, 2rem);
  padding: 0 1.2rem;
  border-bottom: 1px solid #e2d8cf;
  background: var(--studio-surface);
}

.studio-brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.48rem;
  color: var(--studio-ink);
  font-size: 1.04rem;
  font-weight: 850;
  letter-spacing: -0.055em;
  text-transform: uppercase;
}

.studio-brand:hover { color: var(--studio-ink); text-decoration: none; }
.studio-brand .brand-light { color: var(--studio-primary); }
.brand-symbol {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.13rem;
  transform: rotate(-8deg);
}
.brand-symbol span { border-radius: 0.18rem; background: var(--studio-primary); }
.brand-symbol span:nth-child(2), .brand-symbol span:nth-child(3) { opacity: 0.55; }

.tool-nav {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: stretch;
  gap: clamp(0.45rem, 2.6vw, 3rem);
  align-self: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}
.tool-nav::-webkit-scrollbar { display: none; }
.tool-nav__item {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.08rem 0;
  border: 0;
  background: transparent;
  color: var(--studio-ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 670;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.tool-nav__item:hover { color: var(--studio-primary); }
.tool-nav__item.is-active { color: var(--studio-primary); }
.tool-nav__item.is-active::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--studio-primary);
  content: '';
}
.tool-nav__item:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.transform-button:focus-visible,
.format-choice:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--studio-primary) 45%, transparent);
  outline-offset: 2px;
}

.header-actions { flex: 0 0 auto; }
.btn-primary {
  border-color: var(--studio-primary);
  background: var(--studio-primary);
  color: #fff;
  box-shadow: 0 0.15rem 0.3rem rgba(105, 49, 31, 0.2);
}
.btn-primary:hover { background: var(--studio-primary-dark); color: #fff; }
.btn-choose { padding: 0.48rem 0.9rem; font-size: 0.88rem; }

.editor-layout {
  display: grid;
  min-height: max(38rem, calc(100dvh - 4rem));
  grid-template-columns: minmax(0, 1fr) minmax(19rem, clamp(22.5rem, 23vw, 27.5rem));
}
.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--studio-canvas);
}
.workspace__topline,
.workspace__bottomline {
  display: flex;
  min-height: 2.85rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.5rem clamp(1rem, 2vw, 2.2rem);
  color: var(--studio-muted);
  font-size: 0.78rem;
}
.workspace__topline { border-bottom: 1px solid rgba(220, 208, 198, 0.72); }
.workspace__bottomline { border-top: 1px solid rgba(220, 208, 198, 0.72); }
.privacy-note { display: inline-flex; align-items: center; gap: 0.48rem; }
.privacy-note__icon {
  display: inline-grid;
  width: 1.1rem;
  height: 1.1rem;
  place-items: center;
  border-radius: 50%;
  background: #d8f4e8;
  color: #118553;
  font-size: 0.68rem;
  font-weight: 800;
}
.text-button,
.sample-link {
  padding: 0.2rem 0;
  border: 0;
  background: none;
  color: var(--studio-primary);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.text-button:hover, .sample-link:hover { text-decoration: underline; }

.workbench {
  position: relative;
  display: grid;
  min-height: 0;
  flex: 1;
  place-items: center;
  overflow: hidden;
}
.upload-state {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 32rem;
  place-items: start center;
  padding: clamp(2.4rem, 8vh, 4.6rem) 1.2rem 2.5rem;
  transition: background-color 160ms ease;
}
.upload-state.is-dragging { background: #f9e8e1; }
.upload-state__content { display: flex; max-width: 34rem; align-items: center; flex-direction: column; text-align: center; }
.upload-icon {
  display: grid;
  width: 3.15rem;
  height: 3.15rem;
  place-items: center;
  margin-bottom: 1.1rem;
  border-radius: 1rem;
  background: #f3dfd5;
  color: var(--studio-primary);
}
.upload-icon svg { width: 1.8rem; height: 1.8rem; }
.upload-state h2 { margin: 0 0 0.45rem; color: var(--studio-ink); font-size: clamp(1.6rem, 3.4vw, 2.25rem); letter-spacing: -0.03em; }
.upload-state p { margin: 0; color: var(--studio-muted); }
.upload-button { min-width: 15rem; margin-top: 1.35rem; padding: 0.82rem 1.5rem; font-size: 1.02rem; }
.upload-or { margin-top: 0.6rem; color: #4b403a; font-size: 0.84rem; }
.upload-support { margin-top: 1.1rem !important; color: #80756e !important; font-size: 0.76rem; }
.sample-link { margin-top: 0.75rem; font-size: 0.82rem; }

.preview-state {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 31rem;
  flex-direction: column;
  padding: 1rem clamp(1rem, 2.2vw, 2.3rem) 1.15rem;
}
.preview-info { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.preview-file { display: flex; min-width: 0; align-items: center; gap: 0.7rem; }
.file-type-icon {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #ead8cd;
  border-radius: 0.55rem;
  background: var(--studio-surface);
  color: var(--studio-primary);
  font-size: 0.63rem;
  font-weight: 850;
}
.preview-file strong,
.preview-file small { display: block; max-width: min(50vw, 22rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-file strong { font-size: 0.82rem; }
.preview-file small { color: var(--studio-muted); font-size: 0.73rem; }
.icon-button {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #e3d9d0;
  border-radius: 50%;
  background: var(--studio-surface);
  color: #555f70;
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { border-color: #c8b7aa; color: var(--studio-ink); }
.image-stage {
  display: grid;
  min-height: 12rem;
  flex: 1 1 auto;
  place-items: center;
  overflow: hidden;
  padding: 1rem 0;
}
.image-stage__content { position: relative; display: inline-block; max-width: 100%; max-height: 100%; line-height: 0; }
#preview-canvas { display: block; max-width: 100%; max-height: 100%; background-color: var(--studio-surface); box-shadow: 0 0.2rem 0.8rem rgba(54, 37, 27, 0.17); }
.crop-selection {
  position: absolute;
  z-index: 2;
  border: 2px solid var(--studio-primary);
  box-shadow: 0 0 0 9999px rgba(43, 31, 26, 0.43);
  cursor: move;
  touch-action: none;
  user-select: none;
}
.crop-selection.is-dragging { cursor: grabbing; }
.crop-grid { position: absolute; inset: 0; pointer-events: none; }
.crop-grid::before,
.crop-grid::after {
  position: absolute;
  background: rgba(255, 255, 255, 0.43);
  content: '';
}
.crop-grid::before { top: 0; bottom: 0; left: 33.333%; width: 33.333%; border-right: 1px dashed rgba(255,255,255,.55); border-left: 1px dashed rgba(255,255,255,.55); }
.crop-grid::after { top: 33.333%; right: 0; left: 0; height: 33.333%; border-top: 1px dashed rgba(255,255,255,.55); border-bottom: 1px dashed rgba(255,255,255,.55); }
.crop-handle {
  position: absolute;
  z-index: 3;
  width: 0.7rem;
  height: 0.7rem;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 0.13rem;
  background: var(--studio-primary);
  box-shadow: 0 0 0 1px rgba(111, 53, 35, 0.15);
  touch-action: none;
  cursor: nwse-resize;
}
.crop-handle:hover { background: var(--studio-primary-dark); }
.crop-handle:focus-visible { outline: 2px solid #653b2d; outline-offset: 2px; }
.crop-handle--tl { top: -0.4rem; left: -0.4rem; }
.crop-handle--tr { top: -0.4rem; right: -0.4rem; cursor: nesw-resize; }
.crop-handle--bl { bottom: -0.4rem; left: -0.4rem; cursor: nesw-resize; }
.crop-handle--br { right: -0.4rem; bottom: -0.4rem; }
.preview-caption { display: flex; justify-content: space-between; gap: 0.6rem; color: var(--studio-muted); font-size: 0.74rem; }
.preview-caption span:last-child { text-align: right; }
.result-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding: 0.75rem;
  border: 1px solid #b8e7cf;
  border-radius: 0.65rem;
  background: #f1fbf5;
}
.result-card__preview { width: 3.5rem; height: 3rem; flex: 0 0 auto; border: 1px solid #d7e6dc; border-radius: 0.35rem; background: var(--studio-surface); object-fit: contain; }
.result-card__copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.result-card__copy strong { font-size: 0.78rem; }
.result-card__copy span { color: #5f6c69; font-size: 0.72rem; }
.result-download { flex: 0 0 auto; padding: 0.45rem 0.7rem; font-size: 0.78rem; }
.drop-overlay {
  position: absolute;
  z-index: 5;
  display: none;
  place-items: center;
  border: 2px dashed var(--studio-primary);
  background: rgba(249, 232, 225, 0.94);
  color: var(--studio-primary-dark);
  font-size: 1.15rem;
  font-weight: 750;
  inset: 0.8rem;
  pointer-events: none;
}
.workbench.is-dragging .drop-overlay { display: grid; }

.options-panel {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-left: 1px solid #e2d8cf;
  background: var(--studio-surface);
}
.options-panel__heading { padding: 1rem 1rem 0.8rem; border-bottom: 1px solid var(--studio-line); text-align: center; }
.eyebrow { margin: 0 0 0.23rem; color: var(--studio-primary); font-size: 0.67rem; font-weight: 800; letter-spacing: 0.1em; }
.options-panel__heading h2 { margin: 0 0 0.25rem; color: var(--studio-ink); font-size: 1.35rem; letter-spacing: -0.02em; }
.options-panel__heading > p:last-child { margin: 0; color: var(--studio-muted); font-size: 0.79rem; }
.options-panel__body { min-height: 0; flex: 1; overflow-y: auto; }
.panel-empty { display: flex; align-items: center; flex-direction: column; padding: 3.4rem 1.5rem; text-align: center; }
.panel-empty__icon { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; margin-bottom: 0.8rem; border-radius: 50%; background: var(--studio-primary-soft); color: var(--studio-primary); font-size: 1.3rem; }
.panel-empty strong { font-size: 0.9rem; }
.panel-empty p { max-width: 20rem; margin: 0.4rem 0 0.7rem; color: var(--studio-muted); font-size: 0.78rem; }
.mode-options { padding: 0.8rem 0; }
.options-hint { margin: 0; padding: 0 1rem 0.65rem; color: var(--studio-muted); font-size: 0.81rem; }
.dimension-field {
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid #ede4dc;
}
.dimension-field > label { color: #433832; font-size: 0.86rem; }
.dimension-field > label span { color: #80756e; }
.dimension-input { width: 6rem; padding: 0.45rem 0.55rem; border-color: #cbbeb5; border-radius: 0.3rem; text-align: right; font-variant-numeric: tabular-nums; }
.dimension-input:focus { border-color: var(--studio-primary); }
.input-suffix { position: relative; width: 6rem; }
.input-suffix .input { width: 100%; padding-right: 2.1rem; }
.input-suffix > span { position: absolute; top: 50%; right: 0.55rem; color: #80756e; font-size: 0.75rem; transform: translateY(-50%); pointer-events: none; }
.option-check { display: flex; min-height: 3.6rem; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem; border-top: 1px solid #ede4dc; color: #4b403a; font-size: 0.86rem; cursor: pointer; }
.option-check input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.checkmark { display: grid; width: 1.2rem; height: 1.2rem; flex: 0 0 auto; place-items: center; border: 1px solid #95877d; border-radius: 0.22rem; color: transparent; }
.option-check input:checked + .checkmark { border-color: #20b879; background: #f1fbf5; color: #20b879; }
.option-check input:checked + .checkmark::after { content: '✓'; font-size: 0.85rem; font-weight: 800; }
.option-check input:focus-visible + .checkmark { outline: 3px solid color-mix(in srgb, var(--studio-primary) 40%, transparent); outline-offset: 2px; }
.field { margin: 0; }
.format-field { padding: 0.85rem 1rem 0; }
.format-field label,
.quality-field label { display: flex; align-items: baseline; justify-content: space-between; color: #4b403a; font-size: 0.82rem; font-weight: 650; }
.format-field .select { margin-top: 0.35rem; padding: 0.48rem 0.65rem; border-color: #d1c3b8; border-radius: 0.35rem; font-size: 0.84rem; }
.quality-field { padding: 1rem 1rem 0; }
.quality-field output { color: var(--studio-primary); font-variant-numeric: tabular-nums; }
.quality-field input[type='range'] { display: block; margin: 0.75rem 0 0.35rem; }
.field-hint { margin: 0; color: var(--studio-muted); font-size: 0.72rem; line-height: 1.45; }
.crop-hint { padding: 0.7rem 1rem 0; }
.format-choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; padding: 0.1rem 1rem 0.3rem; }
.format-choice {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-direction: column;
  gap: 0.13rem;
  padding: 0.7rem 0.2rem;
  border: 1px solid #e2d8cf;
  border-radius: 0.45rem;
  background: var(--studio-surface);
  color: var(--studio-ink);
  cursor: pointer;
}
.format-choice strong { font-size: 0.84rem; }
.format-choice small { color: var(--studio-muted); font-size: 0.65rem; }
.format-choice:hover { border-color: #d8aa9b; }
.format-choice.is-selected { border-color: var(--studio-primary); background: var(--studio-primary-soft); box-shadow: inset 0 0 0 1px var(--studio-primary); color: var(--studio-primary-dark); }
.transform-group { padding: 0.9rem 1rem; border-top: 1px solid #ede4dc; }
.transform-label { display: block; margin-bottom: 0.45rem; color: #4b403a; font-size: 0.82rem; font-weight: 700; }
.transform-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.transform-button { display: flex; min-height: 2.65rem; align-items: center; justify-content: center; gap: 0.42rem; padding: 0.4rem; border: 1px solid #e2d8cf; border-radius: 0.4rem; background: var(--studio-surface); color: #4b403a; font: inherit; font-size: 0.8rem; cursor: pointer; }
.transform-button:hover { border-color: #d8aa9b; background: #fdf4ef; color: var(--studio-primary-dark); }
.transform-button > span { color: var(--studio-primary); font-size: 1.15rem; line-height: 1; }
.edit-state { margin: 0.25rem 1rem 0; padding: 0.6rem 0.7rem; border-radius: 0.4rem; background: #f5f0e9; color: var(--studio-muted); font-size: 0.74rem; }
.options-panel__footer { padding: 0.8rem 1rem 0.65rem; border-top: 1px solid var(--studio-line); background: var(--studio-surface); box-shadow: 0 -0.15rem 0.6rem rgba(54, 37, 27, 0.035); }
.apply-button { display: flex; width: 100%; min-height: 3.5rem; justify-content: center; gap: 0.8rem; border-radius: 0.62rem; font-size: 1rem; }
.apply-button:disabled { opacity: 0.48; cursor: not-allowed; }
.button-arrow { font-size: 1.25rem; line-height: 1; }
.privacy-caption { margin: 0.45rem 0 0; color: var(--studio-muted); font-size: 0.68rem; text-align: center; }
.privacy-caption span { margin-right: 0.18rem; color: #1ca768; }
.operation-message { min-height: 0.3rem; margin: 0.2rem 0 0; color: #a04432; font-size: 0.72rem; text-align: center; }
.operation-message:empty { display: none; }

.tool-guide { max-width: 75rem; margin: 0 auto; padding: clamp(2.6rem, 7vw, 5rem) 1.2rem 4rem; }
.guide-intro { max-width: 48rem; margin-bottom: 2rem; }
.guide-intro h2 { margin-bottom: 0.6rem; font-size: clamp(1.8rem, 3.4vw, 2.5rem); letter-spacing: -0.035em; }
.guide-intro > p:last-child { max-width: 66ch; color: var(--studio-muted); }
.guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.guide-card { padding: 1.25rem; border: 1px solid #e9e0d8; border-radius: 0.8rem; background: var(--studio-surface); }
.guide-number { display: inline-flex; width: 2rem; height: 2rem; align-items: center; justify-content: center; margin-bottom: 0.8rem; border-radius: 0.6rem; background: var(--studio-primary-soft); color: var(--studio-primary); font-size: 0.75rem; font-weight: 800; }
.guide-card h3 { margin-bottom: 0.35rem; font-size: 1rem; }
.guide-card p { margin: 0; color: var(--studio-muted); font-size: 0.9rem; }
.faq-section { max-width: 54rem; margin: 3.3rem auto 0; }
.faq-section h2 { margin-bottom: 1rem; }
.faq-list { display: grid; gap: 0.55rem; }
.faq-list details { padding: 0.9rem 1rem; border: 1px solid #e6dcd3; border-radius: 0.6rem; background: var(--studio-surface); }
.faq-list summary { color: var(--studio-ink); font-weight: 700; cursor: pointer; }
.faq-list details p { margin: 0.6rem 0 0; color: var(--studio-muted); font-size: 0.9rem; }

@media (max-width: 1050px) {
  .editor-header { gap: 1rem; padding-inline: 0.9rem; }
  .tool-nav { gap: 1.1rem; }
  .tool-nav__item { font-size: 0.73rem; }
  .editor-layout { grid-template-columns: minmax(0, 1fr) minmax(18rem, 21rem); }
}

@media (max-width: 820px) {
  .editor-header { flex-wrap: wrap; gap: 0.55rem 1rem; padding: 0.45rem 0.8rem 0; }
  .studio-brand { min-height: 2.5rem; }
  .header-actions { margin-left: auto; }
  .tool-nav { order: 3; width: 100%; min-height: 2.8rem; flex-basis: 100%; gap: 1.4rem; }
  .tool-nav__item { font-size: 0.73rem; }
  .editor-layout { min-height: 0; grid-template-columns: minmax(0, 1fr); }
  .workspace { min-height: 64vh; }
  .workbench { min-height: 25rem; }
  .upload-state { min-height: 25rem; padding-top: 3rem; }
  .preview-state { min-height: 28rem; }
  .options-panel { border-top: 1px solid #e2d8cf; border-left: 0; }
  .options-panel__heading { padding-block: 0.85rem; }
  .options-panel__body { max-height: none; overflow: visible; }
  .options-panel__footer { position: sticky; bottom: 0; z-index: 5; }
  .guide-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .editor-header { padding-inline: 0.7rem; }
  .btn-choose { padding-inline: 0.68rem; font-size: 0.8rem; }
  .tool-nav { gap: 1.05rem; }
  .tool-nav__item { font-size: 0.68rem; }
  .workspace { min-height: 58vh; }
  .workspace__topline, .workspace__bottomline { padding-inline: 0.8rem; font-size: 0.68rem; }
  .workspace__bottomline { align-items: flex-start; }
  .upload-state { min-height: 23rem; padding-top: 2.3rem; }
  .upload-state h2 { font-size: 1.55rem; }
  .preview-state { min-height: 25rem; padding-inline: 0.8rem; }
  .preview-caption { font-size: 0.68rem; }
  .result-card { flex-wrap: wrap; }
  .result-download { margin-left: 2.4rem; }
  .dimension-field { min-height: 3.7rem; }
  .tool-guide { padding-inline: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
