:root {
  color-scheme: light;
  --blue: #1558d6;
  --blue-dark: #0b3f9f;
  --ink: #172235;
  --muted: #68778b;
  --line: #dce5ee;
  --surface: #ffffff;
  --surface-soft: #f4f7fb;
  --success: #0c8b58;
  --danger: #cc3440;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 720px;
  min-height: 100vh;
  margin: 0;
  background: #f2f5f9;
  color: var(--ink);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

.page-header {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 68px;
  border-bottom: 1px solid #d8e2ed;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 14px rgba(24, 44, 72, 0.06);
  backdrop-filter: blur(12px);
}

.page-header__inner {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  align-items: center;
  width: min(1120px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  color: #52647b;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover {
  color: var(--blue);
}

.back-link span {
  font-size: 1rem;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #eaf2ff;
  color: var(--blue);
  font-size: 1rem;
}

.page-title h1 {
  margin: 0 0 1px;
  font-size: 1.08rem;
  font-weight: 950;
  letter-spacing: -0.025em;
}

.page-title p {
  margin: 0;
  color: #7a899c;
  font-size: 0.66rem;
  font-weight: 700;
}

.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #718197;
  font-size: 0.68rem;
  font-weight: 750;
}

.save-indicator::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #20aa70;
  content: "";
}

.settings-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 760px);
  gap: 34px;
  width: min(1000px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 72px;
}

.settings-nav {
  position: sticky;
  top: 102px;
  display: flex;
  align-self: start;
  flex-direction: column;
  gap: 4px;
}

.settings-nav strong {
  margin: 0 10px 8px;
  color: #8896a8;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-nav a {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: #5c6c81;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
}

.settings-nav a:hover,
.settings-nav a.is-active {
  background: #e8f1ff;
  color: var(--blue);
}

.settings-content {
  min-width: 0;
}

.settings-intro {
  margin: 3px 2px 24px;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0.03em;
}

.settings-intro h2 {
  margin: 0 0 7px;
  color: #142033;
  font-size: 1.42rem;
  font-weight: 950;
  letter-spacing: -0.035em;
}

.settings-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 650;
}

.status {
  position: fixed;
  z-index: 50;
  top: 80px;
  left: 50%;
  min-width: 260px;
  max-width: min(520px, calc(100% - 40px));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #d4e0ec;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(28, 51, 82, 0.17);
  color: #53647a;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.status:not(:empty) {
  transform: translate(-50%, 0);
  opacity: 1;
}

.status--ok {
  border-color: #bfe5d4;
  background: #effaf5;
  color: var(--success);
}

.status--error {
  border-color: #f0c8cd;
  background: #fff3f4;
  color: var(--danger);
}

.settings-card {
  scroll-margin-top: 88px;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid #d9e3ed;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(30, 51, 78, 0.055);
}

.settings-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.settings-card__head h2 {
  margin: 0 0 3px;
  color: #1d2c42;
  font-size: 0.98rem;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.settings-card__head p {
  margin: 0;
  color: #748398;
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.45;
}

.settings-card__icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eef2f7;
  color: #607086;
  font-size: 0.92rem;
  font-weight: 950;
}

