:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --ink: #14211f;
  --muted: #64716f;
  --line: #d8e1de;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #edf8f6;
  --accent: #e0a21a;
  --input: #fbfdfc;
  --danger: #b42318;
  --danger-bg: #fff0ed;
  --warning: #8a5a00;
  --thumb-bg: #edf2f0;
  --shadow: 0 16px 40px rgba(20, 33, 31, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --panel: #18212f;
  --ink: #f5f7fa;
  --muted: #a7b0be;
  --line: #303b4a;
  --primary: #2dd4bf;
  --primary-strong: #5eead4;
  --primary-soft: #123a3a;
  --accent: #f3c14b;
  --input: #101722;
  --danger: #ffb4aa;
  --danger-bg: #3b1816;
  --warning: #f3c14b;
  --thumb-bg: #111827;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 18px 14px 32px;
}

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

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.85rem, 10vw, 2.35rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 68px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.theme-toggle {
  min-width: 58px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input[type="password"],
input[type="text"],
input[inputmode="numeric"] {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--input);
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 700;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.photo-button {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  margin: 0;
  border: 1px dashed #7aa7a2;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 1.02rem;
  font-weight: 900;
}

.photo-icon {
  position: relative;
  width: 28px;
  height: 22px;
  border: 3px solid currentColor;
  border-radius: 5px;
}

.photo-icon::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 6px;
  width: 11px;
  height: 5px;
  border-radius: 3px 3px 0 0;
  background: currentColor;
}

.photo-icon::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 8px;
  width: 7px;
  height: 7px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--thumb-bg);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-thumb {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 33, 31, 0.84);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.small-button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

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

.primary-button:disabled {
  background: #93aaa6;
  color: #f5f7fa;
}

.secondary-button,
.small-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.secondary-button:disabled,
.small-button:disabled {
  color: var(--muted);
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
}

.error-box {
  margin-top: 12px;
  border: 1px solid #f1b2aa;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 800;
}

.loading-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.loading-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 900;
}

.progress-track {
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 320ms ease;
}

.loading-panel p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.results-list,
.extracted-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.results-list div {
  min-height: 48px;
}

.results-list div,
.extracted-list div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.results-list div:last-child,
.extracted-list div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

dd {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 900;
  text-align: right;
}

.results-list dd {
  color: var(--primary-strong);
}

.results-list dt,
.results-list dd {
  font-size: 1rem;
}

.extracted-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.extracted-summary + .extracted-list {
  margin-top: 12px;
}

#modelUsed {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.warning-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--warning);
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (min-width: 600px) {
  .app-shell {
    padding-top: 30px;
  }

  .panel {
    padding: 18px;
  }
}

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}
