:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f8fb;
  color: #152033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4ff 0, #f6f8fb 210px),
    #f6f8fb;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(760px, calc(100vw - 28px));
  margin: 18px auto 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

.topbar p {
  margin-top: 3px;
  color: #5f6e85;
}

.panel,
.status-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #dce4ef;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(26, 42, 68, 0.07);
  padding: 14px;
  margin-top: 10px;
}

.device-panel {
  display: grid;
  gap: 8px;
}

.input-panel {
  padding-bottom: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.between {
  justify-content: space-between;
}

label,
.status-title {
  font-weight: 700;
}

#sizeInfo,
.muted,
.summary-hint {
  color: #65738a;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #152033;
  background: #fff;
}

input,
select {
  min-height: 46px;
  padding: 10px 12px;
}

select {
  appearance: auto;
  font-weight: 650;
}

textarea {
  min-height: 310px;
  resize: vertical;
  margin-top: 8px;
  padding: 13px;
  line-height: 1.55;
  font-size: 16px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: #2f6fed;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14);
  outline: none;
}

.actions {
  display: grid;
  grid-template-columns: 0.9fr 1fr 1.2fr;
  gap: 9px;
  margin-top: 12px;
}

button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-action {
  background: #246bfe;
  color: #fff;
}

.accent-action {
  background: #0f766e;
  color: #fff;
}

.secondary,
.secondary-action,
.icon-button {
  background: #fff;
  border-color: #cbd5e1;
  color: #1d4ed8;
}

.icon-button,
.small-button {
  min-height: 38px;
  padding: 6px 12px;
}

.result {
  margin-top: 7px;
  min-height: 36px;
  color: #24324a;
  line-height: 1.45;
  word-break: break-word;
}

.fold-panel {
  padding: 0;
  overflow: hidden;
}

.fold-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}

.fold-panel summary::-webkit-details-marker {
  display: none;
}

.fold-panel summary::after {
  content: "展开";
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 700;
}

.fold-panel[open] summary::after {
  content: "收起";
}

.history-tools,
.token-box {
  border-top: 1px solid #e5ebf2;
  padding: 12px 14px;
}

.token-box {
  display: grid;
  gap: 7px;
}

.history {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.history-item {
  border: 1px solid #dce4ef;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcff;
  cursor: pointer;
}

.history-meta {
  color: #65738a;
  font-size: 13px;
  margin-bottom: 5px;
}

.history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error {
  color: #b42318;
}

@media (max-width: 720px) {
  body {
    background:
      linear-gradient(180deg, #eef4ff 0, #f6f8fb 170px),
      #f6f8fb;
  }

  .shell {
    width: calc(100vw - 18px);
    margin: 10px auto 26px;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    margin-bottom: 8px;
  }

  h1 {
    font-size: 23px;
  }

  .topbar p {
    font-size: 13px;
  }

  .panel,
  .status-panel {
    padding: 11px;
    margin-top: 8px;
    box-shadow: 0 5px 16px rgba(26, 42, 68, 0.06);
  }

  .compact-row {
    flex-direction: row;
    align-items: center;
  }

  input,
  select {
    min-height: 44px;
  }

  textarea {
    min-height: 42vh;
    max-height: 58vh;
    font-size: 16px;
  }

  .actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    grid-template-columns: 0.9fr 1fr 1.25fr;
    gap: 8px;
    margin: 0;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(246, 248, 251, 0.94);
    border-top: 1px solid #dce4ef;
    backdrop-filter: blur(12px);
  }

  button {
    min-height: 48px;
  }

  .actions button {
    padding: 0 8px;
    font-size: 15px;
  }

  .status-panel {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .fold-panel {
    padding: 0;
  }

  .fold-panel summary {
    min-height: 46px;
    padding: 0 12px;
  }

  .history-tools,
  .token-box {
    padding: 11px 12px;
  }

  .history {
    padding: 0 12px 12px;
  }
}
