.account-page {
  min-height: 100vh;
}

.account-page input {
  font: inherit;
}

.account-page input:focus-visible,
.account-page a:focus-visible {
  outline: 3px solid rgba(8, 124, 112, 0.25);
  outline-offset: 3px;
}

.login-shell {
  width: min(430px, calc(100% - 32px));
  margin: clamp(42px, 10vh, 110px) auto;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-shell h1 {
  margin-bottom: 12px;
  font-size: 27px;
  line-height: 1.35;
}

.account-intro,
.login-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.account-intro {
  margin-bottom: 28px;
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form label {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
}

.login-form input:focus {
  border-color: var(--teal);
}

.login-form button {
  min-height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.login-form button:hover {
  background: var(--teal-dark);
}

.login-form button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.login-error,
.history-error {
  min-height: 18px;
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.login-help {
  margin: 25px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--soft-line);
}

.history-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 4px 28px;
}

.history-header h1 {
  font-size: 29px;
}

.history-header p:last-child {
  max-width: 640px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.history-nav {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  padding-bottom: 3px;
}

.history-nav a,
.history-nav button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--teal-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.history-nav a:hover,
.history-nav button:hover {
  text-decoration: underline;
}

.history-panel {
  padding: 26px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.history-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.history-panel-head h2 {
  margin: 0 0 5px;
  font-size: 20px;
}

.history-panel-head p,
.history-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.operator-label {
  white-space: nowrap;
}

.operator-label strong,
.history-code {
  color: var(--teal-dark);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.history-hint {
  margin-top: 13px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--soft-line);
}

.history-list {
  min-height: 90px;
}

.history-item {
  display: flex;
  align-items: stretch;
  gap: 12px;
  border-bottom: 1px solid var(--soft-line);
}

.history-open {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  flex: 1;
  min-width: 0;
  padding: 17px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-open:hover,
.history-open:focus-visible {
  background: var(--teal-soft);
}

.history-open:focus-visible,
.delete-action:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.history-when {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.history-code {
  display: block;
  font-size: 11px;
}

.history-main strong {
  font-size: 14px;
}

.history-topic {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.history-status {
  display: inline-block;
  margin-left: 9px;
  color: var(--muted);
  font-size: 11px;
}

.history-open-cue {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.delete-action,
.history-more,
.dialog-head button {
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--teal-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.delete-action:hover,
.history-more:hover,
.dialog-head button:hover {
  background: var(--teal-soft);
}

.delete-action {
  align-self: center;
  color: var(--danger);
}

.delete-action:hover {
  background: var(--danger-soft);
}

.history-more {
  display: block;
  margin: 20px auto 0;
}

.history-more[hidden] {
  display: none;
}

.history-empty {
  padding: 35px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.result-dialog {
  width: min(750px, calc(100% - 24px));
  max-height: min(88vh, 900px);
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: inherit;
}

.result-dialog::backdrop {
  background: rgba(19, 40, 58, 0.42);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.dialog-head h2 {
  margin: 0;
  font-size: 20px;
}

.result-meta {
  margin: 7px 0 18px;
  color: var(--muted);
  font-size: 12px;
}

.history-result-item {
  padding: 14px 0;
  border-top: 1px solid var(--soft-line);
}

.history-result-item strong {
  display: block;
  font-size: 14px;
}

.history-result-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.history-conditions {
  padding: 11px 13px;
  border-radius: 6px;
  background: var(--teal-soft);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.65;
}

.history-result-extra {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.history-result-extra summary {
  width: fit-content;
  color: var(--teal-dark);
  font-weight: 700;
  cursor: pointer;
}

.history-result-extra ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.history-result-extra a {
  color: var(--teal-dark);
  overflow-wrap: anywhere;
}

.history-source-meta {
  display: block;
}

@media (max-width: 700px) {
  .history-header,
  .history-panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-panel {
    padding: 20px 18px;
  }

  .history-item {
    gap: 6px;
  }

  .history-open {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 10px;
    padding: 14px 4px;
  }

  .history-when {
    grid-column: 1 / -1;
  }

  .operator-label {
    white-space: normal;
  }
}

@media (max-width: 460px) {
  .login-shell {
    padding: 28px 23px;
  }

  .history-nav {
    flex-wrap: wrap;
  }

  .history-open-cue {
    display: none;
  }
}