.settings-card__icon--blue { background: #e9f2ff; color: #1763db; }
.settings-card__icon--green { background: #e8f8f1; color: #07885a; }
.settings-card__icon--amber { background: #fff5dd; color: #c27600; }
.settings-card__icon--violet { background: #f1edff; color: #6848d8; }

.setting-list {
  border-top: 1px solid #e5ebf1;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  border-bottom: 1px solid #e5ebf1;
  cursor: pointer;
}

.setting-row--standalone {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #dfe7ef;
  border-radius: 9px;
  background: #f8fafc;
}

.setting-row > span:first-child {
  display: grid;
  gap: 4px;
}

.setting-row strong {
  color: #2b3b51;
  font-size: 0.77rem;
  font-weight: 900;
}

.setting-row small {
  color: #7b899b;
  font-size: 0.67rem;
  font-weight: 650;
  line-height: 1.4;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c8d2dd;
  transition: background 0.16s ease;
}

.switch i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(29, 45, 65, 0.25);
  content: "";
  transition: transform 0.16s ease;
}

.switch input:checked + i {
  background: var(--blue);
}

.switch input:checked + i::after {
  transform: translateX(16px);
}

.switch input:focus-visible + i {
  outline: 3px solid rgba(21, 88, 214, 0.18);
  outline-offset: 2px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field:first-child {
  margin-top: 0;
}

.field > span:first-child {
  color: #4b5b70;
  font-size: 0.7rem;
  font-weight: 850;
}

input[type="password"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  outline: 0;
  background: #fff;
  color: #25354b;
  font-size: 0.76rem;
  font-weight: 700;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: #6fa2e6;
  box-shadow: 0 0 0 3px rgba(21, 88, 214, 0.1);
}

input::placeholder {
  color: #a0acba;
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 38px;
}

.input-with-unit i {
  position: absolute;
  top: 50%;
  right: 12px;
  color: #7a899b;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 800;
  transform: translateY(-50%);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin-top: 9px;
  color: #6e7d91;
  font-size: 0.68rem;
  font-weight: 750;
  cursor: pointer;
}

.checkbox input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--blue);
}

.helper-text {
  margin: 10px 0 0;
  color: #77869a;
  font-size: 0.67rem;
  font-weight: 650;
  line-height: 1.5;
}

.helper-text a,
.api-block__title a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.helper-text a:hover,
.api-block__title a:hover {
  text-decoration: underline;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.card-actions--split {
  justify-content: space-between;
}

.card-actions--compact {
  margin-top: 13px;
}

.button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 0.71rem;
  font-weight: 900;
  cursor: pointer;
}

.button:hover {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.button--ghost {
  border-color: #cbd7e3;
  background: #fff;
  color: #53647a;
}

.button--ghost:hover {
  border-color: #9eb5ce;
  background: #f3f7fb;
  color: #2e4664;
}

.api-block {
  padding: 16px;
  border: 1px solid #e0e7ef;
  border-radius: 10px;
  background: #f9fbfd;
}

.api-block + .api-block {
  margin-top: 12px;
}

.api-block__title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.api-block__title > div {
  display: grid;
  gap: 3px;
}

.api-block__title strong {
  color: #2b3b51;
  font-size: 0.78rem;
  font-weight: 900;
}

.api-block__title small {
  color: #7c8a9c;
  font-size: 0.65rem;
  font-weight: 650;
}

.api-block__title a {
  flex: 0 0 auto;
  font-size: 0.66rem;
}

.help ol {
  margin: 0;
  padding-left: 19px;
  color: #66768b;
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.75;
}

@media (max-width: 860px) {
  .page-header__inner,
  .settings-layout {
    width: calc(100% - 36px);
  }

  .settings-layout {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 22px;
  }

  .page-header__inner {
    grid-template-columns: 84px 1fr auto;
  }

  .save-indicator {
    font-size: 0;
  }
}

@media (max-width: 720px) {
  body {
    min-width: 0;
  }

  .page-header {
    height: 62px;
  }

  .page-header__inner {
    grid-template-columns: auto minmax(0, 1fr);
    width: calc(100% - 24px);
    gap: 12px;
  }

  .page-title__icon,
  .page-title p,
  .save-indicator {
    display: none;
  }

  .settings-layout {
    display: block;
    width: calc(100% - 20px);
    padding: 16px 0 calc(40px + env(safe-area-inset-bottom));
  }

  .settings-nav {
    position: sticky;
    z-index: 15;
    top: 62px;
    flex-direction: row;
    gap: 4px;
    margin: 0 -2px 16px;
    padding: 7px 2px;
    overflow-x: auto;
    background: rgba(242, 245, 249, 0.96);
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar,
  .settings-nav strong {
    display: none;
  }

  .settings-nav a {
    flex: 0 0 auto;
    min-height: 42px;
    padding-inline: 11px;
  }

  .settings-intro {
    margin-bottom: 16px;
  }

  .settings-intro h2 {
    font-size: 1.18rem;
  }

  .settings-card {
    padding-inline: 14px;
  }

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

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