/* ==================================================================
   Bauhaus mobile-first
   palette: black / white / red / yellow / blue
   ================================================================== */

:root {
  --bg: #f4f1ea;        /* 米白底（包豪斯常用，比纯白柔和） */
  --ink: #0a0a0a;       /* 黑 */
  --paper: #ffffff;
  --red: #e63946;
  --yellow: #f4c20d;
  --blue: #1d4ed8;
  --line: 2px solid var(--ink);
  --line-thick: 4px solid var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, "Inter", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button {
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { cursor: not-allowed; }

/* ============== HERO（极简） ============== */

.hero {
  border-bottom: var(--line-thick);
  background: var(--paper);
}
.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px;
}
.hero-title {
  font-size: 22px;
  letter-spacing: 0.18em;
  font-weight: 900;
}
.env-badge {
  display: inline-block;
  padding: 5px 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  letter-spacing: 0.15em;
  cursor: pointer;
  user-select: none;
  border: var(--line);
}
.env-badge.ok  { background: var(--blue); border-color: var(--blue); color: #fff; }
.env-badge.warn{ background: var(--yellow); border-color: var(--ink); color: var(--ink); }
.env-badge.bad { background: var(--red); border-color: var(--red); color: #fff; }

.env-hint {
  border-top: var(--line);
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  background: var(--bg);
}
.env-hint code {
  background: var(--ink);
  color: var(--paper);
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}
.env-hint .step {
  display: block;
  margin-top: 4px;
}

/* ============== MAIN ============== */

.main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 540px;
  margin: 0 auto;
}

/* 设备状态卡 */
.card {
  background: var(--paper);
  border: var(--line-thick);
  padding: 18px 16px;
  position: relative;
}
.card-label {
  font-size: 10px;
  letter-spacing: 0.25em;
  margin-bottom: 8px;
  color: var(--ink);
}
.device-card { position: relative; }
.device-card::after {
  /* 右上角红色小方块装饰 */
  content: "";
  position: absolute;
  top: -4px; right: -4px;
  width: 20px; height: 20px;
  background: var(--red);
  border: var(--line);
}
.device-name {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  word-break: break-all;
}
.device-meta {
  font-size: 12px;
  letter-spacing: 0.05em;
  color: #555;
  font-weight: 600;
  word-break: break-all;
}
.device-card.connected .device-name { color: var(--blue); }
.device-card.error     .device-name { color: var(--red); }

/* 大按钮 */
.big-btn {
  position: relative;
  width: 100%;
  min-height: 72px;
  border: var(--line-thick);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  letter-spacing: 0.18em;
  font-weight: 900;
  transition: transform 0.06s ease, box-shadow 0.06s ease, opacity 0.15s ease;
  box-shadow: 6px 6px 0 0 var(--ink);
  user-select: none;
}
.big-btn:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 3px 3px 0 0 var(--ink);
}
.big-btn:disabled {
  opacity: 0.35;
  box-shadow: 6px 6px 0 0 var(--ink);
}
.btn-text { padding: 0 8px; }

.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-blue   { background: var(--blue);   color: #fff; }
.btn-red    { background: var(--red);    color: #fff; }
.btn-black  { background: var(--ink);    color: #fff; min-height: 56px; font-size: 16px; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.action-grid .big-btn { min-height: 110px; }
.action-grid .big-btn .btn-text {
  font-size: 24px;
}

/* 日志卡 */
.log-card {
  background: var(--paper);
  border: var(--line);
  margin-top: 4px;
}
.log-card summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.2em;
}
.log-card summary::-webkit-details-marker { display: none; }
.log-card[open] summary { border-bottom: var(--line); }
.log-label { font-weight: 900; }
.log-hint  { font-weight: 600; opacity: 0.6; font-size: 10px; }
.log-body {
  padding: 10px 12px 12px;
  position: relative;
}
.ghost-btn {
  position: absolute;
  top: -28px; right: 12px;
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 4px 8px;
  border: var(--line);
  background: var(--paper);
}
#log {
  margin: 0;
  background: var(--ink);
  color: #e8e8e8;
  padding: 10px;
  height: 220px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.6;
  font-weight: 500;
  white-space: pre-wrap;
  word-break: break-all;
  letter-spacing: 0;
}
#log .l-info  { color: #e8e8e8; }
#log .l-ok    { color: #7dd3fc; }   /* 偏蓝 */
#log .l-warn  { color: var(--yellow); }
#log .l-err   { color: #ff8b8b; }
#log .l-time  { color: #888; margin-right: 6px; }

/* ============== FOOT ============== */

.foot {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 24px 16px 32px;
  font-size: 10px;
  letter-spacing: 0.3em;
  font-weight: 800;
}
.foot-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: linear-gradient(
    to right,
    var(--red) 0 33%,
    var(--yellow) 33% 66%,
    var(--blue) 66% 100%
  );
}

/* ============== 桌面端微调（移动端优先，桌面只稍作收敛） ============== */

@media (min-width: 768px) {
  .main { max-width: 480px; padding: 24px 16px; }
  .hero-title { font-size: 32px; }
}

/* ============== MODAL（包豪斯对话框，替代 alert） ============== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 0.18s ease-out;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--paper);
  border: var(--line-thick);
  box-shadow: 8px 8px 0 0 var(--ink);
  display: flex;
  animation: modalSlideIn 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* 左侧三色装饰条（红/黄/蓝），替代 emoji 与图标 */
.modal-stripe {
  flex: 0 0 14px;
  background: linear-gradient(
    to bottom,
    var(--red) 0 33.33%,
    var(--yellow) 33.33% 66.66%,
    var(--blue) 66.66% 100%
  );
  border-right: var(--line);
}
.modal.warn .modal-stripe {
  background: var(--yellow);
}
.modal.info .modal-stripe {
  background: var(--blue);
}

.modal-body {
  flex: 1;
  padding: 20px 20px 4px 20px;
  position: relative;
}

/* 右上角小方块装饰（呼应 device-card） */
.modal-card::after {
  content: "";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: var(--ink);
  border: var(--line);
}
.modal.warn .modal-card::after { background: var(--yellow); }
.modal.info .modal-card::after { background: var(--blue); }

.modal-tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.25em;
  margin-bottom: 14px;
}
.modal.warn .modal-tag { background: var(--yellow); color: var(--ink); }
.modal.info .modal-tag { background: var(--blue);   color: var(--paper); }

.modal-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.25;
  margin-bottom: 12px;
  word-break: break-word;
}
.modal-detail {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  color: #333;
  word-break: break-word;
  white-space: pre-wrap;
  /* 长文滚动 */
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.modal-actions {
  align-self: stretch;
  display: flex;
  align-items: stretch;
  padding: 18px 20px 20px 20px;
}
.modal-actions .big-btn {
  margin-left: auto;
  width: auto;
  min-width: 120px;
  min-height: 48px;
  font-size: 14px;
  letter-spacing: 0.2em;
  box-shadow: 4px 4px 0 0 var(--ink);
}
.modal-actions .big-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--ink);
}

/* 桌面端 modal 略大 */
@media (min-width: 768px) {
  .modal-card { max-width: 480px; }
  .modal-title { font-size: 26px; }
}

/* 手机端：把 actions 与 body 改为竖向布局，按钮全宽更易点 */
@media (max-width: 480px) {
  .modal-card {
    flex-direction: row;
  }
  .modal-actions {
    padding: 0 20px 20px 20px;
  }
  .modal-actions .big-btn {
    width: 100%;
    margin-left: 0;
  }
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
