:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #182026;
  --muted: #5d6972;
  --line: #d9e0e5;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --shadow: 0 16px 36px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 20px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.15rem;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 172px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.settings-panel,
.pane,
.controls {
  display: grid;
  gap: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f5;
  margin-bottom: 18px;
}

.tab-button,
.primary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.tab-button {
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab-button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 8px rgba(24, 32, 38, 0.08);
}

.pane {
  display: none;
}

.pane.active {
  display: grid;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  color: var(--muted);
}

.primary-button {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 18px;
  white-space: nowrap;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  background: #aab5bb;
  cursor: not-allowed;
}

.icon-button {
  width: 46px;
  flex: 0 0 46px;
  background: var(--ink);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 900;
}

.crop-workspace {
  display: grid;
  place-items: center;
  min-height: 360px;
  background:
    linear-gradient(45deg, #e6ecef 25%, transparent 25%),
    linear-gradient(-45deg, #e6ecef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6ecef 75%),
    linear-gradient(-45deg, transparent 75%, #e6ecef 75%);
  background-color: #f9fbfc;
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

canvas {
  width: 240px;
  height: 320px;
  max-width: 100%;
  border-radius: 4px;
  background: #111820;
  box-shadow: 0 12px 28px rgba(24, 32, 38, 0.18);
}

.controls {
  grid-template-columns: 1fr 1fr;
}

input[type="range"] {
  padding: 0;
  min-height: 30px;
  accent-color: var(--accent);
}

.status {
  display: block;
  margin-top: 18px;
  min-height: 44px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: #e9f6f4;
  color: var(--ink);
  border-radius: 8px;
}

.status.error {
  border-left-color: var(--danger);
  background: #fff0ee;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .layout,
  .field-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .topbar {
    padding-bottom: 14px;
  }

  .crop-workspace {
    min-height: 336px;
  }

  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }
}
