:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1b1f;
  --muted: #6c666f;
  --line: #ded9d3;
  --accent: #d84c61;
  --accent-strong: #ba314c;
  --accent-soft: #fdecef;
  --ok: #1f7a4d;
  --error: #b42318;
  --shadow: 0 18px 50px rgba(35, 31, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(216, 76, 97, 0.08), transparent 280px),
    var(--bg);
  color: var(--text);
  font-family: Arial, "Malgun Gothic", sans-serif;
  letter-spacing: 0;
}

body.is-locked {
  overflow: hidden;
}

body.is-locked .app-shell,
body.is-locked .notice-bar {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.app-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.tool,
.status-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tool {
  padding: 28px;
}

.tool-header {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.title-block {
  min-width: 0;
}

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

.version-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.app-icon {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.tool-header p,
.status-top p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding-top: 24px;
}

.access-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.access-text.is-ok {
  color: var(--ok);
  font-weight: 700;
}

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

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.option-group legend {
  width: 100%;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.option-pill {
  position: relative;
  display: inline-flex;
}

.option-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.option-pill input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.option-pill input:disabled + span {
  cursor: not-allowed;
  opacity: 0.62;
}

.is-locked {
  opacity: 0.6;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 13px;
  outline: none;
}

input:disabled {
  cursor: not-allowed;
  background: #f1eeeb;
  color: #8d878f;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-button,
.secondary-button,
.download-link,
.icon-button {
  height: 46px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
}

.primary-button,
.download-link {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.primary-button:hover,
.download-link:hover {
  background: var(--accent-strong);
}

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

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  background: #b9b2b7;
  border-color: #b9b2b7;
  color: #fff;
}

.status-panel {
  padding: 24px;
  position: sticky;
  top: 24px;
  display: grid;
  gap: 24px;
}

.action-panel {
  display: grid;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.action-buttons {
  display: grid;
  gap: 10px;
}

.action-buttons .primary-button,
.action-buttons .secondary-button {
  width: 100%;
}

.status-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

#progressText {
  min-width: 56px;
  text-align: right;
  font-size: 24px;
}

.progress-track {
  height: 12px;
  background: #ebe7e2;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 18px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d84c61, #ef8b47);
  transition: width 180ms ease;
}

.summary-list {
  margin: 22px 0 0;
  display: grid;
  gap: 11px;
}

.summary-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.summary-row dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-row dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.download-link {
  width: 100%;
  margin-top: 20px;
}

.status-error #statusText {
  color: var(--error);
  font-weight: 700;
}

.status-done #statusText {
  color: var(--ok);
  font-weight: 700;
}

.modal {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(29, 27, 31, 0.35);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-list {
  margin: 18px 0 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.notice-bar {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto 28px;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  box-shadow: var(--shadow);
}

.notice-bar strong {
  color: var(--text);
}

.notice-bar ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.notice-bar li {
  padding-left: 2px;
}

.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(29, 27, 31, 0.45);
}

.lock-overlay.is-hidden {
  display: none;
}

.lock-panel {
  width: min(390px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.lock-icon {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: cover;
}

.lock-panel p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.lock-panel .primary-button {
  width: 100%;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 620px);
    grid-template-columns: 1fr;
    padding: 24px 0;
  }

  .status-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .tool,
  .status-panel {
    padding: 20px;
  }

  .tool-header {
    align-items: flex-start;
  }

  h1 {
    font-size: 23px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .summary-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .notice-bar {
    grid-template-columns: 1fr;
  }
}
