/* FotoClara Studio (full-screen editor): loaded only on the editor page, after style.css. */
/* FotoClara Studio Mode (Full-Screen Photo Editor) */
body.studio-open {
  overflow: hidden;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.tool.studio .editor-shell {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.tool.studio .ai-progress,
.tool.studio .status:not(:empty) {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1001;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  margin: 0;
  max-width: min(500px, 90vw);
}

.tool.studio .status:not(:empty) {
  padding: 10px 18px;
}

/* Studio Top Bar */
.studio-top {
  height: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  flex-shrink: 0;
}

.studio-top .btn {
  min-height: 36px;
  height: 36px;
  padding: 6px 12px;
  font-family: var(--body);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
}

.studio-top .btn.ghost {
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.studio-top .btn.ghost:hover {
  background: var(--card);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.studio-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.studio-brand .logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font: 760 1.18rem/1 var(--display);
  font-stretch: 118%;
  letter-spacing: -.02em;
}

.studio-brand .logo svg {
  width: 28px;
  height: 28px;
}

.studio-brand .logo b {
  font-weight: 860;
  color: var(--accent);
}

.studio-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.studio-back .ico svg {
  width: 18px;
  height: 18px;
}

.studio-history {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.studio-history .btn {
  padding: 6px 10px;
}

.studio-history .btn .ico svg {
  width: 16px;
  height: 16px;
}

.editor-zoom {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--paper);
  padding: 2px 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.editor-zoom .btn {
  min-height: 28px;
  height: 28px;
  padding: 0 8px;
  box-shadow: none;
  background: transparent;
  color: var(--ink);
}

.editor-zoom .btn:hover {
  background: var(--card);
  color: var(--accent);
  box-shadow: none;
}

.editor-zoom .btn .ico svg {
  width: 16px;
  height: 16px;
}

.editor-zoom .zoom-level {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
  min-width: 44px;
  text-align: center;
  user-select: none;
}

.studio-top [data-act=compare] .ico svg,
.btn-open-new .ico svg {
  width: 18px;
  height: 18px;
}

.studio-spacer {
  flex: 1;
}

.btn-open-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--body);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  border: 0;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s, filter .15s;
}

.btn-download:hover {
  filter: brightness(1.08);
}

.btn-download:active {
  transform: translateY(1px);
}

.btn-download .ico svg {
  width: 18px;
  height: 18px;
}

/* Studio Workspace Body */
.studio-body {
  display: grid;
  grid-template-columns: 84px 300px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Studio Tool Rail */
.studio-rail {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  gap: 2px;
  scrollbar-width: thin;
}

.studio-rail .tab-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 10px 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  color: var(--ink-2);
  transition: all .15s ease;
  text-align: center;
}

.studio-rail .tab-chip .ico {
  font-size: 1.35rem;
  line-height: 1;
  color: inherit;
  transition: transform .15s ease;
}

.studio-rail .tab-chip .ico svg {
  width: 22px;
  height: 22px;
}

.studio-rail .tab-chip .tab-label {
  font-family: var(--body);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  padding: 0 4px;
}

.studio-rail .tab-chip:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: var(--ink);
}

.studio-rail .tab-chip:hover .ico {
  transform: translateY(-1px);
}

.studio-rail .tab-chip.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.studio-rail .tab-chip.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Studio Options Panel */
.studio-panel {
  background: var(--paper);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px;
  scrollbar-width: thin;
}

.editor-panel-bar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ed-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise .2s ease-out;
}

.ed-panel[hidden] {
  display: none !important;
}

.ed-panel h4 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.ed-panel h4 .ico svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.btn-auto {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-family: var(--body);
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: none;
}

.btn-auto:hover {
  background: color-mix(in srgb, var(--accent) 15%, var(--card));
  border-color: var(--accent);
  filter: none;
}

.btn-auto:active {
  transform: translateY(1px);
}

.btn-auto .ico svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.studio-panel label {
  font-family: var(--body);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

.studio-panel label:has(input[type=range]) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 0;
}

.studio-panel label:has(input[type=range]) output {
  font-family: var(--body);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  letter-spacing: normal;
  text-transform: none;
}

.studio-panel label:has(input[type=range]) input[type=range] {
  grid-column: 1 / -1;
  width: 100%;
}

.studio-panel select,
.studio-panel textarea,
.studio-panel input[type=color] {
  width: 100%;
  font-family: var(--body);
  font-size: 0.88rem;
}

.studio-panel textarea {
  min-height: 58px;
  resize: vertical;
}

