:root {
  --ink: #0d0d0d;
  --paper: #f7f4ed;
  --rust: #b8331a;
  --warn: #e8b923;
  --steel: #8a8a85;
  --soft: #ede9e1;
  --bg: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 3px solid var(--ink);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-svg {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-family: "Noto Serif JP", serif;
  font-size: 16px;
  font-weight: 700;
}

.header-sub {
  font-size: 13px;
  color: var(--rust);
  letter-spacing: 0.1em;
  font-weight: 500;
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: calc(100vh - 140px);
}

.screen {
  display: none;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.title {
  font-family: "Noto Serif JP", serif;
  font-size: 28px;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--steel);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: var(--steel);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--soft);
  border-radius: 4px;
  font-size: 16px;
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: var(--rust);
}

.upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--paper);
  border: 2px dashed var(--rust);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 16px;
  min-height: 180px;
}

.upload-btn:hover, .upload-btn:active {
  background: var(--soft);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 13px;
  color: var(--steel);
}

.loading-content {
  text-align: center;
  padding: 60px 20px;
}

.preview {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border: 4px solid var(--soft);
  border-top-color: var(--rust);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 18px;
  font-weight: 700;
}

.loading-hint {
  font-size: 13px;
  color: var(--steel);
  margin-top: 4px;
}

.result-title {
  font-family: "Noto Serif JP", serif;
  font-size: 24px;
  margin-bottom: 20px;
  padding-left: 12px;
  border-left: 5px solid var(--rust);
}

.result-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.result-card {
  background: var(--paper);
  padding: 16px;
  border-radius: 6px;
}

.result-label {
  font-size: 12px;
  color: var(--steel);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.result-value {
  font-size: 15px;
  font-weight: 500;
}

.result-value-big {
  font-size: 24px;
  font-weight: 700;
  color: var(--rust);
}

.result-value-big::after {
  content: " kcal";
  font-size: 14px;
  color: var(--steel);
  font-weight: 400;
}

.pfc-card {
  background: var(--ink);
  color: white;
  padding: 18px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.pfc-label {
  font-size: 12px;
  color: var(--warn);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.pfc-bars {
  display: grid;
  gap: 10px;
}

.pfc-bar {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.pfc-name {
  color: rgba(255,255,255,0.85);
}

.pfc-amount {
  font-weight: 700;
}

.balance-card {
  background: var(--paper);
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  border-left: 4px solid var(--warn);
}

.balance-score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-weight: 700;
}

.balance-comment {
  font-size: 14px;
  color: var(--ink);
}

.points-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.points-card {
  padding: 16px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--soft);
}

.points-card h3 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--rust);
}

.points-card ul {
  list-style: none;
  padding: 0;
  font-size: 13px;
}

.points-card li {
  padding: 4px 0;
  padding-left: 12px;
  position: relative;
}

.points-card li::before {
  content: "・";
  position: absolute;
  left: 0;
}

.trainer-card {
  background: var(--paper);
  padding: 20px;
  border-radius: 8px;
  border: 2px solid var(--rust);
  margin-bottom: 20px;
}

.trainer-title {
  font-family: "Noto Serif JP", serif;
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--ink);
}

.trainer-hint {
  font-size: 13px;
  color: var(--steel);
  margin-bottom: 12px;
}

.trainer-message {
  background: var(--bg);
  padding: 16px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 14px 16px;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 48px;
}

.btn-primary {
  background: var(--rust);
  color: white;
}

.btn-primary:hover, .btn-primary:active {
  background: #9d2a16;
}

.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--ink);
}

.btn-secondary:hover, .btn-secondary:active {
  background: var(--soft);
}

.disclaimer {
  font-size: 11px;
  color: var(--steel);
  margin-top: 16px;
  text-align: center;
}

.error-content {
  text-align: center;
  padding: 60px 20px;
}

.error-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--warn);
  color: var(--ink);
  font-size: 32px;
  font-weight: 900;
}

.error-content h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

#error-message {
  color: var(--steel);
  margin-bottom: 24px;
}

.app-footer {
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--steel);
}

.accent-line {
  height: 4px;
  background: linear-gradient(90deg,
    var(--ink) 0%, var(--ink) 60%,
    var(--rust) 60%, var(--rust) 80%,
    var(--warn) 80%, var(--warn) 100%);
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .title { font-size: 32px; }
  .subtitle { font-size: 16px; }
  .upload-btn { min-height: 220px; }
  .result-title { font-size: 28px; }
}

@media (max-width: 480px) {
  .points-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
}
