/* ==========================================================================
   守机宝 H5 · 报修申请 / 服务信息
   还原自 xxx.png（设计稿三块手机稿为同一套组件系统）
   设计基准：屏幕宽 740 device px ≈ 375 CSS px @DPR2
   ========================================================================== */

/* ------------------------------ 设计变量 ------------------------------ */
:root {
  /* 主色 / 功能色 */
  --c-primary: #0068d0;
  --c-primary-active: #0057ae;
  --c-primary-disabled: #a8c9ea;
  --c-link: #1e7be0;
  --c-danger: #e4393c;          /* 红色说明文案 */
  --c-required: #d0021b;        /* 必填红点 */

  /* 文本 */
  --c-text: #1a1a1a;
  --c-text-sub: #87898d;        /* 分组标题 */
  --c-placeholder: #999999;     /* 占位符 / 次要说明 */
  --c-desc: #666666;

  /* 背景 / 描边 */
  --c-page: #ffffff;
  --c-backdrop: #edeef0;
  --c-band: #eff1f5;            /* 分组灰色条 */
  --c-tile: #f6f6f6;            /* 上传格子 */
  --c-line: #f2f3f5;            /* 分隔线 */

  /* 尺寸（rem：随根字号按机型宽度等比缩放） */
  --gutter: 0.75rem;            /* 12px 内容左右留白 */
  --appbar-h: 2.75rem;          /* 44px 顶栏（设计稿 85 device px ≈ 43） */
  --row-h: 3.125rem;            /* 50px 表单行高（设计稿 98 device px ≈ 49.7） */
  --tile-size: 5.9375rem;       /* 95px 上传格子（设计稿 190 device px ≈ 96） */
  --btn-h: 2.75rem;             /* 44px 主按钮（保证手指可点） */
  --row-font: 0.8125rem;        /* 13px 表单文字（设计稿 25 device px ≈ 12.7） */
  --radius-tile: 0.375rem;
  --radius-btn: 0.5rem;

  /* 全面屏安全区 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* ------------------------------ 基础重置 ------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  /* JS 会按机型宽度改写这里；下面是无 JS 时的兜底值 */
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  font-size: 0.875rem;          /* 14px */
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-backdrop);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { border: 0; display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--c-link); text-decoration: none; }

/* 应用外壳：手机上满宽，平板/桌面上居中成一条“手机列” */
.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--c-page);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}
@media (min-width: 561px) {
  .app {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
    min-height: 100vh;
  }
}

/* ------------------------------ 顶部栏 ------------------------------ */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--c-page);
  border-bottom: 1px solid var(--c-line);
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  transition: box-shadow 0.2s ease;
}
.appbar.is-stuck { box-shadow: 0 1px 12px rgba(0, 0, 0, 0.07); }

.appbar__inner {
  height: var(--appbar-h);
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
}
.appbar__center { min-width: 0; text-align: center; }
.appbar__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__sub {
  font-size: 0.6875rem;
  line-height: 1.25;
  color: #8a8a8e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__icon {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text);
  border-radius: 50%;
}
.appbar__icon:active { background: rgba(0, 0, 0, 0.05); }
.appbar__icon--right { justify-self: end; }
.appbar__icon svg { width: 1.25rem; height: 1.25rem; display: block; }

/* 顶栏右上角菜单 */
.menu {
  position: absolute;
  top: calc(var(--safe-top) + var(--appbar-h) - 0.25rem);
  right: calc(var(--safe-right) + 0.5rem);
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.16);
  padding: 0.25rem 0;
  min-width: 8rem;
  transform-origin: top right;
  transform: scale(0.85);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.16s ease, opacity 0.16s ease, visibility 0.16s;
}
.menu.is-open { transform: scale(1); opacity: 1; visibility: visible; }
.menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}
.menu__item:active { background: #f5f6f8; }

/* ------------------------------ 页面主体 ------------------------------ */
.page {
  flex: 1 1 auto;
  padding-bottom: calc(var(--btn-h) + 2.5rem + var(--safe-bottom));
}

/* 分组灰条 */
.band {
  background: var(--c-band);
  padding: 0.375rem var(--gutter);
  padding-left: calc(var(--gutter) + var(--safe-left));
  padding-right: calc(var(--gutter) + var(--safe-right));
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.band__title {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--c-text-sub);
}
.band__note {
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--c-danger);
}

