*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 15px 15px;
  padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
             "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 18px;
  color: #1e293b;
  background: #f1f5f9;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  margin: 0 auto 12px;
  padding: 9px 3px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0 0 12px 12px;   /* 顶部贴边，上方直角、下方圆角 */
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06),
              0 1px 2px rgba(15, 23, 42, .04);
  box-sizing: border-box;
}

.app-header h1 {
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #1e293b;

}

.app-header h1 .dot {
  color: #f59e0b;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  font-size: .55em;
  vertical-align: middle;
}

.app-header p {
  margin: 4px 0 0;
  font-size: 14px;
  color: #64748b;
}

.layout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.col-left,
.col-right {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06),
              0 1px 2px rgba(15, 23, 42, .04);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.textarea {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  line-height: 18px;
  color: #1e293b;
  background: #f8fafc;
  resize: vertical;
  outline: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.textarea:focus {
  border-color: #93c5fd;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.card-input .textarea,
.card-output .textarea {
  height: 236px;
  min-height: 236px;
}

.textarea-out {
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #1e293b;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}

.btn:hover {
  background: #eef2f7;
  border-color: #cbd5e1;
}

.btn:active {
  transform: scale(.96);
}

.btn-ghost {
  height: 27px;
  padding: 0 10px;
  font-size: 14px;
  background: transparent;
  color: #64748b;
  border-color: transparent;
}

.btn-ghost:hover {
  background: #f1f5f9;
  color: #334155;
}

.btn-primary {
  background: #0C79BF;
  border-color: #0C79BF;
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.btn-stat {
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-color: #dbeafe;
  color: #1d4ed8;
  font-size: 14px;
  height: 27px;
  padding: 0 4px;
}

.btn-stat:hover {
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  border-color: #93c5fd;
}

.quick-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-row {
  display: grid;
  gap: 5px;
}

.quick-row .btn {
  height: 27px;
  padding: 0 2px;
  font-size: 14px;
  font-weight: 500;
}

.quick-3 { grid-template-columns: repeat(3, 1fr); }
.quick-4 { grid-template-columns: repeat(4, 1fr); }
.quick-5 { grid-template-columns: repeat(5, 1fr); }
.quick-6 { grid-template-columns: repeat(6, 1fr); }
.quick-7 { grid-template-columns: repeat(7, 1fr); }

.quick-7 .btn {
  font-size: 14px;
}

.wave-red {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}
.wave-red:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.wave-blue {
  color: #2563eb;
  border-color: #bfdbfe;
  background: #eff6ff;
}
.wave-blue:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.wave-green {
  color: #16a34a;
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.wave-green:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.num-input {
  flex: 1 1 64px;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  font: inherit;
  font-size: 14px;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
}

.num-input::placeholder {
  color: #cbd5e1;
}

.num-input:focus {
  border-color: #93c5fd;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.range-sep {
  color: #94a3b8;
  font-size: 14px;
}

.range-row .btn {
  height: 40px;
  padding: 0 20px;
  flex: 0 0 auto;
}

.hint {
  margin: 8px 0 0;
  font-size: 14px;
  color: #94a3b8;
}

.card-range {
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.btn-grid-stat {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 5px;
}

.app-footer {
  text-align: center;
  padding: 12px 0 12px;
}

.link-nav {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
  margin: 0 auto 10px;
  padding: 10px;
  gap: 2px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06),
              0 1px 2px rgba(15, 23, 42, .04);
}

.link-nav a {
  font-size: 14px;
  color: #1d4ed8;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.link-nav a:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

.app-footer p {
  margin: 0;
  font-size: 14px;
  color: #94a3b8;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: rgba(15, 23, 42, .9);
  color: #fff;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1000px) {
  .layout {
    flex-direction: column;
    gap: 12px;
  }

  .col-left,
  .col-right {
    display: contents;
  }

  .app-header {
  margin-bottom: 11px;
  }

  .app-footer {
   padding-top: 11px;
  }

  .card {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .card-input  { order: 1; }
  .card-quick  { order: 2; }
  .card-range  { order: 3; }
  .card-stat   { order: 4; }
  .card-output { order: 5; }

  .card-input .textarea,
  .card-output .textarea {
    height: 236px;
    min-height: 236px;
  }

  .btn-grid-stat {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  .btn-stat {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0 8px 8px;
  }

  .app-header {
  margin-bottom: 10px;
  }
  
  .app-header h1 {
   font-size: 14px;
  }

  .layout {
    gap: 10px;
  }

  .card {
    padding: 10px;
    border-radius: 10px;
  }

  .card-input .textarea,
  .card-output .textarea {
    height: 220px;
    min-height: 220px;
  }

  .quick-wrap {
    gap: 5px;
  }

  .quick-row {
    gap: 4px;
  }

  .quick-row .btn {
    height: 27px;
    font-size: 14px;
    padding: 0 1px;
  }

  .quick-7 .btn {
    font-size: 14px;
  }

  .btn-grid-stat {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .btn-stat {
    font-size: 14px;
    height: 27px;
    padding: 0 2px;
  }
}

@media (max-width: 360px) {
  .quick-row {
    gap: 3px;
  }

  .quick-row .btn {
    font-size: 14px;
    height: 27px;
  }

  .quick-7 .btn {
    font-size: 14px;
  }

  .btn-grid-stat {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn-stat {
    font-size: 14px;
  }
}

#btnClear,
#btnCopy,
#btnToggleQuick {
  background: #0C79BF;
  border-color: #0C79BF;
  color: #fff;
}

#btnClear:hover,
#btnCopy:hover,
#btnToggleQuick:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}