* {
  box-sizing: border-box;
}

:root {
  --bg: #efefef;
  --card: #ffffff;
  --border: #dce1e9;
  --text: #1f2633;
  --muted: #667184;
  --orange: #f28c12;
  --left-red: #ef4444;
  --orange-dark: #d87709;
  --orange-soft: #fff4e7;
  --navy: #243044;
  --blue: #1ca8ff;
}

body {
  margin: 0;
  padding: 20px;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
}

.top {
  margin-bottom: 16px;
}

.brand-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 108px;
  padding: 8px 0;
  text-align: center;
}

.brand-logo {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 160px;
  max-width: 34vw;
  height: auto;
  display: block;
}

.brand-copy {
  min-width: 0;
  width: 100%;
  padding: 0 180px;
}

.brand-copy,
.brand-copy h1,
.brand-copy .subtitle {
  text-align: center;
}

h1 {
  margin: 0 0 6px;
  font-size: 36px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.upload-only {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  text-align: center;
}

.btn,
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.btn {
  background: var(--orange);
  color: #fff;
}

.btn.secondary {
  background: var(--navy);
  color: #f2f4f8;
}

.btn:disabled {
  background: #bfc5cf;
  color: #f7f7f7;
  cursor: not-allowed;
  filter: none;
}

.tab {
  background: #e7ebf1;
  color: #233045;
}

.tab.active {
  background: var(--orange);
  color: #fff;
}

.btn:hover:not(:disabled),
.tab:hover {
  filter: brightness(1.03);
}

.upload-trigger.uploaded {
  background: #bfc5cf;
  color: #233045;
}

.upload-trigger.uploaded:hover {
  filter: none;
}

.upload-trigger.hidden {
  display: none;
}

.upload-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  justify-content: center;
  min-width: 280px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 12px;
  border-radius: 12px;
  background: #f7f8fb;
  border: 1px solid #dde3eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.file-chip.hidden {
  display: none;
}

.file-side-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--orange-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.file-remove {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: #edf1f6;
  color: #445066;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-remove:hover {
  background: #dfe6ef;
}

.file-remove:focus-visible {
  outline: 2px solid rgba(242, 140, 18, 0.45);
  outline-offset: 2px;
}