/* ------------------------------ 表单行 ------------------------------ */
.rows { background: var(--c-page); }

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--row-h);
  font-size: var(--row-font);
  padding: 0.5rem var(--gutter);
  padding-left: calc(var(--gutter) + var(--safe-left));
  padding-right: calc(var(--gutter) + var(--safe-right));
}

/* 分隔线：左右各留出内容边距 */
.row--line::after {
  content: "";
  position: absolute;
  left: calc(var(--gutter) + var(--safe-left));
  right: calc(var(--gutter) + var(--safe-right));
  bottom: 0;
  height: 1px;
  background: var(--c-line);
  transform: scaleY(0.5);
  transform-origin: bottom;
}

.row__label {
  flex: 0 0 auto;
  white-space: nowrap;
  font-weight: 500;
  color: var(--c-text);
}
/* 长句标签：独占一行，允许换行 */
.row__label--wrap {
  flex: 1 1 100%;
  min-width: 0;
  white-space: normal;
}

/* 右侧值：占满剩余空间并右对齐；flex-basis:0 保证不会挤压左侧标签 */
.row__value {
  flex: 1 1 0%;
  min-width: 0;
  text-align: right;
  word-break: break-word;
}
.row__value.is-placeholder { color: var(--c-placeholder); font-weight: 400; }

/* 必填红点 */
.req::before {
  content: "";
  flex: 0 0 auto;
  width: 0.3125rem;
  height: 0.3125rem;
  border-radius: 50%;
  background: var(--c-required);
  margin-right: -0.1875rem;
}

/* 右箭头 */
.chev {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-top: 1.5px solid #333;
  border-right: 1.5px solid #333;
  transform: rotate(45deg);
  margin-left: 0.125rem;
}

/* 行内输入框：flex-basis 必须为 0，否则 width:100% 会把左侧标签挤到一字宽 */
.row__input {
  flex: 1 1 0%;
  min-width: 0;
  width: auto;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  text-align: right;
  color: var(--c-text);
  font-size: inherit;
  appearance: none;
}
.row__input::placeholder { color: var(--c-placeholder); }

/* 可点击行 */
.row--tap { cursor: pointer; }
.row--tap:active { background: #fafbfc; }

/* 长句确认行：标签独占首行，勾选控件另起一行并右对齐 */
.row--consent { flex-wrap: wrap; }
.row--consent .consent { margin-left: auto; }

/* 说明文案（紧贴某行下方） */
.hint {
  padding: 0 var(--gutter) 0.625rem;
  padding-left: calc(var(--gutter) + var(--safe-left) + 0.3125rem);
  padding-right: calc(var(--gutter) + var(--safe-right));
  margin-top: -0.25rem;
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--c-placeholder);
}

/* 勾选 / 单选 */
.consent {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.875rem;
  color: var(--c-text);
  white-space: nowrap;
}
.consent input {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  border: 1.5px solid #c8c9cc;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
  transition: border-color 0.15s, background-color 0.15s;
}
.consent input:checked {
  border-color: var(--c-primary);
  background: var(--c-primary);
}
.consent input:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}
.consent--box input { border-radius: 0.1875rem; }
.consent--box input:checked::after {
  width: 0.25rem;
  height: 0.4375rem;
  border-radius: 0;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  background: none;
  transform: translate(-50%, -60%) rotate(45deg);
}

/* ------------------------------ 上传区 ------------------------------ */
.field {
  background: var(--c-page);
  padding: 0.625rem var(--gutter) 0.75rem;
  padding-left: calc(var(--gutter) + var(--safe-left));
  padding-right: calc(var(--gutter) + var(--safe-right));
}
.field__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.field__title {
  font-size: var(--row-font);
  font-weight: 500;
  color: var(--c-text);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.field__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.625rem;
  flex: 0 1 auto;
}
.field__link {
  font-size: 0.75rem;
  color: var(--c-link);
  white-space: nowrap;
}
.field__link:active { opacity: 0.6; }
.field__desc {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--c-desc);
}

