.entry-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto 16px;
}

.entry-method {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.entry-method b { font-size: .9rem; }
.entry-method span { color: var(--muted); font-size: .68rem; }
.entry-method.active {
  color: #fff;
  border-color: var(--teal);
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  box-shadow: 0 10px 25px #076b6525;
}
.entry-method.active span { color: #d7fff5; }

.manual-start {
  display: grid;
  place-items: center;
  min-height: 390px;
  padding: 35px;
  text-align: center;
}
.manual-start h2 { margin: 8px 0 0; }
.manual-start p { max-width: 430px; margin: 5px auto 20px; color: var(--muted); }
.manual-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 0;
  padding: 0;
  border-radius: 18px;
  color: var(--teal-dark);
  background: var(--mint);
  font-family: inherit;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.manual-icon:hover { transform: translateY(-2px); box-shadow: 0 8px 20px #0b766f26; }
.manual-icon:active { transform: translateY(0); }
.manual-icon:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 3px; }

.manual-mode .review-layout { grid-template-columns: 1fr; }

@media (max-width: 520px) {
  .entry-method { padding: 11px; }
  .manual-start { min-height: 310px; padding: 22px; }
}

/* A one-option tab bar is noise: hide it when AI scan is switched off. */
.entry-choice.single-method { display: none; }

/* ---- Manual entry: one product group, many number lines ---- */
.order-group .line-head,
.order-group .order-line {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr)) 74px 74px 62px 34px;
  gap: 8px;
  align-items: center;
}
.order-group .line-head {
  margin: 10px 0 2px;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .6;
}
.order-group .order-line { margin-bottom: 7px; }
.order-group .lf { display: block; }
.order-group .lf input { width: 100%; }
.order-group .delete-line {
  width: 34px; height: 34px; padding: 0; line-height: 1;
  border: 1px solid #d9c2c0; border-radius: 8px;
  background: #fff; color: #b23b32; font-size: 1rem; cursor: pointer;
}
.order-group .delete-line:hover { background: #fff0ed; }
.order-group .add-line {
  margin-top: 4px; padding: 7px 12px;
  border: 1px dashed #9dc6bf; border-radius: 9px;
  background: transparent; color: #0b766f;
  font: inherit; font-size: .72rem; font-weight: 700; cursor: pointer;
}
.order-group .add-line:hover { background: #eef8f5; }

/* On a phone the column header is dropped and each field labels itself.
   Number gets the full width because it is the field being read off the paper;
   the amounts pair up beneath it, Big beside Small and A beside C, which is
   how they are written down. */
@media (max-width: 640px) {
  .order-group .line-head { display: none; }
  .order-group .order-line {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 6px;
    padding: 11px 10px;
    margin-bottom: 11px;
    border: 1px solid #dde7e5;
    border-radius: 12px;
    background: #fbfdfd;
  }
  .order-group .lf::before {
    content: attr(data-label);
    display: block; margin-bottom: 4px;
    font-size: .55rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: .01em; opacity: .6; white-space: nowrap;
  }
  .order-group .order-line input { padding: 9px 5px; text-align: center; }
  .order-group .lf:first-child input { padding: 9px 10px; text-align: left; }

  /*
   * Row one is the number and the three bet-type buttons; row two is the four
   * amounts. The cells are in DOM order - number, big, small, a, c, ibox, box,
   * 4A - so each is placed by hand rather than left to auto-flow.
   */
  .order-group .order-line .lf:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .order-group .order-line .lf:nth-child(6) { grid-column: 3; grid-row: 1; }
  .order-group .order-line .lf:nth-child(7) { grid-column: 4; grid-row: 1; }
  .order-group .order-line .lf:nth-child(2) { grid-column: 1; grid-row: 2; }
  .order-group .order-line .lf:nth-child(3) { grid-column: 2; grid-row: 2; }
  .order-group .order-line .lf:nth-child(4) { grid-column: 3; grid-row: 2; }
  .order-group .order-line .lf:nth-child(5) { grid-column: 4; grid-row: 2; }
  .order-group .order-line .lf:nth-child(8) { grid-column: 1; grid-row: 3; }
  /* The button already says 4A+, so the column label above it is noise on the
     row it shares with Remove. */
  .order-group .order-line .lf:nth-child(8)::before { display: none; }
  .order-group .order-line .four-panel { grid-column: 1 / -1; grid-row: 4; }
  .order-group .delete-line {
    grid-column: 2 / -1;
    grid-row: 3;
    align-self: center;
    justify-self: end;
    width: auto; height: auto;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: .68rem; font-weight: 700;
  }
  .order-group .delete-line::after { content: ' Remove'; }
}

/* ---- "Same amounts for every number" ---- */
.same-amounts {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 10px 0 2px;
  padding: 9px 11px;
  border: 1px solid #cfe4e0;
  border-radius: 10px;
  background: #f4fbf9;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
}
.same-amounts input { width: auto; margin: 2px 0 0; flex: none; }
.same-amounts small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 500;
}

/* Locked: only the first line keeps its amount boxes. The other lines keep
   their values in the DOM, so unticking gives them straight back. */
.order-group.amounts-locked .order-line:not(:first-child) .lf:not(:first-child) {
  display: none;
}
/* Columns are pinned explicitly: with the amount boxes hidden, auto-placement
   would drop the note after the remove button instead of before it. */
.order-group.amounts-locked .order-line:not(:first-child) .lf:first-child {
  grid-column: 1 / 5;
  grid-row: 1;
}
.order-group.amounts-locked .order-line:not(:first-child)::after {
  content: '↑ same / 相同';
  grid-column: 5;
  grid-row: 1;
  align-self: center;
  white-space: nowrap;
  color: var(--muted);
  font-size: .62rem;
  font-style: italic;
}
.order-group.amounts-locked .order-line:not(:first-child) .delete-line {
  grid-column: 6;
  grid-row: 1;
}
@media (max-width: 640px) {
  .order-group.amounts-locked .order-line:not(:first-child) .lf:first-child {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .order-group.amounts-locked .order-line:not(:first-child)::after {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .order-group.amounts-locked .order-line:not(:first-child) .delete-line {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

/* ---- Optional product icons ---- */
.product-picker .product-icon {
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 5px;
  object-fit: contain;
  vertical-align: middle;
}

/* ---- Phase 4.1: AI Scan as a button on the manual page ---- */
/* The heading is space-between, so without this the button would float to the
   middle. Pushing it left keeps it beside the title, with "Start Again" still
   pinned to the far right. */
.panel-heading .ai-scan-entry {
  margin-right: auto;
  min-height: 36px;
  padding: 0 13px;
  font-size: .7rem;
}
.panel-heading .ai-scan-entry::before {
  content: '⌗';
  margin-right: 6px;
  font-size: .85rem;
}

/* On a phone the heading wraps; the button takes its own full-width row so it
   never squeezes the title down to two characters. */
@media (max-width: 520px) {
  .panel-heading { flex-wrap: wrap; }
  .panel-heading .ai-scan-entry { order: 2; width: 100%; margin-right: 0; }
  .panel-heading #back-to-photo { order: 3; }
}


/* ---- Box / IBOX switches ---- */
/* A pressed state has to be obvious at a glance: staff read these back to the
   customer, and a missed toggle is a wrong bet. Colour carries the signal --
   no pseudo-element, which a button renders inconsistently. */
.order-group .order-line .bet-toggle {
  width: 100%;
  min-height: 34px;
  padding: 0 6px;
  border: 1px solid #bfd0cd;
  border-radius: 9px;
  background: #fff;
  color: #64777e;
  font: inherit;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.order-group .order-line .bet-toggle:hover {
  border-color: #9dc6bf;
  background: #f2fbf9;
}
.order-group .order-line .bet-toggle[aria-pressed="true"] {
  color: #fff;
  border-color: #0b8b82;
  background: #0b8b82;
  box-shadow: 0 4px 12px #0b8b8233;
}
.order-group .order-line .bet-toggle[aria-pressed="true"]:hover {
  background: #076b65;
  border-color: #076b65;
}
.order-group .order-line .bet-toggle:focus-visible {
  outline: 3px solid #076b65;
  outline-offset: 2px;
}

/* ---- "Others" products, tucked behind a button ---- */
.product-picker .others-toggle {
  padding: 6px 11px;
  border: 1px dashed #9dc6bf;
  border-radius: 8px;
  background: #fff;
  color: #0b766f;
  font: inherit;
  font-size: .62rem;
  font-weight: 800;
  cursor: pointer;
}
.product-picker .others-toggle:hover { background: #eef8f5; }
.product-picker .others-toggle::after { content: ' \25be'; }
.product-picker .others-toggle[aria-expanded="true"]::after { content: ' \25b4'; }
/* Its own full-width row, so opening it does not shuffle the front row. */
.product-picker .product-others {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed #d8e5e3;
}


/* ---- 4A bet: a button that opens five amount boxes ---- */
.order-group .order-line .four-toggle {
  width: 100%;
  min-height: 34px;
  padding: 0 4px;
  border: 1px dashed #9dc6bf;
  border-radius: 9px;
  background: #fff;
  color: #0b766f;
  font: inherit;
  font-size: .68rem;
  font-weight: 800;
  cursor: pointer;
}
.order-group .order-line .four-toggle:hover { background: #eef8f5; }
.order-group .order-line .four-toggle[aria-expanded="true"] {
  border-style: solid;
  border-color: #0b8b82;
  background: #e6f6f3;
}
/* Its own full-width row under the line it belongs to. */
.order-group .order-line .four-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
  padding-top: 10px;
  border-top: 1px dashed #cfe0dc;
}
.order-group .order-line .four-panel .ff { display: block; }
.order-group .order-line .four-panel .ff::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 3px;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .04em;
  opacity: .6;
}
.order-group .order-line .four-panel input {
  width: 100%;
  padding: 8px 6px;
  border: 1px solid #bfd0cd;
  border-radius: 8px;
  text-align: center;
}
/* A locked group hides the follower lines' amounts; hide their 4A panel too. */
.order-group.amounts-locked .order-line:not(:first-child) .four-panel { display: none; }

@media (max-width: 640px) {
  .order-group .order-line .four-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* ---- Softer corners on the order line ---- */
/* The boxes read as square at small sizes; a wider radius matches the cards
   they sit inside. */
.order-group .order-line input,
.order-group .order-line .four-panel input {
  border-radius: 13px;
}
.order-group .order-line .bet-toggle,
.order-group .order-line .four-toggle {
  border-radius: 13px;
}
.order-group .order-line { border-radius: 16px; }
/* One height for every control on the line so the inputs and the bet-type
   buttons share a baseline; without it the buttons ride a few pixels high. */
.order-group .order-line > .lf > input,
.order-group .order-line .bet-toggle,
.order-group .order-line .four-toggle {
  min-height: 38px;
}
@media (max-width: 640px) {
  .order-group .order-line input,
  .order-group .order-line .four-panel input,
  .order-group .order-line .bet-toggle,
  .order-group .order-line .four-toggle {
    border-radius: 14px;
  }
  /* One height for every control on the line, so the number box and the three
     buttons sit on the same baseline instead of 6px apart. */
  .order-group .order-line > .lf > input,
  .order-group .order-line .bet-toggle,
  .order-group .order-line .four-toggle {
    min-height: 42px;
  }
  /* Each cell is label-above-control, and the labels are not all the same
     height (CJK sits taller than plain ASCII). Centring each cell would stagger
     the controls, so the cells bottom-align and the controls share a baseline. */
  .order-group .order-line { align-items: end; }
}

/* ---- Customer output: room to read on a phone ---- */
/* The label column eats a third of a narrow screen, and 100px of textarea is
   about four lines - too few once a row produces a straight, box, ibox and 4A
   line each. */
@media (max-width: 640px) {
  .output-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }
  .output-card > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
  .output-card small { margin-top: 0; }
  .output-card textarea {
    min-height: 240px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.8;
  }
}
