/* Foto Ikan — Marine Professional theme (matches SRND Shark AI workstation).
   Light, clean, teal-forward. Same layout as the field-tool build. */
:root {
  --bg:         #FAF9F6;
  --bg-2:       #F0F4F5;
  --white:      #FFFFFF;
  --line:       #E6F0F2;
  --line-2:     #D0DBDD;
  --text:       #2F3E46;
  --dim:        #6C7A89;
  --primary:    #0F4C5C;
  --primary-dk: #0A3A47;
  --accent:     #2A9D8F;
  --accent-ink: #FFFFFF;
  --accent-2:   #00B4D8;
  --danger:     #E76F51;
  --ok:         #2A9D8F;
  --warn:       #F4A261;

  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 20px -2px rgba(15, 76, 92, 0.09);
  --shadow-sm:  0 2px 8px -1px rgba(15, 76, 92, 0.07);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { min-height: 100dvh; }
button { font-family: inherit; color: inherit; }

#app {
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 100dvh;
}
.screen[hidden] { display: none; }

/* ───────── top bar ───────── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 14px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}
.title {
  font-size: 20px;
  font-weight: 800;
  margin: 2px 0 0;
  letter-spacing: -0.2px;
  color: var(--primary);
}
.top-bar > div:nth-child(2) { margin-left: 4px; }
.top-bar > .total-badge { margin-left: auto; text-align: right; padding-right: 4px; }
.total-label {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--dim);
  font-weight: 700;
}
.total-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  font-family: var(--mono);
}

/* ───────── buttons ───────── */
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--line);
  background: var(--white);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.icon-btn.ghost {
  border: 2px solid var(--line);
  background: var(--white);
  width: 44px;
  height: 44px;
  margin-left: auto;
}
.icon-btn.ghost.big { margin-left: 0; width: 44px; height: 44px; }
.icon-btn:active { background: rgba(42, 157, 143, 0.08); border-color: var(--accent); }

.btn-primary {
  flex: 2;
  height: 60px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.6px;
  cursor: pointer;
  text-transform: uppercase;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.btn-secondary {
  flex: 1;
  height: 60px;
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--line);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.6px;
  cursor: pointer;
  text-transform: uppercase;
  border-radius: var(--radius);
}
.btn-primary:active { filter: brightness(0.96); }
.btn-secondary:active { background: var(--bg-2); }

/* ───────── camera viewport ───────── */
.viewport {
  flex: 1;
  margin: 0 18px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: var(--shadow-sm);
}
#camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#camera[data-active="false"] { display: none; }
.stripe-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #EAF1F2 0 14px, #F4F8F8 14px 28px);
}
.stripe-fallback span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--dim);
  border: 1px solid var(--line-2);
  padding: 4px 10px;
  background: var(--white);
  border-radius: 999px;
  text-transform: uppercase;
}
#camera[data-active="true"] ~ .stripe-fallback,
.viewport[data-has-photo="true"] .stripe-fallback { display: none; }

.viewport[data-has-photo="true"] #camera { display: none; }

/* Captured photo that fills the viewport on analyzing/result */
.captured,
.result-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Reticle */
.reticle { position: absolute; inset: 0; pointer-events: none; }
.rc {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--accent);
}
.rc.tl { top: 20px; left: 20px; border-top: 3px solid var(--accent); border-left: 3px solid var(--accent); }
.rc.tr { top: 20px; right: 20px; border-top: 3px solid var(--accent); border-right: 3px solid var(--accent); }
.rc.bl { bottom: 20px; left: 20px; border-bottom: 3px solid var(--accent); border-left: 3px solid var(--accent); }
.rc.br { bottom: 20px; right: 20px; border-bottom: 3px solid var(--accent); border-right: 3px solid var(--accent); }

.viewport-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.top-icons { display: flex; gap: 8px; }

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border: 1.5px solid currentColor;
  background: var(--white);
}
.pill.offline {
  background: rgba(244, 162, 97, 0.14);
  color: var(--warn);
}
.pill.online {
  background: rgba(42, 157, 143, 0.14);
  color: var(--ok);
}
.pill.online::before {
  content: '●';
  font-size: 10px;
}

.hint-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}
.hint-strong { color: var(--accent); }
.hint-dim { color: var(--dim); }

