:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-soft: #edf4f9;
  --text: #142232;
  --muted: #4f657a;
  --line: #d2dfea;
  --brand: #0b816d;
  --brand-strong: #0d6887;
  --accent: #eea43a;
  --danger: #b63b35;
  --warning: #a86700;
  --success: #0a7f45;
  --radius-lg: 20px;
  --radius-md: 12px;
  --shadow: 0 22px 50px -28px rgba(13, 36, 58, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans JP", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 13% 8%, #d7f4ec 0%, transparent 35%),
    radial-gradient(circle at 86% 87%, #ffe8be 0%, transparent 34%),
    linear-gradient(130deg, #f2f7fb 0%, #f4f8fb 44%, #fff8ea 100%);
  line-height: 1.5;
  padding: 24px 16px 40px;
}

.background-orb {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(28px);
  z-index: 0;
}

.orb-a {
  width: 210px;
  height: 210px;
  top: 20px;
  right: 6%;
  background: rgba(11, 129, 109, 0.15);
}

.orb-b {
  width: 240px;
  height: 240px;
  bottom: 18px;
  left: 4%;
  background: rgba(238, 164, 58, 0.16);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.hero {
  background: linear-gradient(120deg, #0c7f69 0%, #0d6887 56%, #2f586e 100%);
  color: #f4fcff;
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.lang-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 240, 235, 0.6);
  color: rgba(244, 255, 252, 0.92);
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  background: rgba(14, 78, 93, 0.3);
}

.lang-link:hover {
  background: rgba(17, 109, 130, 0.45);
  color: #ffffff;
}

.lang-link.is-active {
  border-color: rgba(255, 255, 255, 0.83);
  background: rgba(251, 255, 255, 0.94);
  color: #145471;
}

.hero-kicker {
  margin: 0 0 8px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.84;
}

.hero h1 {
  margin: 0 0 8px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: clamp(1.45rem, 2.7vw, 2rem);
  line-height: 1.2;
}

.hero-text {
  margin: 0;
  color: rgba(246, 255, 254, 0.92);
  max-width: 66ch;
}

.hero-quick-links {
  margin: 0 0 10px;
}

.hero-quick-links a {
  color: rgba(246, 255, 254, 0.96);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 0.92rem;
  font-weight: 600;
}

.hero-quick-links a:hover {
  color: #ffffff;
}

.workspace-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  grid-template-areas:
    "controls"
    "output";
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 14px 35px -28px rgba(12, 30, 48, 0.6);
}

.controls-panel {
  grid-area: controls;
  padding: 14px 14px 12px;
}

.output-panel {
  grid-area: output;
  display: flex;
  flex-direction: column;
}

.action-row {
  margin-top: 6px;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(106deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #f5fdff;
}

.btn-primary:hover:not([disabled]) {
  filter: brightness(1.05);
}

.btn-secondary {
  background: #edf4f8;
  color: #16445b;
  border: 1px solid #cedde6;
}

.btn-secondary:hover:not([disabled]) {
  background: #e5edf3;
}

.shortcut-panel {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #d7e2eb;
  border-radius: 10px;
  background: #f7fbfe;
}

.shortcut-title {
  margin: 0 0 6px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #3e6076;
}

.shortcut-chips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.shortcut-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  font-size: 0.9rem;
  color: #345469;
}

kbd {
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 6px;
  border: 1px solid #b8c8d4;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #ffffff;
  color: #1c3f54;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.setting-group {
  margin: 0;
  display: grid;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f7fbfe;
}

.setting-group legend {
  padding: 0 6px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  color: #1f4e67;
}

.resolution-group {
  padding-top: 6px;
}

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

.resolution-separator {
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-weight: 700;
  color: #3d6177;
}

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

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #2f546c;
}

.toggle-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.picker-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #2f546c;
  font-size: 0.86rem;
}

input[type="color"] {
  width: 54px;
  height: 36px;
  border: 1px solid #b9cbda;
  border-radius: 8px;
  padding: 0;
  background: #ffffff;
  cursor: pointer;
}

input[type="color"][disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.size-inputs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-soft);
}

input[type="number"] {
  font-weight: 600;
  color: #1b3f54;
}

input[type="text"]::placeholder {
  color: #7b90a5;
}

#targetSizeValue {
  width: 120px;
}

#targetSizeUnit {
  width: 84px;
}

