:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0e8;
  --blue: #2563eb;
  --blue-dark: #1e4fc2;
  --green: #047857;
  --amber: #b45309;
  --shadow: 0 16px 40px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
}

.privacy-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #b7e4cc;
  border-radius: 8px;
  background: #ecfdf3;
  color: #075e45;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 480px) 1fr;
  gap: 18px;
  align-items: stretch;
}

.upload-panel,
.result-panel,
.history-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 18px;
}

.result-panel {
  min-height: 380px;
  padding: 22px;
  display: grid;
  align-content: center;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 170px;
  padding: 20px;
  border: 2px dashed #9aa8ba;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 150ms ease,
    background-color 150ms ease;
}

.drop-zone.dragging {
  border-color: var(--blue);
  background: #eff6ff;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 800;
  letter-spacing: 0;
}

.drop-zone strong {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.drop-zone small,
.muted {
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input:disabled {
  background: #edf1f5;
  color: #98a2b3;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.check-row span {
  margin: 0;
  font-weight: 600;
}

.primary-button,
.ghost-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--blue);
  color: #fff;
}

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

.primary-button:disabled {
  background: #94a3b8;
  cursor: wait;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: #344054;
}

.ghost-button:hover {
  border-color: #98a2b3;
}

.empty-state {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.empty-state h2 {
  font-size: 24px;
}

.empty-state p,
#resultMessage {
  color: var(--muted);
  line-height: 1.7;
}

.result-state {
  display: grid;
  gap: 18px;
}

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

.metric-row div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-row strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  color: var(--green);
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.download-button {
  background: var(--green);
  color: #fff;
}

.download-button.secondary {
  background: var(--amber);
}

.history-panel {
  margin-top: 18px;
  padding: 18px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.section-title h2 {
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.history-item div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.history-item strong {
  overflow-wrap: anywhere;
}

.history-item span,
.history-item small {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 16px;
  }

  .topbar,
  .workspace,
  .metric-row,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .privacy-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .history-item div {
    display: grid;
    gap: 4px;
  }
}
