:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #dcdcdc;
  --text: #171717;
  --text-muted: #6b6b6b;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --radius: 4px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.header {
  margin-bottom: 32px;
}

.header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.dropzone {
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone.drag-over {
  outline: 1px dashed var(--accent);
  outline-offset: -8px;
}

.dropzone-empty {
  text-align: center;
  color: var(--text-muted);
}

.dropzone-empty p {
  margin: 0 0 16px;
}

.cropper-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.crop-stage {
  position: relative;
  width: 360px;
  height: 360px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  touch-action: none;
  cursor: grab;
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-stage img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  user-select: none;
  pointer-events: none;
  will-change: transform;
}

.crop-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.crop-mask.shape-square { border-radius: 0; }
.crop-mask.shape-rounded { border-radius: 20%; }
.crop-mask.shape-circle { border-radius: 50%; }

.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-position: 33.333% 0, 66.666% 0, 0 33.333%, 0 66.666%;
  background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
  background-repeat: no-repeat;
}

.crop-controls {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.control-row span {
  color: var(--text-muted);
  white-space: nowrap;
}

.control-row input[type="range"] {
  flex: 1;
}

.control-row input[type="number"] {
  width: 100px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
}

.zoom-label {
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 12px;
}

.tool-row {
  display: flex;
  gap: 6px;
}

.btn-icon {
  flex: 1;
  padding: 6px 0;
  font-size: 14px;
  line-height: 1;
}

.btn-icon.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.option-group h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.seg-btn {
  flex: 1;
  padding: 8px 0;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.seg-btn:last-child { border-right: none; }

.seg-btn.active {
  background: var(--text);
  color: var(--surface);
}

.segmented-sm {
  margin-bottom: 0;
  flex: 1;
}

.segmented-sm .seg-btn {
  padding: 5px 0;
  font-size: 12px;
}

#bgColor {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}

.check-row input {
  accent-color: var(--accent);
}

.btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.btn:hover { border-color: var(--text); }

.btn-ghost {
  background: transparent;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  padding: 11px 16px;
}

.btn-primary:disabled {
  background: var(--border);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-primary:not(:disabled):hover {
  filter: brightness(1.05);
}

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

.status.error {
  color: #c0392b;
}

.seo {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  max-width: 720px;
}

.seo h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 28px 0 10px;
}

.seo h2:first-child {
  margin-top: 0;
}

.seo p {
  margin: 0 0 12px;
  color: var(--text-muted);
}

.seo code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1px 5px;
  font-size: 12px;
}

.seo details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}

.seo summary {
  cursor: pointer;
  font-weight: 500;
}

.seo details p {
  margin: 10px 0 0;
}
