:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #17201b;
  --muted: #5d665f;
  --line: #cdd5cc;
  --panel: #ffffff;
  --accent: #0e6f60;
  --accent-ink: #ffffff;
  --warn: #8f4e0c;
  --soft: #e9efe9;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  -webkit-font-smoothing: antialiased;
}

button,
select,
input,
textarea {
  font: inherit;
  font-size: 16px;
}

img,
video,
canvas {
  max-width: 100%;
}

.app {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

#status {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.error {
  color: #8f1d1d;
  min-height: 20px;
  font-size: 13px;
  font-weight: 700;
}

.panel,
.results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field.compact {
  grid-template-columns: 1fr auto;
  align-items: center;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  padding: 0 12px;
}

textarea,
input:not([type="checkbox"]) {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  overflow-wrap: anywhere;
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

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

button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  overflow-wrap: anywhere;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.icon-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.small {
  font-size: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

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

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcf9;
}

.item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.25;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.pill {
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1;
}

.pill.warn {
  background: #fff1df;
  color: var(--warn);
}

.item p,
.coach {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.item a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.coach {
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin: 10px 0;
  max-width: 100%;
}

.photo-preview figure {
  margin: 0;
}

.photo-preview img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.photo-preview figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.extract-form {
  margin-top: 12px;
}

.feedback-area {
  margin-top: 10px;
}

.success {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  margin-top: 8px;
}

.extract-json,
.kpi-box {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.login-panel {
  display: grid;
  gap: 16px;
  margin-top: 18vh;
}

@media (min-width: 680px) {
  .panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .field {
    margin-bottom: 0;
  }

  .actions {
    grid-column: 1 / -1;
  }
}