.studio-panel .filter-grid {
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.studio-panel .filter {
  padding: 5px;
  font-size: 0.78rem;
}

.studio-panel .chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.studio-panel .chip {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.82rem;
}

.studio-panel .btn {
  font-size: 0.85rem;
  border-radius: 6px;
}

.studio-panel .btn.small {
  min-height: 34px;
  padding: 6px 10px;
}

.studio-panel .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.studio-panel .hint {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
  background: var(--card);
  border-left: 3px solid var(--amber);
  border-radius: 0 4px 4px 0;
}

.ed-panel[data-panel=transform] .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ed-panel[data-panel=transform] .btn {
  width: 100%;
  padding: 8px 6px;
  font-size: 0.8rem;
}

.ed-brush-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.ed-brush-row label {
  width: 100%;
}

/* Studio Canvas Stage */
.editor-stage-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background-color: #e5e7eb;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .75) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .75) 1px, transparent 1px);
  background-size: 20px 20px;
}

:root[data-theme="dark"] .editor-stage-wrap {
  background-color: #111827;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .06) 1px, transparent 1px);
}

.editor-preview {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}

.editor-preview canvas {
  display: block;
  max-width: 100% !important;
  max-height: calc(100vh - 120px) !important;
  width: auto !important;
  height: auto !important;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, .4), 0 0 0 1px rgba(0, 0, 0, .08);
  border-radius: 4px;
  transition: transform .12s ease-out;
}

.editor-preview.retouching canvas {
  cursor: crosshair;
}

/* Studio Toast */
.studio-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 22px;
  border-radius: 999px;
  font-family: var(--body);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 1002;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  animation: rise .25s ease-out;
  pointer-events: none;
  white-space: nowrap;
}

.studio-toast[hidden] {
  display: none !important;
}

/* Studio Save Dialog */
.save-dialog {
  width: min(440px, 92vw);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.save-dialog::backdrop {
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(4px);
}

.save-dialog form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.save-dialog h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--ink);
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preset {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
  padding: 12px 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.preset input[type=radio] {
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.preset b {
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
}

.preset small {
  font-family: var(--body);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.3;
}

.preset:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.preset:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--paper));
}

.save-advanced {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.save-advanced summary {
  font-family: var(--body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
}

.save-advanced summary:hover {
  color: var(--accent);
}

.save-advanced label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-family: var(--body);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

.save-advanced label:has(input[type=range]) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 0;
}

.save-advanced label:has(input[type=range]) output {
  font-family: var(--body);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  letter-spacing: normal;
  text-transform: none;
}

.save-advanced label:has(input[type=range]) input[type=range] {
  grid-column: 1 / -1;
  width: 100%;
}

.save-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.save-actions .btn {
  min-height: 42px;
  padding: 8px 18px;
  font-family: var(--body);
  font-size: 0.95rem;
  border-radius: 8px;
}

.btn-save-main {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn-save-main:hover {
  filter: brightness(1.08);
}

.btn-save-main .ico svg {
  width: 18px;
  height: 18px;
}

/* Studio Mobile Responsive (<= 760px) */
@media (max-width: 760px) {
  .studio-top {
    padding: 0 10px;
    gap: 6px;
  }

  .studio-brand {
    gap: 6px;
  }

  .studio-brand .logo span {
    display: none;
  }

  .studio-top .btn {
    padding: 6px 8px;
  }

  .studio-top .btn:not(.btn-download) .lbl {
    display: none;
  }

  .editor-zoom {
    display: none;
  }

  .btn-download {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  .studio-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
    height: calc(100vh - 60px);
  }

  .editor-stage-wrap {
    order: 1;
    min-height: 0;
  }

  .studio-panel {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    max-height: 38vh;
    padding: 14px;
  }

  .studio-rail {
    order: 3;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 0 4px;
    gap: 4px;
    scrollbar-width: none;
  }

  .studio-rail::-webkit-scrollbar {
    display: none;
  }

  .studio-rail .tab-chip {
    width: 64px;
    min-width: 64px;
    padding: 8px 2px;
  }

  .studio-rail .tab-chip.active::before {
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: 100%;
    height: 3px;
    border-radius: 0 0 2px 2px;
  }

  .editor-preview {
    padding: 12px;
  }
}

/* background tab: the brush ring replaces the pointer; the pickers fit the narrow panel */
.editor-preview.retouching canvas { cursor: none; }
.ed-panel .colorset .picker { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 12px 2px; }
.ed-panel .colorset .dot { width: 40px; height: 40px; }
.ed-panel .ws-modes { margin-top: 6px; }
.ed-brush-row { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
.ed-brush-row[hidden] { display: none; }

.ed-brush-row .field-label { text-align: left; }
