:root {
  color: #171717;
  background: #fafaf8;
  font-family: "Lato", sans-serif;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; background: linear-gradient(180deg, #fff 0, #fafaf8 42%, #f2f0ea 100%); }

a { color: inherit; }

.grader-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  width: min(1180px, calc(100% - 40px));
  min-height: 78px;
  margin: 0 auto;
  align-items: center;
  border-bottom: 1px solid #e6e1d7;
}

.grader-brand { justify-self: start; font-family: "Playfair Display", serif; font-size: 1.34rem; letter-spacing: .13em; text-decoration: none; }
.grader-header nav { display: flex; gap: 10px; justify-self: end; }
.grader-header nav a, #collection-button { border-radius: 999px; padding: 9px 14px; font-family: inherit; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; cursor: pointer; transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease; }
.grader-header nav a { border: 1px solid #c7b679; background: rgb(255 255 255 / 72%); color: #6e5a24; box-shadow: 0 4px 12px rgb(126 94 20 / 8%); }
.grader-header nav a:hover { border-color: #9b7719; background: #f5f0e2; color: #73570e; transform: translateY(-1px); }
.grader-header nav a:focus-visible, #collection-button:focus-visible { outline: 2px solid #171717; outline-offset: 3px; }
#collection-button { justify-self: center; border: 1px solid #9b7719; background: #9b7719; color: #fff; box-shadow: 0 5px 14px rgb(126 94 20 / 18%); }
#collection-button:hover, #collection-button.is-active { background: #73570e; color: #fff; box-shadow: 0 7px 18px rgb(126 94 20 / 25%); transform: translateY(-1px); }

main { width: min(960px, calc(100% - 40px)); margin: 0 auto; padding: 72px 0 64px; }
.grader-hero { max-width: 650px; margin: 0 auto 48px; text-align: center; }
.eyebrow { margin: 0 0 11px; color: #876711; font-size: .68rem; font-weight: 700; letter-spacing: .16em; }
h1, h2 { margin: 0; font-family: "Playfair Display", serif; font-weight: 500; }
h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); letter-spacing: .065em; }
.grader-hero > p:last-child { max-width: 560px; margin: 20px auto 0; color: #5f5a51; font-size: 1.05rem; line-height: 1.65; }

.grader-panel, .grade-result, .grader-note {
  border: 1px solid #e4bf4f;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff 0%, #fafaf8 58%, #f6f4ed 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 90%), 0 14px 34px rgb(126 94 20 / 9%);
}
.grader-panel { padding: clamp(22px, 4vw, 42px); }
.panel-heading { display: flex; gap: 20px; align-items: end; justify-content: space-between; margin-bottom: 28px; }
.panel-heading h2, .result-details h2, .grader-note h2 { font-size: clamp(1.65rem, 3vw, 2.25rem); }
.credit-balance { margin: 0; color: #5d584e; font-size: .8rem; font-weight: 700; text-align: right; }

.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.image-upload { display: grid; gap: 8px; cursor: pointer; }
.image-upload input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.upload-preview { display: grid; aspect-ratio: 3 / 4; overflow: hidden; place-items: center; border: 1px dashed #b9aa7a; border-radius: 12px; background: #f7f5ef; transition: border-color 180ms ease, background-color 180ms ease; }
.image-upload:hover .upload-preview, .image-upload input:focus-visible + .upload-preview { border-color: #876711; background: #f2eee1; }
.upload-preview > span { color: #876711; font-family: "Playfair Display", serif; font-size: 2rem; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-upload strong { font-size: .81rem; letter-spacing: .1em; text-transform: uppercase; }
.image-upload small { color: #777166; font-size: .76rem; }

.grading-controls { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-top: 30px; padding: 16px; border: 1px solid #e4ded0; border-radius: 12px; background: rgb(255 255 255 / 65%); }
.accuracy-control { display: flex; gap: 15px; align-items: center; }
.accuracy-control strong, .accuracy-control span { display: block; }
.accuracy-control strong { font-size: .87rem; }
.accuracy-control span { margin-top: 3px; color: #726c60; font-size: .78rem; }
.toggle { position: relative; display: inline-flex; flex: 0 0 auto; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle > span:first-of-type { width: 44px; height: 24px; margin: 0; border-radius: 99px; background: #c9c4b9; transition: background-color 180ms ease; }
.toggle > span:first-of-type::after { display: block; width: 18px; height: 18px; margin: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 18%); content: ""; transition: transform 180ms ease; }
.toggle input:checked + span { background: #876711; }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 2px solid #171717; outline-offset: 3px; }

#grade-button { flex: 0 0 auto; border: 1px solid #876711; border-radius: 8px; padding: 13px 18px; background: #876711; color: #fff; font-family: inherit; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; transition: background-color 180ms ease, transform 180ms ease; }
#grade-button:hover:not(:disabled) { background: #6e530e; transform: translateY(-1px); }
#grade-button:disabled { cursor: wait; opacity: .62; }
.grader-message { min-height: 1.3em; margin: 14px 0 0; color: #625d52; font-size: .82rem; }
.grader-message.is-error { color: #9b3124; }

.grade-result { display: grid; grid-template-columns: 1fr 220px; gap: clamp(28px, 5vw, 56px); margin-top: 28px; padding: clamp(22px, 4vw, 42px); }
.result-score { display: grid; align-content: center; justify-items: center; min-height: 220px; border-left: 1px solid #ddd4c2; text-align: center; }
.result-score > strong { color: #876711; font-family: "Playfair Display", serif; font-size: 5rem; font-weight: 500; line-height: 1; }
.result-score > span { margin-top: 8px; font-size: .82rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.result-score small { margin-top: 12px; color: #716c62; font-size: .76rem; }
.result-details > p { margin: 16px 0 23px; color: #5f5a51; line-height: 1.6; }
.result-details dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0; }
.result-details dl div { display: grid; min-height: 100px; padding: 13px; align-content: center; border-radius: 9px; background: rgb(255 255 255 / 58%); text-align: center; }
dt { color: #876711; font-size: .66rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
dd { margin: 7px 0 0; color: #58534a; font-size: .82rem; line-height: 1.5; }
.grader-note { margin-top: 28px; padding: 28px clamp(22px, 4vw, 42px); border-color: #e4ded0; box-shadow: none; }
.grader-note h2 { font-size: 1.45rem; }
.grader-note p { max-width: 720px; margin: 10px 0 0; color: #625d52; font-size: .86rem; line-height: 1.65; }
footer { padding: 24px 20px; border-top: 1px solid #e6e1d7; color: #777166; font-size: .68rem; letter-spacing: .08em; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-view { opacity: 1; transform: translateY(0); transition: opacity 240ms ease, transform 240ms ease; }
.app-view.is-fading { opacity: 0; transform: translateY(10px); }
.collection-view { padding-bottom: 20px; }
.collection-heading { display: flex; gap: 28px; align-items: end; justify-content: space-between; margin-bottom: 28px; }
.collection-heading h1 { font-size: clamp(2.5rem, 6vw, 4rem); }
.collection-heading > div > p:last-child { margin: 12px 0 0; color: #625d52; line-height: 1.55; }
.secondary-button { border: 1px solid #a98a3b; border-radius: 8px; padding: 11px 16px; background: #fff; color: #6e530e; font-family: inherit; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; transition: background-color 180ms ease, transform 180ms ease; }
.secondary-button:hover { background: #f5f0e2; transform: translateY(-1px); }
.portfolio-panel { padding: clamp(22px, 4vw, 34px); border: 1px solid #e4bf4f; border-radius: 16px; background: linear-gradient(135deg, #fff 0%, #fafaf8 58%, #f6f4ed 100%); box-shadow: inset 0 1px 0 rgb(255 255 255 / 90%), 0 14px 34px rgb(126 94 20 / 9%); }
.portfolio-summary { display: flex; gap: 20px; align-items: end; justify-content: space-between; }
.portfolio-summary strong { display: block; font-family: "Playfair Display", serif; font-size: clamp(2.2rem, 6vw, 3.7rem); font-weight: 500; line-height: 1; }
.portfolio-summary span { display: block; margin-top: 9px; color: #716c62; font-size: .78rem; }
.portfolio-summary span.is-positive { color: #477050; }
.portfolio-summary span.is-negative { color: #9b3124; }
.graph-range { display: flex; gap: 5px; padding: 4px; border-radius: 9px; background: #efebe1; }
.graph-range button { border: 0; border-radius: 6px; padding: 7px 10px; background: transparent; color: #716c62; font-family: inherit; font-size: .67rem; font-weight: 700; cursor: pointer; }
.graph-range button.is-active { background: #fff; color: #876711; box-shadow: 0 2px 8px rgb(80 62 20 / 10%); }
.portfolio-chart { position: relative; min-height: 230px; margin-top: 22px; }
#portfolio-graph { display: block; width: 100%; height: auto; overflow: visible; }
.portfolio-area { fill: url(#portfolio-area-gradient); }
.portfolio-line { fill: none; stroke: #9b7719; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.portfolio-point { fill: #fff; stroke: #9b7719; stroke-width: 2; }
.portfolio-empty { position: absolute; inset: 0; display: grid; margin: 0; place-items: center; color: #8a8478; font-size: .82rem; text-align: center; }
.portfolio-empty[hidden] { display: none; }
.portfolio-disclaimer { margin: 14px 0 0; color: #7a7469; font-size: .72rem; line-height: 1.5; }
.collection-list-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 18px; }
.collection-list-heading h2 { font-size: 1.7rem; }
.collection-list-heading span { color: #716c62; font-size: .78rem; }
.collection-message { min-height: 1.2em; margin: -9px 0 16px; color: #716c62; font-size: .78rem; }
.collection-message.is-error { color: #9b3124; }
.collection-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.collection-card { display: grid; overflow: hidden; padding: 0; border: 1px solid #ddd4c2; border-radius: 13px; background: #fff; color: inherit; font-family: inherit; text-align: left; cursor: pointer; box-shadow: 0 8px 22px rgb(84 67 28 / 7%); transition: opacity 200ms ease, transform 220ms ease, box-shadow 220ms ease; animation: collection-card-in 360ms both; }
.collection-card:hover { transform: translateY(-4px); box-shadow: 0 13px 28px rgb(84 67 28 / 13%); }
.collection-card img { width: 100%; aspect-ratio: 3 / 4; background: #eeeae0; object-fit: cover; }
.collection-card-body { display: grid; gap: 8px; padding: 13px; }
.collection-card-body > strong { overflow: hidden; font-family: "Playfair Display", serif; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.collection-card-meta { display: flex; gap: 10px; align-items: center; justify-content: space-between; color: #6c665b; font-size: .72rem; }
.collection-card-meta strong { color: #876711; font-size: .82rem; }
.collection-empty { padding: 52px 24px; border: 1px dashed #cfc4a7; border-radius: 14px; color: #625d52; text-align: center; }
.collection-empty h2 { color: #292721; font-size: 1.6rem; }
.collection-empty p { margin: 10px 0 22px; }
.collection-card-dialog { width: min(920px, calc(100% - 30px)); max-height: calc(100vh - 30px); overflow: auto; border: 1px solid #d7c58f; border-radius: 18px; padding: clamp(24px, 4vw, 42px); background: #faf9f5; color: #171717; box-shadow: 0 28px 80px rgb(0 0 0 / 24%); }
.collection-card-dialog[open] { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); gap: clamp(24px, 4vw, 44px); animation: collection-dialog-in 260ms ease both; }
.collection-card-dialog::backdrop { background: rgb(18 16 12 / 58%); animation: collection-backdrop-in 220ms ease both; backdrop-filter: blur(5px); }
.collection-card-dialog[open].is-closing { animation: collection-dialog-out 180ms ease both; }
.collection-card-dialog.is-closing::backdrop { animation: collection-backdrop-out 180ms ease both; }
.dialog-close { position: absolute; top: 14px; right: 17px; z-index: 2; border: 0; background: transparent; color: #625d52; font-size: 1.7rem; cursor: pointer; }
.collection-card-visuals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.collection-card-visuals figure { margin: 0; }
.collection-card-visuals img { display: block; width: 100%; aspect-ratio: 3 / 4; border-radius: 12px; background: #eae6dc; object-fit: cover; box-shadow: 0 12px 28px rgb(0 0 0 / 12%); }
.collection-card-visuals figcaption { margin-top: 8px; color: #777166; font-size: .68rem; letter-spacing: .1em; text-align: center; text-transform: uppercase; }
.collection-card-info { align-self: center; }
.collection-card-info h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
.collection-card-info > p:not(.eyebrow) { color: #625d52; line-height: 1.6; }
.collection-card-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 22px 0; }
.collection-card-metrics div { padding: 14px; border: 1px solid #e2dac6; border-radius: 10px; background: #fff; text-align: center; }
.collection-card-metrics span { display: block; color: #777166; font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; }
.collection-card-metrics strong { display: block; margin-top: 6px; color: #876711; font-family: "Playfair Display", serif; font-size: 1.5rem; }
#collection-card-source { color: #876711; font-size: .74rem; font-weight: 700; }
.collection-card-actions { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-top: 22px; }
#remove-collection-card { margin-left: auto; border: 1px solid #ba6b61; border-radius: 8px; padding: 10px 13px; background: transparent; color: #913c32; font-family: inherit; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; cursor: pointer; transition: background-color 180ms ease, color 180ms ease; }
#remove-collection-card:hover:not(:disabled) { background: #913c32; color: #fff; }
#remove-collection-card:disabled { cursor: wait; opacity: .55; }
.collection-card-message { min-height: 1.2em; margin: 12px 0 0; color: #9b3124; font-size: .74rem; }

@keyframes collection-card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes collection-dialog-in { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes collection-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes collection-dialog-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes collection-backdrop-out { from { opacity: 1; } to { opacity: 0; } }

@media (min-width: 621px) {
  .grader-header { min-height: clamp(64px, 8vh, 78px); }
  main { width: min(720px, calc(100% - 40px)); padding-top: clamp(28px, 5vh, 56px); }
  .grader-hero { margin-bottom: clamp(24px, 4vh, 40px); }
  h1 { font-size: clamp(2.5rem, 5vw, 3.8rem); }
  .grader-hero > p:last-child { margin-top: 14px; font-size: 1rem; line-height: 1.55; }
  .grader-panel { padding: clamp(24px, 3vw, 32px); }
  .panel-heading { margin-bottom: clamp(18px, 2.8vh, 26px); }
  .upload-grid { max-width: min(100%, 660px, calc(56vh + 20px)); margin-inline: auto; gap: 20px; }
  .grading-controls { margin-top: clamp(18px, 2.8vh, 26px); padding: 14px; }
  .grader-message { margin-top: 10px; }
}

@media (max-width: 620px) {
  .grader-header { grid-template-columns: 1fr auto; width: min(100% - 28px, 1180px); min-height: 64px; padding: 12px 0; row-gap: 10px; }
  .grader-header nav { gap: 7px; }
  .grader-header nav a { padding: 7px 9px; font-size: .62rem; }
  .grader-brand { font-size: 1.05rem; }
  #collection-button { grid-column: 1 / -1; grid-row: 2; padding: 7px 10px; font-size: .64rem; }
  main { width: min(100% - 28px, 960px); padding-top: 46px; }
  .panel-heading, .grading-controls { align-items: flex-start; flex-direction: column; }
  .credit-balance { text-align: left; }
  #grade-button { width: 100%; }
  .grade-result { grid-template-columns: 1fr; }
  .result-score { order: -1; min-height: auto; padding-bottom: 26px; border-left: 0; border-bottom: 1px solid #ddd4c2; }
  .result-details dl { grid-template-columns: 1fr; }
  .collection-heading, .portfolio-summary { align-items: flex-start; flex-direction: column; }
  .collection-heading .secondary-button { width: 100%; }
  .collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .collection-card-body { padding: 10px; }
  .portfolio-chart { min-height: 180px; }
  .collection-card-dialog[open] { grid-template-columns: 1fr; }
  .collection-card-info { text-align: center; }
  .collection-card-actions { flex-direction: column; }
  #remove-collection-card { margin-left: 0; }
}
