/* ========================================================================
   tools.zhangtianzuo.com — global styles
   Black & white, type-driven, photographer-friendly.
   ======================================================================== */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #6b6b6b;
  --line: #e7e7e7;
  --accent: #0a0a0a;
  --card: #fafafa;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --max: 1180px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --font-display: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", "Droid Serif", "Times", "Source Serif Pro", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #f5f5f5;
    --muted: #8a8a8a;
    --line: #1f1f1f;
    --accent: #f5f5f5;
    --card: #111;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }

img { max-width: 100%; display: block; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  max-width: var(--max);
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand svg { color: var(--accent); background: var(--bg); border-radius: 4px; }
.back-link { font-size: 14px; color: var(--muted); }
.back-link:hover { color: var(--fg); text-decoration: none; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 80px;
}

.home {
  max-width: var(--max);
  margin: 0 auto;
  padding: 80px 24px 40px;
}
.hero { max-width: 760px; margin-bottom: 64px; }
.kicker {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 18px;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
}
.hero .lead {
  font-size: 18px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 560px;
  margin: 0;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--fg);
  text-decoration: none;
}
.tool-preview {
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  position: relative;
  display: grid;
  place-items: center;
}
.tool-preview-inner {
  width: 70%;
  height: 70%;
  display: flex;
  flex-direction: column;
}
.preview-frame {
  flex: 1;
  background: #d8d8d8;
  border: 8px solid #fff;
}
.preview-bar {
  height: 32px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
}
.preview-bar::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e10600;
}
.preview-bar::after {
  content: "LEICA | 43mm f/2.2 1/250s ISO 2500";
  font: 600 9px/1 ui-monospace, monospace;
  letter-spacing: 0.05em;
  color: #000;
  text-transform: uppercase;
}
.tool-preview--placeholder {
  background: repeating-linear-gradient(45deg, #1a1a1a 0 12px, #222 12px 24px);
}
.tool-preview--placeholder::after {
  content: "Coming soon";
  color: #777;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tool-meta { padding: 18px 20px 22px; }
.tool-meta h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 6px;
}
.tool-meta p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.tool-cta {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tool-cta--muted { color: var(--muted); font-weight: 500; }
.tool-card--soon { opacity: 0.7; cursor: default; }
.tool-card--soon:hover { transform: none; box-shadow: none; border-color: var(--line); }

.page-studio { min-height: 100vh; }

.studio-app {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: calc(100vh - 65px);
}
@media (max-width: 1024px) {
  .studio-app { grid-template-columns: minmax(280px, 340px) 1fr; }
}
@media (max-width: 768px) {
  .studio-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

.studio-panel {
  border-right: 1px solid var(--line);
  padding: 18px 20px 120px;
  overflow-y: auto;
  max-height: calc(100vh - 65px);
}
@media (max-width: 768px) {
  /* Mobile: panel becomes a bottom sheet, slides up via toggle */
  .studio-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 70vh;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    background: var(--bg, #fff);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
    transform: translateY(calc(100% - 56px));
    transition: transform .28s ease;
    z-index: 9980;
    padding: 14px 20px 28px;
  }
  .studio-panel.expanded { transform: translateY(0); }
  .studio-panel::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: 2px;
    background: #ccc;
  }
}

.panel-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.panel-section:last-child { border-bottom: 0; }
.panel-section h3 {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--fg);
}
.field-label .value { font-family: var(--font-mono); color: var(--muted); }

input[type="range"] {
  width: 100%;
  accent-color: var(--fg);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  background-clip: padding-box;
  position: relative;
  flex-shrink: 0;
}
.swatch.active { border-color: var(--fg); }
.swatch.swatch--picker {
  background: conic-gradient(from 90deg, #e10600, #ff8800, #ffe600, #00d65a, #00aaff, #002fff, #a800ff, #ff00aa, #e10600);
  overflow: hidden;
}
.swatch.swatch--picker::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--bg); }
.color-text {
  flex: 1;
  font-family: var(--text-font, var(--font-mono));
  font-size: 13px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--fg);
}

.preset-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.preset {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 12px;
  cursor: pointer;
  color: var(--fg);
}
.preset:hover { border-color: var(--fg); }
.preset.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.toggle-row span { font-size: 14px; }
.switch {
  position: relative;
  width: 40px; height: 22px;
  background: var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch.on { background: var(--fg); }
.switch.on::after { transform: translateX(18px); }

select, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
}
select { cursor: pointer; }