.file-name {
  color: #2f3b4d;
  font-size: 14px;
  font-weight: 700;
  margin-right: 0;
  min-width: 140px;
  max-width: 260px;
  text-align: left;
  word-break: break-word;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.side-switch {
  display: flex;
  gap: 8px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.crop-status {
  flex: 1 1 260px;
  min-width: 220px;
  align-self: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(242, 140, 18, 0.12);
  color: var(--orange-dark);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.crop-status:empty {
  display: none;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 14px;
  color: #5c677b;
}

input[type="number"] {
  width: 100px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cfd6e1;
  background: #fff;
  color: var(--text);
  font-size: 15px;
}

.workspace {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

#appContent:not(.hidden) {
  display: block;
}

.mobile-topbar-slot {
  display: none;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 92px;
}

.compact-panel {
  padding: 12px 14px;
}

.panel-block h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #000;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
}

.metric-block {
  padding: 10px 0;
  border-top: 1px solid #e6e9ef;
  text-align: center;
}

.metric-block:first-of-type {
  border-top: none;
  padding-top: 0;
}

.metric-label {
  font-weight: 700;
  font-size: 14px;
  color: #2f3745;
  margin-bottom: 8px;
}

.axis-row,
.metric-sub,
.metric-value {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  justify-items: center;
}

.axis-label {
  font-weight: 800;
}

.axis-left {
  color: var(--left-red);
}

.axis-right {
  color: #22c55e;
}

.axis-top {
  color: #0ea5e9;
}

.axis-bottom {
  color: #8b5cf6;
}

.axis-sep,
.pair-sep {
  color: #8a93a3;
  font-weight: 700;
}

.pair-item {
  display: block;
  width: 100%;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.metric-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
}

.metric-value {
  margin-top: 4px;
  color: var(--blue);
  font-weight: 800;
  font-size: 14px;
  line-height: 1.45;
}

.grade-panel h3 {
  text-align: center;
  margin-bottom: 12px;
}

.grades-grid {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 12px;
  align-items: start;
}

.grades-divider {
  background: #e1e5ec;
  min-height: 92px;
}

.grades-title {
  color: var(--orange);
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 8px;
  text-align: left;
  line-height: 1.2;
}

.grades-list {
  font-size: 14px;
  line-height: 1.5;
  color: #343c4a;
  font-weight: 700;
  text-align: left;
}

.tip-box .tip-copy {
  margin: 0;
  color: #5d6778;
  line-height: 1.55;
  font-size: 14px;
}

.tip-box .tip-copy strong {
  color: #334055;
}

.tip-box .tip-copy p {
  margin: 0 0 10px;
}

.tip-box .tip-copy p:last-child {
  margin-bottom: 0;
}

.tip-box .tip-copy ul {
  margin: 0 0 10px 18px;
  padding: 0;
}

.tip-box .tip-copy li {
  margin: 0 0 8px;
}

.tip-box .tip-copy li:last-child {
  margin-bottom: 0;
}

.result-box .result-copy {
  margin: 0;
  color: #5d6778;
  line-height: 1.55;
  font-size: 14px;
}

.result-box .result-copy strong {
  color: #334055;
}

.result-box .result-copy p {
  margin: 0 0 10px;
}

.result-box .result-copy p:last-child {
  margin-bottom: 0;
}

.result-box .result-copy ul {
  margin: 0 0 10px 18px;
  padding: 0;
}

.result-box .result-copy li {
  margin: 0 0 8px;
}

.result-box .result-copy li:last-child {
  margin-bottom: 0;
}

.canvas-area {
  min-width: 0;
  display: flex;
}

.canvas-wrap {
  padding: 8px;
  overflow: visible;
  width: 100%;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 820px;
  width: auto;
  height: auto;
  background: #dcdcdc;
  border-radius: 10px;
  margin: 0 auto;
}

.hidden {
  display: none;
}

@media (max-width: 1250px) {
  .workspace {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
  }
}

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

  .left-panel,
  .right-panel {
    position: static;
  }

  .topbar {
    position: static;
  }
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .upload-only {
    align-items: center;
    justify-content: center;
    gap: 16px;
  }

  .upload-group {
    width: 100%;
    max-width: 360px;
    align-items: center;
  }

  .upload-trigger,
  .file-chip {
    width: min(100%, 320px);
    justify-content: center;
  }

  .brand-header {
    flex-direction: column;
    align-items: center;
  }

  .brand-logo {
    width: 140px;
    max-width: 60vw;
  }
}


.control-note {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}


.tip-box {
  min-height: 150px;
  max-height: 230px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.result-box {
  min-height: 0;
  max-height: calc(100vh - 185px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.result-box.synced-height {
  max-height: none;
}

.grade-panel {
  min-height: 236px;
}

.canvas-wrap {
  overscroll-behavior: auto;
  scrollbar-gutter: stable both-edges;
}

canvas {
  user-select: none;
  -webkit-user-drag: none;
}

@media (pointer: coarse) {
  .btn,
  .tab,
  .file-remove,
  .footer-link {
    min-height: 46px;
  }

  canvas {
    -webkit-tap-highlight-color: transparent;
  }
}

.result-box .next-target-callout {
  margin: 0 0 12px;
  padding: 0;
  background: none;
  border: none;
  color: #000000;
  font-weight: 900;
}

.result-box .next-target-callout strong {
  color: #000000;
}


.site-footer {
  margin: 32px 20px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-copy {
  color: #586273;
  font-size: 14px;
}

.footer-copy strong {
  color: #1f2633;
}

.footer-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link {
  border: 1px solid #d6dce5;
  background: #ffffff;
  color: #233045;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.footer-link:hover {
  border-color: #c4ccd8;
  background: #f8fafc;
}

.policy-dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(680px, calc(100vw - 24px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.policy-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.policy-dialog-card {
  margin: 0;
  padding: 0;
}

.policy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e7ebf1;
}

.policy-header h2 {
  margin: 0;
  font-size: 22px;
  color: #1f2633;
}

.policy-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: #f3f4f6;
  color: #1f2633;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.policy-body {
  padding: 18px 20px 22px;
  color: #4f5b6d;
  font-size: 15px;
  line-height: 1.65;
}

.policy-body p {
  margin: 0 0 12px;
}

.policy-body p:last-child {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  #appContent:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .brand-header {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding-top: 0;
    text-align: center;
  }

  .brand-logo {
    position: static;
    transform: none;
  }

  .brand-copy {
    padding: 0;
  }

  .brand-copy,
  .brand-copy h1,
  .brand-copy .subtitle {
    text-align: center;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .canvas-area {
    order: 1;
  }

  .mobile-topbar-slot {
    display: block;
    order: 2;
  }

  .left-panel {
    order: 3;
  }

  .right-panel {
    order: 4;
  }

  .topbar {
    margin-bottom: 0;
  }

  .topbar,
  .controls,
  .side-switch {
    justify-content: center;
  }

  .controls {
    width: 100%;
  }

  .controls .btn,
  .side-switch .tab {
    flex: 1 1 auto;
  }

  .crop-status {
    width: 100%;
    text-align: center;
  }

  .canvas-wrap {
    padding: 6px;
  }

  canvas {
    width: 100%;
    max-height: none;
    height: auto;
  }

  .tip-box {
    display: none;
  }

  .file-name {
    min-width: 0;
    text-align: left;
  }

  .site-footer {
    align-items: flex-start;
  }
}


.access-card {
  max-width: 480px;
}

.access-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.access-note {
  margin: 0;
  color: #5c6473;
  line-height: 1.5;
}

.access-label {
  font-weight: 700;
  color: #303846;
}

.access-input {
  width: 100%;
  border: 1px solid #d5dae3;
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}

.access-input:focus {
  border-color: #f28c12;
  box-shadow: 0 0 0 3px rgba(242, 140, 18, 0.14);
}

.access-error {
  min-height: 20px;
  margin: 0;
  color: #c2410c;
  font-weight: 700;
}

.access-actions {
  display: flex;
  justify-content: flex-end;
}
