:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --control: #ffffff;
  --control-hover: #f8fafc;
  --subtle-bg: #f8fafc;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d8dee8;
  --line-soft: #e7ebf0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-ring: rgba(37, 99, 235, 0.12);
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --danger-line: rgba(180, 35, 24, 0.22);
  --warning: #8a5a00;
  --warning-bg: #fff8e1;
  --warning-line: rgba(138, 90, 0, 0.22);
  --success: #0f7a4f;
  --success-bg: #f0fdf4;
  --success-line: rgba(15, 122, 79, 0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141414;
  --card: #1f2023;
  --control: #18191c;
  --control-hover: #27292f;
  --subtle-bg: #18191c;
  --text: #f3f4f6;
  --muted: #a4acb9;
  --line: #3a3d45;
  --line-soft: #2e3138;
  --accent: #5ea1ff;
  --accent-hover: #8bbcff;
  --accent-ring: rgba(94, 161, 255, 0.22);
  --danger: #ffb4ab;
  --danger-bg: #321b1a;
  --danger-line: rgba(255, 180, 171, 0.24);
  --warning: #ffd58a;
  --warning-bg: #2d2413;
  --warning-line: rgba(255, 213, 138, 0.24);
  --success: #86efac;
  --success-bg: #14301f;
  --success-line: rgba(134, 239, 172, 0.26);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  touch-action: manipulation;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
label,
summary,
.password-item,
.password-value,
.history-item {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

.page {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.header-copy {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-icon {
  display: inline-flex;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  outline: none;
}

.brand-icon:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.brand-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(460px, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.main-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.settings,
.results,
.history,
.side {
  padding: 16px;
}

.side-section + .side-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.side h2,
.side h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.25;
}

.side h3 {
  font-size: 14px;
}

.side p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.side-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.side-list li {
  position: relative;
  padding-left: 14px;
}

.side-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 180px;
  margin-top: 10px;
  color: var(--muted);
  background: var(--subtle-bg);
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
  text-align: center;
}

.section-title {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
}

.field {
  margin-bottom: 14px;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

select,
.text-input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

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

.text-input {
  font-family: var(--mono);
  font-size: 16px;
}

.symbol-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.symbol-input-row .button-secondary {
  min-height: 38px;
  white-space: nowrap;
}

.checkbox-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  line-height: 1.35;
}

.checkbox-row:last-child {
  border-bottom: 0;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.checkbox-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.details {
  margin: 0 0 14px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.details summary {
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.details-content {
  padding-bottom: 12px;
}

.notice {
  display: none;
  margin: 0 0 12px;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.notice.is-visible {
  display: block;
}

.notice.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
}

.notice.warning {
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning-line);
}

.actions,
.results-actions {
  display: grid;
  gap: 8px;
  align-items: center;
}

.actions {
  grid-template-columns: minmax(0, 1fr) auto;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
}

.button-primary,
.button-secondary,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--text);
}

.button-primary {
  min-height: 42px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.button-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button-secondary {
  min-height: 42px;
  padding: 0 12px;
}

.icon-button.theme-toggle {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  width: 44px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.theme-icon {
  display: block;
}

.button-secondary:hover,
.icon-button:hover {
  background: var(--control-hover);
  border-color: var(--line);
}

.button-secondary:disabled {
  opacity: 0.5;
  cursor: default;
}

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

.results-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.history[hidden] {
  display: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.history-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.history-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.history-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 36px;
  gap: 6px;
  align-items: center;
  min-height: 52px;
  padding: 6px 4px 6px 10px;
  background: var(--control);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.history-meta {
  min-width: 0;
}

.history-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.history-empty {
  min-height: 120px;
}

.password-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.password-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 36px;
  gap: 6px;
  align-items: center;
  min-height: 42px;
  padding: 4px 4px 4px 10px;
  background: var(--control);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.password-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--muted);
}

.copy-state {
  color: var(--success);
  border-color: var(--success-line);
  background: var(--success-bg);
}

.empty[hidden] {
  display: none;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
}

.empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.seo-content {
  margin-top: 16px;
  padding: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.seo-content h2,
.seo-content h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.seo-content h3 {
  margin-top: 16px;
  font-size: 15px;
}

.seo-content p {
  margin: 0;
  max-width: 860px;
}

.faq-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.faq-list details {
  padding: 12px;
  background: var(--control);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.faq-list summary {
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.faq-list p {
  margin-top: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1060px) {
  .layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .side {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .side-section + .side-section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .actions {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 5;
    grid-template-columns: minmax(92px, 0.45fr) minmax(0, 1fr);
    margin-top: 8px;
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
  }

  .actions .button-secondary {
    order: 1;
  }

  .actions .button-primary {
    order: 2;
  }

  .actions .button-primary,
  .actions .button-secondary {
    min-height: 48px;
  }

  .side {
    display: block;
  }

  .side-section + .side-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
  }
}

@media (max-width: 520px) {
  .page {
    width: min(100% - 16px, 960px);
    margin-left: auto;
    margin-right: auto;
    padding-top: 16px;
  }

  .header h1 {
    font-size: 24px;
  }

  .header {
    gap: 12px;
  }

  .header-copy {
    gap: 10px;
  }

  .brand-icon {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }

  .settings,
  .results,
  .history,
  .side,
  .seo-content {
    padding: 12px;
  }

  .results-header,
  .history-header {
    align-items: stretch;
    flex-direction: column;
  }

  .results-actions .button-secondary {
    flex: 1;
  }

  .password-item {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    min-height: 56px;
    gap: 8px;
    padding: 6px;
  }

  .history-item {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    min-height: 60px;
    gap: 8px;
    padding: 6px;
  }

  .password-item .icon-button,
  .history-item .icon-button {
    width: 44px;
    min-height: 44px;
  }

  select,
  .text-input,
  button {
    font-size: 16px;
  }

  .symbol-input-row {
    grid-template-columns: 1fr;
  }
}