.ratio-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ratio-pill {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.ratio-pill.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.exif-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.exif-row input { flex: 1; }
.exif-row .eye {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--muted);
}
.exif-row .eye.on { color: var(--fg); border-color: var(--fg); }
.exif-row .eye svg { width: 14px; height: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--fg);
  border-radius: 10px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { opacity: 0.9; }
.btn--ghost {
  background: transparent;
  color: var(--fg);
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.studio-canvas-wrap {
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(45deg, #f5f5f5 25%, transparent 25%),
    linear-gradient(-45deg, #f5f5f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f5f5f5 75%),
    linear-gradient(-45deg, transparent 75%, #f5f5f5 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  min-height: 60vh;
}
@media (prefers-color-scheme: dark) {
  .studio-canvas-wrap {
    background:
      linear-gradient(45deg, #161616 25%, transparent 25%),
      linear-gradient(-45deg, #161616 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #161616 75%),
      linear-gradient(-45deg, transparent 75%, #161616 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  }
}

#canvas {
  max-width: 100%;
  max-height: 75vh;
  background: var(--bg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0,0,0,0.08);
  border-radius: 4px;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 60px 40px;
  text-align: center;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  max-width: 520px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--fg);
  background: var(--bg);
}
.dropzone h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 28px;
  margin: 12px 0 8px;
}
.dropzone p { color: var(--muted); margin: 0 0 18px; }

.hidden { display: none !important; }

.studio-actions {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  gap: 12px;
  z-index: 10;
}
.studio-actions .left, .studio-actions .right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.studio-actions .filename {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.preset-saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 13px;
}
.preset-saved-item .name { font-weight: 600; }
.preset-saved-item .actions { display: flex; gap: 6px; }
.icon-btn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover { color: var(--fg); border-color: var(--fg); }
.icon-btn.danger:hover { color: #e10600; border-color: #e10600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%) translateY(20px);
  background: var(--fg);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.logo-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.logo-thumb {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
}
.logo-thumb.active { border-color: var(--fg); }
.logo-thumb.upload {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--card);
  font-size: 18px;
}

/* =========================================================
   Support Me — Ko-fi overlay (1:1 with main site)
   ========================================================= */
.support-me-trigger {
  position: fixed;
  left: 14px;
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  background: #00bfa5e0;
  color: #fff;
  font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
  font-weight: 600;
  font-size: 13px;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(23, 23, 23, .18);
  cursor: pointer;
  transition: background .16s ease, transform .16s ease, opacity .16s ease;
  opacity: .85;
  transform: scale(.92);
  transform-origin: bottom left;
}
.support-me-trigger:hover,
.support-me-trigger:focus-visible {
  background: #00bfa5;
  transform: scale(1);
  opacity: 1;
  outline: none;
}
.support-me-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  flex: 0 0 10px;
}
.support-me-modal[hidden] { display: none; }
.support-me-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: grid;
  place-items: end center;
  padding: 18px 14px max(18px, calc(env(safe-area-inset-bottom) + 14px));
  background: rgba(23, 23, 23, .28);
}
.support-me-open { overflow: hidden; }
.support-me-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  cursor: pointer;
}
.support-me-shell {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: min(390px, 100%);
  height: min(680px, 100vh - 42px);
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(23, 23, 23, .28);
}
.support-me-shell iframe {
  border: 0;
  width: 100%;
  height: 100%;
}
.support-me-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 34px;
  height: 34px;
  background: #fff;
  color: #171717;
  font: inherit;
  font-size: 28px;
  line-height: 1;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(23, 23, 23, .18);
  cursor: pointer;
}

/* Mobile "Show controls" toggle FAB (only visible ≤768px) */
.studio-toggle { display: none; }
@media (max-width: 768px) {
  .studio-toggle {
    display: inline-flex;
    position: fixed;
    right: 16px;
    bottom: 80px; /* above support-me (bottom:14 + ~30) */
    z-index: 9981;
    align-items: center;
    gap: 6px;
    background: #111;
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    font: 600 13px/1 system-ui, -apple-system, sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
  }
  .studio-toggle:hover { background: #333; }
}
