/* 中医馆药壶管理系统 - HTML5 客户端样式
 * 古朴风格：深棕、古铜、米黄；楷体/仿宋；八卦/云纹元素 */

:root {
  --c-bg:        #f5e8c8;
  --c-bg-soft:   #ede0bb;
  --c-paper:     #fbf3da;
  --c-paper-trans: rgba(251, 243, 218, 0.75); /* 半透明纸张色 */
  --c-ink:       #3a2814;
  --c-brown:     #5a3a1e;
  --c-bronze:    #b08d57;
  --c-bronze-2:  #8a6a3b;
  --c-red:       #8b2a1a;
  --c-line:      #c9b07a;
  --c-empty:     #d8c89a; /* 空药壶卡片色 */
  --c-empty-trans: rgba(216, 200, 154, 0.75); /* 半透明空壶色 */
  --c-good:      #2a6b1f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

/*
 * 内置字体：
 * 把字体文件放到 client-html/assets/fonts/ 后，即使终端系统未安装字体，
 * 浏览器/Android WebView 也会通过 @font-face 加载项目内字体。
 */
@font-face {
  font-family: "YaohuJianti";
  src: url("../assets/fonts/jianti.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "YaohuFanti";
  src: url("../assets/fonts/fanti.woff2") format("woff2");
  font-display: swap;
}

body {
  font-family: "KaiTi", "STKaiti", "FangSong", "STFangsong", serif;
  background: var(--c-bg);
  color: var(--c-ink);
  user-select: none;
  /* 使用生成的木纹底纹素材 */
  background-image: url('../assets/backgrounds/wood_texture_512.png');
  background-repeat: repeat;
  background-attachment: fixed;
  background-size: 256px 256px;
}

/* 字体风格切换：作用于全局 */
body.font-jianti {
  font-family: "YaohuJianti", "KaiTi", "STKaiti", "FangSong", "STFangsong", serif !important;
  letter-spacing: 0.05em !important;
  font-weight: 400 !important;
}
body.font-fanti {
  font-family: "YaohuFanti", "KaiTi", "STKaiti", "FangSong", "STFangsong", serif !important;
  letter-spacing: 0.05em !important;
  font-weight: 400 !important;
}

button, input, select {
  font-family: inherit;
  color: var(--c-ink);
}

button {
  cursor: pointer;
  border: 1px solid var(--c-bronze-2);
  background: var(--c-paper);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 15px;
  transition: background .15s, transform .05s;
}
button:active { transform: scale(.97); }
button:hover { background: var(--c-bronze); color: #fff; }
button.primary { background: var(--c-brown); color: #fff; border-color: var(--c-brown); }
button.primary:hover { background: var(--c-red); }
button.cancel { background: #d8d2c2; }

input, select {
  border: 1px solid var(--c-line);
  background: var(--c-paper);
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 15px;
}
input:focus, select:focus { outline: 2px solid var(--c-bronze); }

.view { min-height: 100vh; display: flex; flex-direction: column; }

/* ----------- 主内容包装器（用于侧边栏布局） ----------- */
.main-content-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ----------- 空药壶侧边栏 ----------- */
.empty-sidebar {
  background: var(--c-paper-trans);
  border: 2px solid var(--c-bronze);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 10px rgba(90, 58, 30, 0.1);
  transition: background 0.3s ease;
}

/* 侧边栏标题 */
.sidebar-title {
  font-weight: bold;
  color: var(--c-brown);
  letter-spacing: 2px;
  flex-shrink: 0;
}

/* 侧边栏药壶容器 */
.sidebar-pots {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap; /* 不换行，改为滚动 */
  overflow: auto; /* 允许滚动 */
  scrollbar-width: thin; /* Firefox 细滚动条 */
  scrollbar-color: var(--c-bronze-2) transparent;
}

/* WebKit 浏览器滚动条样式 */
.sidebar-pots::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar-pots::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-pots::-webkit-scrollbar-thumb {
  background: var(--c-bronze-2);
  border-radius: 3px;
}

.sidebar-pots::-webkit-scrollbar-thumb:hover {
  background: var(--c-bronze);
}

/* 侧边栏中的药壶标签 */
.sidebar-pots .pot-tag {
  background: var(--c-empty);
  border: 2px solid var(--c-bronze-2);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.sidebar-pots .pot-tag:hover {
  background: var(--c-bronze);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(90, 58, 30, 0.3);
}

/* 竖屏模式：侧边栏在右侧 */
@media (orientation: portrait) {
  .main-content-wrapper {
    flex-direction: row;
  }
  
  .empty-sidebar {
    width: 60px;
    flex-direction: column;
    padding: 12px 4px;
    border-left: 2px solid var(--c-bronze);
    border-top: none;
    gap: 12px;
  }
  
  .sidebar-title {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: clamp(12px, 3vw, 16px);
    line-height: 1.2;
  }
  
  .sidebar-pots {
    flex-direction: column;
    align-items: center;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  .sidebar-pots .pot-tag {
    writing-mode: horizontal-tb;
    min-width: 40px;
  }
}

/* 横屏模式：侧边栏在底部 */
@media (orientation: landscape) {
  .main-content-wrapper {
    flex-direction: column;
  }
  
  .empty-sidebar {
    height: 60px;
    flex-direction: row;
    padding: 4px 12px;
    border-top: 2px solid var(--c-bronze);
    border-left: none;
    gap: 12px;
  }
  
  .sidebar-title {
    writing-mode: horizontal-tb;
    font-size: clamp(14px, 2.5vw, 18px);
    line-height: 1;
  }
  
  .sidebar-pots {
    flex-direction: row;
    align-items: center;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
  }
  
  .sidebar-pots .pot-tag {
    writing-mode: horizontal-tb;
    flex-shrink: 0;
  }
}

/* 双击状态样式 */
.pot-tag.click-once {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(90, 58, 30, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: var(--c-bronze-2);
  color: #fff;
}

.empty-sidebar.drag-over {
  background: rgba(139, 42, 26, 0.15);
  border-color: var(--c-red);
  border-width: 3px;
}

.sidebar-pots .pot-tag.long-pressing {
  background: var(--c-bronze);
  color: #fff;
  box-shadow: 0 6px 20px rgba(90, 58, 30, 0.5);
}

/* ----------- 顶部栏 ----------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, #5a3a1e 0%, #6b4928 100%);
  color: #fbf3da;
  border-bottom: 3px double var(--c-bronze);
  box-shadow: 0 2px 6px rgba(58,40,20,.25);
}
.topbar .title-zone { text-align: center; flex: 1; }
.topbar .title { font-size: 20px; letter-spacing: 6px; }
.topbar .subtitle { font-size: 12px; opacity: .85; margin-top: 2px; }
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(251,243,218,.1);
  border: 2px solid var(--c-bronze);
  color: #fbf3da;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.icon-btn:hover { background: var(--c-bronze); color: #fff; }

/* 图标按钮内图片样式 */
.icon-btn .icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

/* ----------- 标签栏 ----------- */
.tabbar {
  display: flex;
  background: var(--c-paper);
  border-bottom: 1px solid var(--c-line);
}
.tab-btn {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 12px;
  font-size: 16px;
  color: var(--c-bronze-2);
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: var(--c-brown);
  border-bottom-color: var(--c-brown);
  background: rgba(176,141,87,.08);
}

/* ----------- 列表行布局 ----------- */
.grid-area {
  flex: 1;
  padding: 6px 8px; /* 更小padding：6px 8px */
  display: flex;
  flex-direction: column;
  gap: 2px; /* 更小间距：2px */
  overflow-y: auto;
}

/* 竖屏（高度大于宽度）时：单列布局 */
@media (orientation: portrait) {
  .grid-area.two-columns {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
}

/* 横屏（宽度大于高度）时：双列布局 */
@media (orientation: landscape) {
  .grid-area.two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* 强制两列 */
    grid-auto-flow: row;
    column-gap: 4px; /* 更小列间距：4px */
    row-gap: 2px; /* 更小行间距：2px */
    align-content: start; /* 从顶部开始排列，不居中 */
  }
}
.pot-row, .med-row {
  background: var(--c-paper-trans); /* 半透明背景，透出木纹 */
  border: 1px solid var(--c-bronze); /* 细边框，节省空间 */
  border-radius: 6px; /* 减小圆角 */
  padding: 0.125rem 0.375rem; /* 更小padding：2px 6px */
  display: flex;
  align-items: center;
  gap: 0.25rem; /* 更小gap：4px */
  min-height: 1.75rem; /* 更小最小高度：28px */
  box-shadow: 0 1px 2px rgba(58,40,20,.1); /* 减弱阴影 */
  flex-shrink: 0;
}
.pot-row.empty { 
  background: var(--c-empty-trans); /* 空壶半透明背景 */
  opacity: .85; 
}

.pot-row .num {
  font-size: 1.375rem; /* 22px，更小字体 */
  font-weight: bold;
  color: var(--c-brown);
  letter-spacing: 0;
  width: 1.75rem; /* 28px，更小圆圈 */
  height: 1.75rem; /* 28px，更小圆圈 */
  line-height: 1.75rem; /* 28px，更小圆圈 */
  text-align: center;
  flex-shrink: 0;
  border: 1px solid var(--c-bronze); /* 更细边框 */
  border-radius: 50%;
}
.pot-row .med-name {
  font-size: 1.625rem; /* 26px -> rem */
  color: var(--c-ink);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pot-row .meta {
  font-size: 1.625rem; /* 26px -> rem */
  color: var(--c-bronze-2);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.pot-row .meta .boil { color: var(--c-red); }
.pot-row .meta .min  { color: var(--c-good); }

.med-row .name {
  font-size: 1.625rem; /* 26px -> rem */
  color: var(--c-brown);
  font-weight: bold;
  flex-shrink: 0;
  max-width: 256px; /* 8字符宽度：160px/5*8 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.med-row .pots {
  font-size: 1.625rem; /* 26px -> rem */
  color: var(--c-ink);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.pot-tag {
  display: inline-block;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-bronze-2);
  border-radius: 8px;
  padding: 2px 10px;
  font-size: 1.625rem; /* 26px -> rem */
  white-space: nowrap;
}

.poll-status {
  text-align: center;
  font-size: 12px;
  color: var(--c-bronze-2);
  padding: 6px;
  background: rgba(176,141,87,.06);
}

/* ----------- 未注册视图 ----------- */
.paper-box {
  margin: 60px auto;
  max-width: 460px;
  background: var(--c-paper);
  border: 2px solid var(--c-bronze);
  border-radius: 12px;
  padding: 30px 28px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(58,40,20,.18);
}
.bagua-large { font-size: 80px; color: var(--c-brown); }
.bagua-large.asset-bagua {
  width: 120px;
  height: 120px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.paper-box h2 { color: var(--c-brown); margin: 8px 0 12px; letter-spacing: 4px; }
.uid-box {
  background: var(--c-bg-soft);
  border: 1px dashed var(--c-bronze-2);
  border-radius: 6px;
  padding: 12px;
  margin: 16px 0;
  display: flex; gap: 10px; align-items: center;
}
.uid-box code {
  flex: 1; word-break: break-all;
  font-family: monospace; font-size: 14px;
  color: var(--c-red);
}

/* ----------- 灌药操作页 ----------- */
.list-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.fill-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--c-paper);
  border: 1px solid var(--c-bronze);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.fill-row .num {
  width: 3.5rem; /* 56px -> rem，可随字体缩放 */ font-size: 1.375rem; /* 22px -> rem */ font-weight: bold;
  color: var(--c-brown); text-align: center;
}
.fill-row .info { flex: 1; font-size: 0.8125rem; /* 13px -> rem */ color: var(--c-bronze-2); }
.fill-row .info .cur { color: var(--c-ink); font-size: 0.9375rem; /* 15px -> rem */ }
.fill-row .actions { display: flex; gap: 6px; }
.fill-row .actions button { padding: 6px 10px; font-size: 0.875rem; /* 14px -> rem */ }

/* ----------- 弹窗 ----------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(58,40,20,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-box {
  background: var(--c-paper);
  border: 2px solid var(--c-bronze);
  border-radius: 10px;
  padding: 16px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 28px rgba(58,40,20,.35);
}
.modal-box.small { max-width: 320px; }
.modal-box h3 {
  margin: 0 0 10px;
  text-align: center; color: var(--c-brown);
  letter-spacing: 2px;
  font-size: 16px;
}
.modal-box input[type=password],
.modal-box input[type=text],
.modal-box input:not([type]) {
  display: block; width: 100%;
  font-size: 18px; text-align: center;
  letter-spacing: 4px;
  padding: 8px;
  margin-bottom: 0;
}

/* 密码输入框：用更大更清晰的圆点字符替代默认的小点 */
.modal-box input[type=password] {
  font-size: 28px; /* 大字号让圆点清晰可见，从32px调整为28px以适配更多字符 */
  letter-spacing: 6px; /* 适中间距，既清晰又能容纳6位密码，从12px调整为6px */
  font-family: "Arial", "Helvetica", sans-serif; /* 使用无衬线字体，圆点更规整 */
  -webkit-text-security: disc; /* WebKit浏览器：使用圆盘字符 ● */
  text-security: disc; /* 标准属性（未来浏览器支持） */
}
.modal-actions {
  display: flex; gap: 8px; justify-content: center;
  margin-top: 8px;
}
.modal-actions button { min-width: 88px; }

.med-list {
  max-height: 260px; overflow-y: auto;
  margin: 8px 0; padding: 4px;
  border: 1px solid var(--c-line); border-radius: 6px;
  background: var(--c-bg-soft);
}
.med-list .med-item {
  padding: 10px 12px;
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: 4px;
  margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.med-list .med-item:hover { background: var(--c-bronze); color: #fff; }
.med-list .med-item .py { font-size: 12px; color: var(--c-bronze-2); }
.med-list .med-item:hover .py { color: #fbf3da; }

.boil-options, .pot-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
}
.boil-options button, .pot-options button {
  padding: 14px 0;
  font-size: 16px;
  background: var(--c-paper);
  border: 1.5px solid var(--c-bronze);
}
.boil-options button:hover, .pot-options button:hover {
  background: var(--c-brown); color: #fff;
}

.manual-input { margin-top: 8px; font-size: 13px; color: var(--c-bronze-2); }
.manual-input summary { cursor: pointer; }

.msg {
  margin-top: 8px;
  text-align: center;
  color: var(--c-red);
  font-size: 15px; /* 增大字体 */
  font-weight: bold; /* 加粗 */
  min-height: 20px;
  padding: 6px 12px; /* 增加内边距 */
  background: rgba(139, 42, 26, 0.1); /* 淡红色背景 */
  border-radius: 4px;
  animation: msgFadeIn 0.3s ease-out; /* 淡入动画 */
}
.msg.ok { 
  color: var(--c-good); 
  background: rgba(42, 107, 31, 0.1); /* 淡绿色背景 */
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------- 设置区域 ----------- */
.settings-area { flex: 1; padding: 14px; overflow-y: auto; }
.stab { display: none; }
.stab.active { display: block; }
.form {
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.form h4 { margin: 0 0 14px; color: var(--c-brown); letter-spacing: 2px; }
.form label { display: block; font-size: 14px; margin-bottom: 12px; }
.form input { display: block; width: 100%; margin-top: 4px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 120px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-paper);
  border: 1px solid var(--c-line);
}
.data-table th, .data-table td {
  border: 1px solid var(--c-line);
  padding: 8px 10px;
  font-size: 14px;
  text-align: left;
}
.data-table th {
  background: var(--c-bg-soft);
  color: var(--c-brown);
}
.data-table tr:nth-child(even) td { background: rgba(176,141,87,.05); }
.data-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.data-table .row-actions button { padding: 4px 8px; font-size: 12px; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid var(--c-line);
  background: var(--c-bg-soft);
}
.tag.on { background: #e6f1d8; color: var(--c-good); border-color: #9ec77a; }
.tag.off { background: #f3d8d8; color: var(--c-red); border-color: #c79e9e; }
.tag.pending { background: #fff3cf; color: #8a6a00; border-color: #d8c073; }

/* ========== 清空模式样式 ========== */
/* 标题中的字符可点击（用于触发隐藏功能） */
.title span[data-char] {
  cursor: pointer;
  transition: color .2s;
}
.title span[data-char]:hover {
  color: var(--c-bronze);
}

/* 清空模式遮罩层 */
.clear-mode-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(139, 42, 26, 0.15); /* 半透明红色 */
  z-index: 999;
  pointer-events: none; /* 允许点击穿透到下层元素 */
  animation: clearModeEnter 0.3s ease-out;
}

@keyframes clearModeEnter {
  from {
    opacity: 0;
    background: rgba(139, 42, 26, 0);
  }
  to {
    opacity: 1;
    background: rgba(139, 42, 26, 0.15);
  }
}

/* 清空模式提示文字 */
.clear-mode-tip {
  position: absolute;
  top: 8px; /* 从60px改为8px，紧贴顶部栏下方 */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(139, 42, 26, 0.95);
  color: #fff;
  padding: 8px 20px; /* 减小padding使其更紧凑 */
  border-radius: 6px; /* 略微减小圆角 */
  font-size: 14px; /* 从16px改为14px */
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(139, 42, 26, 0.4);
  pointer-events: auto; /* 提示框本身可点击（用于退出） */
  animation: tipPulse 1s ease-in-out infinite;
  white-space: nowrap;
  z-index: 1000; /* 确保在遮罩层之上 */
}

@keyframes tipPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* 清空模式下的药壶标签高亮 */
.clear-mode .pot-tag {
  cursor: pointer !important;
  background: #fff3cf !important;
  border-color: #d8a040 !important;
  color: #8a6a00 !important;
  font-weight: bold;
  animation: potTagBlink 1.5s ease-in-out infinite;
  box-shadow: 0 2px 6px rgba(216, 160, 64, 0.3);
}

.clear-mode .pot-tag:hover {
  background: #ffe89d !important;
  border-color: #b88a2a !important;
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(216, 160, 64, 0.5);
}

@keyframes potTagBlink {
  0%, 100% { box-shadow: 0 2px 6px rgba(216, 160, 64, 0.3); }
  50% { box-shadow: 0 2px 10px rgba(216, 160, 64, 0.6); }
}

/* ========== 虚拟数字键盘 ========== */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 8px 0;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  padding: 0;
}

.numpad-btn {
  padding: 15px 0;
  font-size: 24px;
  font-weight: bold;
  border: 2px solid var(--c-bronze);
  background: var(--c-paper);
  color: var(--c-brown);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  box-shadow: 0 2px 4px rgba(90, 58, 30, 0.2);
  min-height: 50px;
}

.numpad-btn:active {
  transform: scale(0.92);
  background: var(--c-bronze);
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.numpad-btn:hover {
  background: var(--c-bronze-2);
  color: #fff;
  border-color: var(--c-brown);
}

/* 删除按钮样式 */
.numpad-del {
  background: #d8d2c2;
  font-size: 32px;
  line-height: 1;
}

.numpad-del:hover {
  background: #c9b8a0;
}

.numpad-del:active {
  background: #b8a890;
}

/* 确认按钮样式 */
.numpad-ok {
  background: var(--c-brown);
  color: #fff;
  border-color: var(--c-brown);
  font-size: 32px;
  line-height: 1;
}

.numpad-ok:hover {
  background: var(--c-red);
  border-color: var(--c-red);
}

.numpad-ok:active {
  background: #6b1a0f;
}

/* 密码输入框只读状态 */
input[readonly] {
  cursor: default;
  user-select: none;
  background: var(--c-paper);
  opacity: 1;
  -webkit-opacity: 1;
}

/* 密码输入错误动画 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.input-error {
  animation: shake 0.3s;
  border-color: var(--c-red) !important;
}

/* 响应式调整 */
@media (max-width: 400px) {
  .numpad {
    gap: 8px;
    max-width: 280px;
  }
  
  .numpad-btn {
    padding: 16px 0;
    font-size: 22px;
  }
  
  .numpad-del,
  .numpad-ok {
    font-size: 28px;
  }
}

/* ========== 字母虚拟键盘 ========== */
.letter-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* 5列自适应布局 */
  gap: 4px 2px; /* 垂直间距4px，水平间距2px */
  margin: 8px 0 6px 0;
  padding: 0;
}

.letter-btn {
  padding: 5px 0;
  font-size: 14px;
  font-weight: bold;
  border: 1.5px solid var(--c-bronze);
  background: var(--c-paper);
  color: var(--c-brown);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  box-shadow: 0 1px 2px rgba(90, 58, 30, 0.2);
  min-height: 28px;
  width: 100%; /* 移除 max-width 限制，让按钮填充整个网格单元 */
}

.letter-btn:active {
  transform: scale(0.92);
  background: var(--c-bronze);
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.letter-btn:hover {
  background: var(--c-bronze-2);
  color: #fff;
  border-color: var(--c-brown);
}

/* 删除按钮样式 */
.letter-del {
  background: #d8d2c2;
  font-size: 16px; /* 缩小字体 */
  line-height: 1;
}

.letter-del:hover {
  background: #c9b8a0;
}

.letter-del:active {
  background: #b8a890;
}

/* 清空按钮样式 */
.letter-clear {
  background: var(--c-red);
  color: #fff;
  border-color: var(--c-red);
  font-size: 16px; /* 缩小字体 */
  line-height: 1;
}

.letter-clear:hover {
  background: #6b1a0f;
  border-color: #6b1a0f;
}

.letter-clear:active {
  background: #4a1209;
}

/* 药剂选择弹窗优化 */
#med-pick-modal .modal-box {
  max-width: 280px; /* 缩小为原来的 2/3：420px * 2/3 = 280px */
}

#med-pick-modal #med-search {
  margin-bottom: 0;
}

/* 响应式调整 */
@media (max-width: 400px) {
  .letter-pad {
    grid-template-columns: repeat(4, 1fr); /* 小屏幕4列 */
    gap: 5px;
  }
  
  .letter-btn {
    padding: 8px 0;
    font-size: 16px;
    min-height: 38px;
  }
  
  .letter-del,
  .letter-clear {
    font-size: 20px;
  }
}

/* ===== 悬浮时钟 ===== */
.floating-clock {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--c-paper-trans);
  backdrop-filter: blur(10px);
  color: var(--c-ink);
  padding: 12px 20px;
  border-radius: 8px;
  border: 2px solid var(--c-bronze);
  font-size: 24px;
  font-weight: bold;
  cursor: move;
  user-select: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
  touch-action: none; /* 防止触摸时页面滚动 */
}

.floating-clock:hover {
  transform: scale(1.05);
}

.floating-clock:active {
  transform: scale(0.98);
}

/* 时钟内部元素 */
.clock-time {
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
}

.clock-ganzhi {
  font-size: 11px;
  font-weight: normal;
  text-align: center;
  margin-top: 4px;
  color: var(--c-bronze-2);
  opacity: 0.9;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

@media (max-width: 600px) {
  .floating-clock {
    font-size: 20px;
    padding: 10px 16px;
    bottom: 15px;
    right: 15px;
  }
  
  .clock-time {
    font-size: 20px;
  }
  
  .clock-ganzhi {
    font-size: 10px;
    margin-top: 3px;
  }
}

/* ----------- 历史记录弹窗样式 ----------- */
.history-list {
  max-height: 500px;
  overflow-y: auto;
  margin: 16px 0;
  padding: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: 6px;
  transition: background 0.2s;
}

.history-item:hover {
  background: var(--c-bg-soft);
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-type {
  font-size: 14px;
  font-weight: bold;
  color: var(--c-brown);
  margin-bottom: 4px;
}

.history-details {
  font-size: 15px;
  color: var(--c-ink);
  margin-bottom: 4px;
  word-wrap: break-word;
}

.history-time {
  font-size: 13px;
  color: var(--c-bronze-2);
}

.history-rollback-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 14px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .history-item {
    flex-direction: column;
    align-items: stretch;
  }
  
  .history-rollback-btn {
    width: 100%;
  }
}
