:root {
  color-scheme: light;
  --ink: #18201b;
  --muted: #66736b;
  --line: #d7e0da;
  --panel: #ffffff;
  --page: #eef2ed;
  --accent: #117a65;
  --accent-2: #c96b45;
  --good: #1f8f5f;
  --watch: #c78018;
  --risk: #c64735;
  --shadow: 0 18px 50px rgba(26, 38, 30, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(17, 122, 101, 0.09), transparent 38%),
    linear-gradient(315deg, rgba(201, 107, 69, 0.12), transparent 42%),
    var(--page);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
.upload-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

button {
  background: #f9fbf9;
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled),
.upload-button:hover {
  border-color: #9db8aa;
  transform: translateY(-1px);
}

button:disabled {
  color: #9aa59e;
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(16px, 3vw, 36px);
}

.workspace {
  max-width: 1180px;
  margin: 0 auto;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.3rem, 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-pill {
  border: 1px solid #cfd9d2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 0.92rem;
  min-width: 118px;
  padding: 9px 14px;
  text-align: center;
}

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

.panel {
  border: 1px solid rgba(217, 225, 219, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
}

.section-heading h2,
.ai-card h2 {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.section-heading p,
.notice,
#scoreText,
#aiAssessment {
  color: var(--muted);
  line-height: 1.5;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.year-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

.preview-frame {
  position: relative;
  display: grid;
  min-height: 250px;
  aspect-ratio: 4 / 5;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(23, 33, 27, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(23, 33, 27, 0.05) 1px, transparent 1px),
    #f4f7f4;
  background-size: 30px 30px;
}

.preview-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.year-card.has-photo .preview-frame img {
  display: block;
}

.year-card.has-photo .empty-preview {
  display: none;
}

.empty-preview {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-preview strong {
  color: var(--ink);
  font-size: 2.4rem;
  line-height: 1;
}

.year-card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.year-label,
.score-label,
.detail-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.year-card-footer strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.year-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-button,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  border-color: #0d6d5a;
  padding: 0 18px;
}

.action-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

#uploadHint {
  color: var(--muted);
}

.side-panel {
  padding: 18px;
}

.score-block {
  display: grid;
  gap: 6px;
}

#scoreValue {
  font-size: clamp(3.2rem, 9vw, 6rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.meter {
  height: 12px;
  margin: 18px 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), var(--watch), var(--risk));
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-right: 4px solid #17211b;
  background: rgba(255, 255, 255, 0.5);
  transition: width 180ms ease;
}

.detail-grid,
.ai-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf9;
  padding: 10px;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.ai-card {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.ai-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

#aiStatus {
  border: 1px solid #cfd9d2;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  max-width: 150px;
  padding: 5px 8px;
  text-align: center;
}

.year-breakdown {
  display: grid;
  gap: 8px;
}

.year-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.year-result span {
  color: var(--accent);
  font-weight: 850;
}

.year-result strong {
  display: block;
  margin-top: 3px;
}

.year-result p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.ai-card ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.42;
}

.ai-card li:first-child {
  color: var(--ink);
  list-style: none;
  margin-left: -18px;
}

.notice {
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 0.88rem;
}

@media (max-width: 980px) {
  .masthead {
    align-items: start;
    flex-direction: column;
  }

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

  .side-panel {
    order: -1;
  }
}

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

  .preview-frame {
    aspect-ratio: 16 / 10;
    min-height: 220px;
  }

  .action-bar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

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

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