:root {
  --nen: #F6F3EE;
  --the: #FFFFFF;
  --chu: #1F2421;
  --mo: #5E625D;
  --vien: #E3DDD3;
  --chinh: #2F5D50;
  --chinh-dam: #244A3F;
  --nhan: #B5651D;
  --loi: #B3261E;
  --bo: 14px;
  --bo-nho: 10px;
  --bong: 0 1px 2px rgba(31,36,33,.06), 0 6px 20px rgba(31,36,33,.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: clip; }
body {
  margin: 0; background: var(--nen); color: var(--chu);
  font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  min-height: 100svh;
}
[hidden] { display: none !important; }
h1, h2 { letter-spacing: -0.01em; margin: 0; }
button, a, label, .chip { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
input, select { font-size: max(16px, 1rem); font-family: inherit; }

.logo { font-weight: 700; font-size: 17px; color: var(--chinh); }
.logo span { color: var(--nhan); margin: 0 4px; }

/* Nút */
.nut {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font: 600 16px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none;
}
.nut:active { opacity: .85; }
.nut-chinh { background: var(--chinh); color: #fff; }
.nut-chinh:hover { background: var(--chinh-dam); }
.nut-chinh:disabled { background: #8FA59D; cursor: wait; }
.nut-phu { background: var(--the); color: var(--chinh); border-color: var(--chinh); }
.nut-chu { background: none; border: 0; color: var(--chinh); font: 600 15px inherit; font-family: inherit; min-height: 44px; padding: 0 8px; cursor: pointer; }

/* Đăng nhập */
.dang-nhap { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.the-dang-nhap {
  width: 100%; max-width: 380px; background: var(--the); border-radius: 20px; padding: 28px 24px;
  box-shadow: var(--bong); display: grid; gap: 14px;
}
.the-dang-nhap h1 { font-size: 24px; }
.the-dang-nhap .mo { color: var(--mo); margin: -6px 0 4px; font-size: 14px; }
.the-dang-nhap label { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }
.the-dang-nhap input, .luoi-3 input {
  min-height: 50px; padding: 0 14px; border: 1px solid var(--vien); border-radius: var(--bo-nho); background: #FDFCFA; color: var(--chu);
}
input:focus-visible, .nut:focus-visible, .chip:focus-visible, .the-pc:focus-visible { outline: 3px solid rgba(47,93,80,.35); outline-offset: 2px; }
.loi { color: var(--loi); font-weight: 500; margin: 0; }

/* Khung ứng dụng */
.dau {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: var(--the); border-bottom: 1px solid var(--vien);
  position: sticky; top: 0; z-index: 20;
}
.bo-cuc { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.cot-nhap { display: grid; gap: 14px; padding-bottom: calc(84px + var(--safe-bottom)); }
.khoi { background: var(--the); border-radius: var(--bo); padding: 18px 16px; box-shadow: var(--bong); }
.khoi h2 { font-size: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.khoi h2 b {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--chinh); color: #fff; font-size: 14px;
}
.phu { color: var(--mo); font-weight: 400; font-size: 13px; }
.nhan { font-weight: 600; font-size: 14px; margin: 14px 0 8px; }
.goi-y { color: var(--mo); font-size: 14px; margin: 0 0 12px; }
.luoi-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.luoi-3 label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--mo); }
.luoi-3 input { width: 100%; }
.ghi-loi { color: var(--loi); font-size: 14px; margin: 10px 0 0; }

/* Chip */
.hang-chip { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--vien);
  background: #FDFCFA; color: var(--chu); font: 500 15px inherit; font-family: inherit; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--chinh); border-color: var(--chinh); color: #fff; }

/* Tải bản vẽ */
.o-tai {
  display: grid; place-items: center; min-height: 120px; border: 2px dashed var(--vien); border-radius: var(--bo);
  background: #FBF9F5; cursor: pointer; text-align: center; padding: 12px; color: var(--chinh); font-weight: 600; position: relative;
}
.o-tai input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.o-tai img { max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 8px; }
.o-tai img { background: #fff; border: 1px solid var(--vien); }
.o-tai[aria-busy="true"] { opacity: .7; cursor: progress; }
#tt-ban-ve { margin: 8px 0 0; }
.chon-trang { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 15px; }
.chon-trang select { font: inherit; font-size: 16px; min-height: 44px; padding: 0 10px; border: 1px solid var(--vien); border-radius: 8px; background: #fff; }

/* Chuyển ngoại/nội */
.chuyen { display: grid; grid-template-columns: 1fr 1fr; background: #EFEAE2; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 6px; }
.chuyen-nut { min-height: 44px; border: 0; border-radius: 9px; background: transparent; font: 600 15px inherit; font-family: inherit; color: var(--mo); cursor: pointer; }
.chuyen-nut.dang { background: var(--the); color: var(--chinh); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Thẻ phong cách */
.luoi-the { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.the-pc {
  display: grid; text-align: left; padding: 0; border: 2px solid transparent; border-radius: var(--bo);
  background: #FBF9F5; overflow: hidden; cursor: pointer; font-family: inherit; color: var(--chu);
}
.the-pc img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #E9E4DB; }
.the-pc .ten { font-weight: 600; font-size: 15px; padding: 10px 10px 2px; }
.the-pc .mo-ta { font-size: 13px; color: var(--mo); padding: 0 10px 8px; line-height: 1.4; }
.the-pc .mau { display: flex; gap: 4px; padding: 0 10px 12px; }
.the-pc .mau i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); }
.the-pc[aria-pressed="true"] { border-color: var(--chinh); background: #F1F6F3; }
.the-pc[aria-pressed="true"] .ten::after { content: " ✓"; color: var(--chinh); }

/* Món */
.nhom-mon + .nhom-mon { margin-top: 4px; }
.trong-mon { color: var(--mo); font-size: 14px; }

/* Nút tạo dính đáy (điện thoại) */
.thanh-tao {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(10px + var(--safe-bottom)); background: rgba(246,243,238,.96);
  border-top: 1px solid var(--vien); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.nut-tao { width: 100%; min-height: 54px; font-size: 17px; }

/* Kết quả */
.cot-ket-qua { background: var(--the); border-radius: var(--bo); padding: 14px; box-shadow: var(--bong); align-self: start; }
.khung-anh { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #EFEAE2; display: grid; place-items: center; }
.khung-anh img { width: 100%; height: 100%; object-fit: cover; }
.trong { text-align: center; padding: 20px; color: var(--mo); font-size: 14px; }
.dang-tao { text-align: center; color: var(--chinh); font-weight: 600; }
.vong { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #CFDCD6; border-top-color: var(--chinh); margin: 0 auto 10px; animation: quay 0.9s linear infinite; }
@keyframes quay { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) { .vong { animation-duration: 3s; } }
.nhan-ai { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--nhan); }
.thong-tin p { margin: 8px 0; }
.hang-nut { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
details { font-size: 13px; color: var(--mo); }
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 500; }
.cau-mo-ta { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #F6F3EE; padding: 10px; border-radius: 8px; word-break: break-word; }
.chan { text-align: center; color: var(--mo); font-size: 12px; padding: 8px 16px calc(96px + var(--safe-bottom)); }

/* Máy tính: 2 cột, ảnh đứng yên bên phải */
@media (min-width: 960px) {
  .bo-cuc { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; padding: 24px; gap: 24px; }
  .cot-ket-qua { position: sticky; top: 76px; }
  .luoi-the { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cot-nhap { padding-bottom: 0; }
  .thanh-tao { position: sticky; bottom: 0; background: linear-gradient(rgba(246,243,238,0), var(--nen) 35%); border: 0; padding: 20px 0 16px; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .chan { padding-bottom: 24px; }
}
