:root {
  color-scheme: light;
  font-family: "Be Vietnam Pro", "Noto Sans", "Segoe UI", Roboto, Arial, sans-serif;

  --bg-grad-1: #f5f7fa;
  --bg-grad-2: #e4edf9;
  --text-main: #1f2937;
  --text-muted: #4b5563;

  --card-bg: #ffffffcc;
  --card-border: #d1d5db;
  --card-shadow: rgba(0, 0, 0, 0.05);

  --surface-bg: #f8fafc;
  --surface-border: #e2e8f0;

  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --focus-border: #2563eb;
  --focus-ring: #bfdbfe;

  --btn-bg: #2563eb;
  --btn-bg-hover: #1d4ed8;
  --btn-text: #ffffff;

  --mini-btn-bg: #e2e8f0;
  --mini-btn-bg-hover: #cbd5e1;
  --mini-btn-border: #cbd5e1;
  --mini-btn-text: #0f172a;

  --status-success-bg: #dcfce7;
  --status-success-text: #166534;
  --status-error-bg: #fee2e2;
  --status-error-text: #991b1b;

  --protocol-bg: #eff6ff;
  --protocol-border: #bfdbfe;
  --protocol-text: #1e3a8a;

  --notice-bg: #fff7ed;
  --notice-border: #fdba74;
  --notice-text: #9a3412;
}

body.theme-dark {
  color-scheme: dark;

  --bg-grad-1: #0b1220;
  --bg-grad-2: #111a2c;
  --text-main: #e5e7eb;
  --text-muted: #94a3b8;

  --card-bg: rgba(15, 23, 42, 0.8);
  --card-border: #334155;
  --card-shadow: rgba(2, 6, 23, 0.4);

  --surface-bg: #0f172a;
  --surface-border: #334155;

  --input-bg: #0b1220;
  --input-border: #334155;
  --focus-border: #60a5fa;
  --focus-ring: rgba(96, 165, 250, 0.35);

  --btn-bg: #3b82f6;
  --btn-bg-hover: #2563eb;
  --btn-text: #ffffff;

  --mini-btn-bg: #1e293b;
  --mini-btn-bg-hover: #334155;
  --mini-btn-border: #334155;
  --mini-btn-text: #e2e8f0;

  --status-success-bg: #14532d;
  --status-success-text: #bbf7d0;
  --status-error-bg: #7f1d1d;
  --status-error-text: #fecaca;

  --protocol-bg: #172554;
  --protocol-border: #1d4ed8;
  --protocol-text: #bfdbfe;

  --notice-bg: #3f1d07;
  --notice-border: #9a3412;
  --notice-text: #fed7aa;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--bg-grad-1), var(--bg-grad-2));
  color: var(--text-main);
  overflow-x: hidden;
}

.container {
  max-width: 880px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

h1 {
  margin-bottom: 0.25rem;
}

.subtitle {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 25px var(--card-shadow);
}

.key-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.key-actions button {
  min-width: 170px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.check-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--btn-bg);
}

.password-row {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
}

.password-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.password-toggle-btn {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 0.45rem 0.62rem;
  font-size: 0.82rem;
  line-height: 1.1;
  white-space: nowrap;
  border-radius: 6px;
  background: var(--mini-btn-bg);
  color: var(--mini-btn-text);
  border: 1px solid var(--mini-btn-border);
}

.password-toggle-btn:hover {
  background: var(--mini-btn-bg-hover);
}

@media (max-width: 720px) {
  .key-actions {
    grid-template-columns: 1fr;
  }

  .actions button {
    width: 100%;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

input,
select,
button {
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
  background: var(--input-bg);
  color: var(--text-main);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

button {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--btn-bg-hover);
}

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

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Be Vietnam Pro", "Noto Sans", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 0.8rem;
}

.key-info-empty {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 0.8rem;
  color: var(--text-muted);
}

.key-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}

.info-item {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.info-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

.protocol-list {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.45rem;
}

.protocol-item {
  background: var(--protocol-bg);
  border: 1px solid var(--protocol-border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  color: var(--protocol-text);
}

.result-empty {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 0.8rem;
  color: var(--text-muted);
}

.result-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.7rem;
}

.result-actions {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.3rem;
}

.section-head h2 {
  margin: 0;
}

.mini-btn {
  background: var(--mini-btn-bg);
  color: var(--mini-btn-text);
  border: 1px solid var(--mini-btn-border);
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

.mini-btn:hover {
  background: var(--mini-btn-bg-hover);
}

.theme-icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.collapse-body {
  margin-top: 0.55rem;
}

.collapse-body.is-collapsed {
  display: none;
}

.status-pill-error {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

.notice-box {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  color: var(--notice-text);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 768px) {
  .container {
    margin: 1rem auto;
    padding: 0 0.75rem;
  }

  h1 {
    margin-top: 0;
    margin-bottom: 0.2rem;
    font-size: 1.95rem;
    line-height: 1.15;
  }

  .subtitle {
    margin-bottom: 1rem;
    font-size: 0.98rem;
    line-height: 1.4;
  }

  .card {
    padding: 0.9rem;
    border-radius: 10px;
  }

  .page-head {
    flex-direction: row;
    align-items: flex-start;
  }

  .grid,
  .key-info-grid,
  .result-summary-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .key-actions {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .key-actions button {
    width: 100%;
    min-width: 0;
  }

  .actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .actions button,
  .result-actions button {
    width: 100%;
  }

  .section-head {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .section-head .mini-btn {
    margin-left: auto;
  }

  .protocol-item {
    font-size: 0.9rem;
  }

  .notice-box {
    font-size: 0.95rem;
    line-height: 1.5;
  }
}

@media (max-width: 480px) {
  .container {
    margin: 0.75rem auto;
    padding: 0 0.55rem;
  }

  h1 {
    font-size: 1.7rem;
  }

  label {
    font-size: 0.88rem;
    margin-bottom: 0.65rem;
  }

  .info-value {
    font-size: 0.92rem;
  }

  .theme-icon-btn {
    width: 40px;
    height: 40px;
  }

  .password-toggle-btn {
    min-width: 58px;
    padding: 0.45rem 0.5rem;
  }
}
