/* zkds 共用外壳：底、表单、按钮、面板、主题切换。页面布局 CSS 后加载可覆盖。 */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background-color: var(--paper);
  font-family: var(--sans);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-image: var(--paper-bg);
  background-size: var(--paper-bg-size);
  background-attachment: fixed;
}

a, button, input, select, textarea, label, summary {
  touch-action: manipulation;
}

button, a, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea, button {
  font-family: var(--sans);
  color: var(--ink);
}

button,
select,
textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]) {
  -webkit-appearance: none;
  appearance: none;
}

input, select, textarea {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

button {
  cursor: pointer;
}

button:disabled { opacity: 0.45; cursor: default; }

.zkds-theme-switch {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 24px);
  padding: 4px 6px 4px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ink) 12%, transparent);
}

.zkds-theme-switch label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.zkds-theme-switch select {
  height: 28px;
  min-height: 28px;
  min-width: 6.5em;
  padding: 0 8px;
  width: auto;
  font-size: 16px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 6px;
}

@media (max-width: 720px) {
  body {
    background-attachment: scroll;
  }

  input[type="password"],
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px;
    min-height: 44px;
  }

  /* 有底栏的页面不要把主题切换浮在左上角，避免挡住标题；页面脚本会把它放进顶栏 */
  body.has-bottom-bar > .zkds-theme-switch {
    display: none;
  }

  body.has-bottom-bar .zkds-theme-switch label {
    display: none;
  }

  body.has-bottom-bar .zkds-theme-switch select {
    height: 36px;
    min-height: 36px;
    min-width: 5.2em;
    font-size: 16px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .zkds-theme-switch select:hover { border-color: var(--accent); }
}
