:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --text: #1d2a35;
  --muted: #627487;
  --line: #d9e5ee;
  --accent: #147ea1;
  --accent-dark: #0d607c;
  --accent-soft: #e7f5f9;
  --danger: #b23a48;
  --shadow: 0 8px 24px rgba(32, 73, 95, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "BIZ UDPGothic", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px clamp(20px, 4vw, 56px);
  color: #ffffff;
  background: linear-gradient(135deg, #126a8c, #1a93a8);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.5rem);
}

.lead {
  margin: 8px 0 0;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.file-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 700;
}

.file-button:hover,
.secondary-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.danger-button {
  background: rgba(118, 8, 22, 0.22);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.app-main {
  width: min(1200px, calc(100% - 32px));
  margin: 24px auto 64px;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(240px, 2fr);
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card,
.control-panel,
.notice-panel,
.nudibranch-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-card {
  padding: 18px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.8rem;
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-heading strong {
  margin: 0;
  font-size: 1.1rem;
}

.progress-track {
  height: 12px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef3;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.control-panel {
  display: flex;
  gap: 16px;
  align-items: end;
  padding: 18px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group.grow {
  flex: 1;
}

.field-group label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d7e1;
  border-radius: 9px;
  padding: 10px 11px;
  color: var(--text);
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(20, 126, 161, 0.16);
  border-color: var(--accent);
}

.notice-panel {
  margin-top: 16px;
  padding: 14px 18px;
  color: #365565;
  background: var(--accent-soft);
}

.message-area {
  min-height: 26px;
  padding: 10px 4px;
  color: var(--accent-dark);
  font-weight: 700;
}

.card-list {
  display: grid;
  gap: 16px;
}

.nudibranch-card {
  padding: 20px;
}

.card-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.card-number {
  display: inline-block;
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-weight: 800;
}

.card-name {
  margin: 0;
  font-size: 1.35rem;
}

.scientific-name {
  margin: 4px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.check-label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef5f7;
  white-space: nowrap;
  font-weight: 700;
}

.check-label input {
  width: auto;
}

.query-preview {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f6f9fb;
}

.query-preview > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.query-text {
  overflow-wrap: anywhere;
}

.search-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.search-button,
.small-button {
  border: 0;
  border-radius: 9px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
}

.search-button {
  padding: 9px 13px;
}

.small-button {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.search-button:hover,
.small-button:hover {
  background: var(--accent-dark);
}

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

.full-width {
  grid-column: 1 / -1;
}

.empty-message {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-header {
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .summary-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .control-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .app-main {
    width: min(100% - 20px, 1200px);
  }

  .summary-panel {
    grid-template-columns: 1fr 1fr;
  }

  .progress-card {
    grid-column: 1 / -1;
  }

  .card-heading {
    flex-direction: column;
  }

  .query-preview {
    grid-template-columns: 1fr;
  }

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

  .full-width {
    grid-column: auto;
  }

  .search-button {
    flex: 1 1 100%;
  }
}