/* Samples strip */
.samples { padding: 14px 18px 0; }
.samples-label {
  font-size: 10px;
  letter-spacing: 1.6px;
  color: var(--dim);
  font-weight: 700;
  margin-bottom: 8px;
}
.samples-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.sample-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border: 2px solid var(--line);
  padding: 0;
  background: var(--bg-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
.sample-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sample-thumb .sample-tag {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  padding: 2px 6px;
  background: rgba(15, 76, 92, 0.82);
  color: #fff;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
}
.sample-thumb:active { border-color: var(--accent); }

/* ───────── action dock ───────── */
.dock {
  padding: 16px 18px 22px;
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  gap: 12px;
  align-items: center;
}
.square-btn {
  height: 80px;
  width: 80px;
  background: var(--white);
  border: 2px solid var(--line);
  color: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-sm);
}
.square-btn.static { background: transparent; cursor: default; box-shadow: none; border-style: dashed; }
.square-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--dim);
  text-transform: uppercase;
}
.square-meta {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 1.4px;
  font-weight: 700;
}
.square-value {
  font-size: 14px;
  font-weight: 800;
  margin-top: 2px;
  color: var(--primary);
}

.shutter {
  height: 84px;
  border: 3px solid var(--accent);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
}
.shutter-inner {
  width: 100%;
  height: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.shutter:active .shutter-inner { filter: brightness(0.94); }

/* ───────── analyzing ───────── */
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
  animation: scan 1.6s linear infinite;
}
@keyframes scan {
  0%   { top: 0; }
  50%  { top: calc(100% - 3px); }
  100% { top: 0; }
}
.step-pill {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.7); }
}
.analyzing-foot {
  padding: 16px 18px 22px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.mono-dim {
  margin-left: auto;
  font-size: 12px;
  color: var(--dim);
  font-family: var(--mono);
}

/* ───────── result ───────── */
.result-photo {
  margin: 0 18px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--bg-2);
  box-shadow: var(--shadow-sm);
}
.result-box {
  position: absolute;
  border: 3px solid rgba(42, 157, 143, 0.45);
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.result-box[data-selected="true"] {
  border-color: var(--accent);
  background: rgba(42, 157, 143, 0.12);
}
.result-box.danger[data-selected="true"] {
  border-color: var(--danger);
  background: rgba(231, 111, 81, 0.14);
}
.result-box .box-label {
  position: absolute;
  top: -2px;
  left: -3px;
  transform: translateY(-100%);
  background: var(--primary);
  color: #fff;
  border: 2px solid var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 3px 8px;
  text-transform: uppercase;
  font-family: var(--mono);
  white-space: nowrap;
  border-radius: 6px;
}
.result-box[data-selected="true"] .box-label {
  background: var(--accent);
  color: var(--accent-ink);
}
.result-box.danger[data-selected="true"] .box-label {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.detail-card {
  margin: 14px 18px 0;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  box-shadow: var(--shadow-sm);
}
.detail-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.detail-name {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--primary);
}
.detail-conf {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}
.conf-bar {
  height: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.conf-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 300ms ease;
}
.detail-note {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.5;
  margin: 0;
}
.chips {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  flex-wrap: wrap;
}
.chip {
  flex: 1 1 0;
  min-width: 110px;
  padding: 12px 10px;
  background: var(--white);
  color: var(--text);
  border: 2px solid var(--line);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
}
.chip[data-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.chip[data-danger="true"][data-selected="true"] {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.chip-idx {
  font-size: 10px;
  letter-spacing: 1.5px;
  opacity: 0.7;
}

.result-actions {
  padding: 14px 18px 22px;
  display: flex;
  gap: 10px;
}

/* ───────── history ───────── */
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 20px;
}
.history-group-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 1.6px;
  font-weight: 700;
  padding: 4px 0 8px;
  text-transform: uppercase;
}
.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.history-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, #EAF1F2 0 6px, #F4F8F8 6px 12px);
  object-fit: cover;
}
.history-names {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--primary);
}
.history-meta {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
  letter-spacing: 1px;
}
.flag-shark {
  background: var(--danger);
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.empty-history {
  color: var(--dim);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 20px;
}

/* ───────── toast ───────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 92vw;
  background: var(--danger);
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 99;
}
.toast[hidden] { display: none; }