.uploader {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 0.625rem;
}
.tile {
  position: relative;
  width: var(--tile-size);
  height: var(--tile-size);
  flex: 0 0 auto;
  border-radius: var(--radius-tile);
  background: var(--c-tile);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: #9a9a9a;
  overflow: hidden;
}
.tile:active { background: #efefef; }
.tile__icon { width: 1.875rem; height: 1.875rem; color: #c8c8c8; }
.tile__text { font-size: var(--row-font); line-height: 1; }
.tile--thumb { background: #000; }
.tile--thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile__del {
  position: absolute;
  top: 0;
  right: 0;
  width: 1.375rem;
  height: 1.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-bottom-left-radius: 0.375rem;
  color: #fff;
}
.tile__del svg { width: 0.6875rem; height: 0.6875rem; }
.tile__badge {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 0.0625rem 0.25rem;
  font-size: 0.625rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border-top-right-radius: 0.375rem;
}

/* 编号说明 */
.notes {
  border-top: 1px solid var(--c-line);
  padding: 0.625rem var(--gutter) 0.875rem;
  padding-left: calc(var(--gutter) + var(--safe-left) + 0.3125rem);
  padding-right: calc(var(--gutter) + var(--safe-right));
  counter-reset: note;
}
.notes__item {
  position: relative;
  padding-left: 0.9375rem;
  font-size: 0.75rem;
  line-height: 1.85;
  color: var(--c-placeholder);
  counter-increment: note;
}
.notes__item::before {
  content: counter(note) ".";
  position: absolute;
  left: 0;
}
.notes__item--red { color: var(--c-danger); }

/* ------------------------------ 底部操作栏 ------------------------------ */
.actionbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  z-index: 30;
  background: #fff;
  padding: 0.5rem var(--gutter) calc(0.5rem + var(--safe-bottom));
  padding-left: calc(var(--gutter) + var(--safe-left));
  padding-right: calc(var(--gutter) + var(--safe-right));
  box-shadow: 0 -1px 12px rgba(0, 0, 0, 0.06);
}
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--btn-h);
  min-height: 44px;              /* 小屏也保证手指可点 */
  border-radius: var(--radius-btn);
  background: var(--c-primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.btn-primary:active { background: var(--c-primary-active); }
.btn-primary[disabled] { background: var(--c-primary-disabled); }

/* ------------------------------ 弹层 ------------------------------ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
}
.sheet.is-open { visibility: visible; }
.sheet__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sheet.is-open .sheet__mask { opacity: 1; }
.sheet__panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  max-height: 78vh;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 1rem 1rem 0 0;
  padding-bottom: var(--safe-bottom);
  transform: translate(-50%, 100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.25, 1);
}
.sheet.is-open .sheet__panel { transform: translate(-50%, 0); }
.sheet__head {
  flex: 0 0 auto;
  position: relative;
  padding: 0.875rem var(--gutter);
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--c-line);
}
.sheet__close {
  position: absolute;
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  color: #9a9a9a;
}
.sheet__close svg { width: 1rem; height: 1rem; }
.sheet__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0 0.5rem;
}
.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3rem;
  padding: 0.25rem var(--gutter);
  font-size: 0.9375rem;
}
.option:active { background: #f7f8fa; }
.option.is-active { color: var(--c-primary); font-weight: 500; }
.option__check { width: 1rem; height: 1rem; color: var(--c-primary); visibility: hidden; }
.option.is-active .option__check { visibility: visible; }

/* 样例图预览 */
.sample {
  padding: 0.75rem var(--gutter) 1.25rem;
  text-align: center;
}
.sample__box {
  width: 100%;
  border-radius: 0.5rem;
  background: #f6f7f9;
  border: 1px dashed #dcdfe6;
  padding: 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sample__box svg { width: 6.5rem; height: 6.5rem; color: #c8c8c8; }
.sample__cap {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--c-desc);
  text-align: left;
}

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 99;
  transform: translate(-50%, -50%) scale(0.96);
  max-width: 76%;
  padding: 0.5625rem 0.9375rem;
  border-radius: 0.375rem;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.is-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* 底部安全区占位（无固定按钮的页面用） */
.safe-pad { height: var(--safe-bottom); }

/* ------------------------------ 校验失败态 ------------------------------ */
.row.is-error .row__label,
.row.is-error .row__value,
.row.is-error .row__input,
.field.is-error .field__title { color: var(--c-danger); }
.row.is-error .row__input::placeholder { color: var(--c-danger); }
.row.is-error .chev { border-color: var(--c-danger); }
.uploader.is-error .tile { background: #fdf1f1; }
.uploader.is-error .tile__icon,
.uploader.is-error .tile__text { color: #e9a3a4; }

/* ------------------------------ 横屏 / 矮屏适配 ------------------------------ */
@media (orientation: landscape) and (max-height: 480px) {
  :root {
    --appbar-h: 2.5rem;
    --row-h: 2.75rem;
    --tile-size: 4.5rem;
    --btn-h: 2.375rem;
  }
  .band { padding-top: 0.375rem; padding-bottom: 0.375rem; }
}

/* 大字号无障碍场景 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