input[type="number"][disabled],
select[disabled] {
  cursor: not-allowed;
  opacity: 0.65;
}

.format-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 2px;
}

.format-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cfe0ed;
  background: #f5f9fd;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.86rem;
  color: #1d435c;
}

.format-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.format-option.is-disabled {
  opacity: 0.55;
}

.helper-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.row-hint {
  grid-column: 1 / -1;
  margin-top: -2px;
}

.output-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.output-panel label {
  display: block;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-weight: 600;
}

.output-summary {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #155071;
  background: #e9f4fb;
  border: 1px solid #c4dceb;
}

.output-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.output-item {
  border: 1px solid #d4e0ea;
  border-radius: var(--radius-md);
  background: #fbfdff;
  padding: 10px 12px;
}

.output-item.is-clickable {
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.output-item.is-clickable:hover {
  border-color: #95bdd7;
  box-shadow: 0 9px 18px -16px rgba(10, 40, 62, 0.85);
}

.output-item.is-clickable:active {
  transform: translateY(1px);
}

.output-item.is-clickable:focus-visible {
  outline: 3px solid rgba(11, 129, 109, 0.28);
  outline-offset: 1px;
}

.output-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.output-file {
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: #13364d;
  word-break: break-all;
}

.output-size {
  font-weight: 600;
  color: #174b66;
}

.output-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.85rem;
  color: #516980;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge.exact {
  color: #0f6940;
  background: #e7f6ee;
  border-color: #bce2cd;
}

.badge.closest {
  color: #0f5671;
  background: #e8f3fb;
  border-color: #bfd9ec;
}

.badge.adjusted {
  color: #8b5600;
  background: #fff5e2;
  border-color: #f1d3a2;
}

.output-note {
  margin: 6px 0 0;
  color: var(--warning);
  font-size: 0.8rem;
}

.output-help {
  margin: 6px 0 0;
  color: #3e6279;
  font-size: 0.8rem;
}

.status {
  margin: 10px 0 0;
  min-height: 1.5em;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.warning {
  color: var(--warning);
}

.status.success {
  color: var(--success);
}

.seo-panel h2 {
  margin: 0 0 10px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 1.05rem;
  color: #143f55;
}

.seo-panel h2:not(:first-child) {
  margin-top: 16px;
}

.seo-panel p {
  margin: 0;
  color: var(--text);
}

.seo-panel ul,
.seo-panel ol {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
}

.seo-panel li {
  margin: 0 0 6px;
}

.ad-panel {
  padding: 12px 16px;
}

.ad-label {
  margin: 0 0 10px;
  font-family: "Sora", "Noto Sans JP", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4f6678;
}

.ad-slot {
  min-height: 120px;
  border: 1px dashed #bfd3e0;
  border-radius: var(--radius-md);
  padding: 10px;
  background: #f8fbfe;
}

.ad-slot[hidden] {
  display: none;
}

.ad-panel[data-ad-state="disabled"],
.ad-panel[data-ad-state="error"] {
  display: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  font-size: 0.9rem;
  color: #38566a;
  padding: 2px 4px 10px;
}

.site-footer a {
  color: #1d5f7d;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a[aria-current="page"] {
  text-decoration: none;
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(88vw, 380px);
  background: #143b53;
  color: #f2f9ff;
  border: 1px solid rgba(203, 231, 250, 0.3);
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 16px 35px -18px rgba(10, 29, 44, 0.65);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
  font-size: 0.92rem;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

a:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="color"]:focus,
select:focus,
button:focus,
input[type="checkbox"]:focus {
  outline: 3px solid rgba(11, 129, 109, 0.28);
  outline-offset: 1px;
}

@media (max-width: 620px) {
  .panel {
    padding: 16px;
  }

  .hero {
    padding: 20px;
  }

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

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 860px) {
  .color-row,
  .size-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .action-row {
    flex-wrap: wrap;
  }

  .size-inputs {
    width: 100%;
  }

  #targetSizeValue {
    width: 100%;
  }
}

@media (min-width: 1040px) {
  .workspace-grid {
    grid-template-columns: minmax(360px, 1fr) minmax(440px, 1.25fr);
    grid-template-areas: "controls output";
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .panel {
    animation: panel-fade 320ms ease-out both;
  }

  .output-item.is-clickable:hover {
    transform: translateY(-1px);
  }
}

@keyframes panel-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
