/* ===================================================================
   Color Palette Studio — cream-world aesthetic, earth87human.com
   =================================================================== */

:root {
  --bg:          #faf6f1;
  --bg-2:        #f3eee5;
  --surface:     #ffffff;
  --surface-2:   #faf6ed;
  --surface-3:   #eee7d8;
  --border:      #e8dfcc;
  --border-soft: #f0e9da;
  --text:        #1f1a14;
  --text-2:      #5c5547;
  --text-3:      #6e6557;
  --text-faint:  #b5ac9b;

  --accent:      #e85f4d;
  --accent-2:    #d44a39;
  --accent-soft: rgba(232, 95, 77, 0.10);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

.page-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ============ Color input ============ */
.color-input-section {
  max-width: 480px;
  margin: 0 auto 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.color-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
}
.color-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
}
.color-picker {
  width: 44px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  padding: 2px;
  background: var(--surface);
}
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border-radius: 4px; border: none; }
.color-picker:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.hex-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.hex-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* ============ Harmony chips ============ */
.harmony-selector {
  text-align: center;
  margin-bottom: 24px;
}
.harmony-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 10px;
}
.harmony-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.harmony-chip {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.harmony-chip:hover { border-color: var(--accent); color: var(--accent); }
.harmony-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.harmony-active:hover { color: #fff; }

/* ============ Palette swatches ============ */
.palette-display {
  margin-bottom: 24px;
}
.swatches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.swatch {
  position: relative;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}
.swatch-color {
  width: 100%;
  height: 100px;
}
.swatch-info {
  padding: 10px 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.swatch-hex {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.03em;
}
.swatch-label {
  font-size: 11px;
  color: var(--text-3);
}
.swatch-copied {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}
.swatch-copied.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============ Image upload ============ */
.image-upload-section {
  max-width: 520px;
  margin: 0 auto 28px;
}
.image-upload-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
}
.image-upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 32px 20px;
  text-align: center;
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.image-upload-zone:hover,
.image-upload-zone.dragover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.image-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.image-upload-icon {
  color: var(--text-3);
  margin-bottom: 10px;
}
.image-upload-hint {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 12px;
}
.image-upload-btn {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--r-pill);
  transition: background var(--transition);
}
.image-upload-btn:hover { background: var(--accent-2); }
.image-canvas { display: none; }
.image-preview {
  margin-top: 12px;
  text-align: center;
}
.image-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

/* ============ CSS export ============ */
.css-export-section {
  max-width: 520px;
  margin: 0 auto 32px;
}
.css-export-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.css-export-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.css-export-copy {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color var(--transition), color var(--transition);
}
.css-export-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.css-code-block {
  background: #1a1714;
  border: 1px solid #2a2620;
  border-radius: var(--r-md);
  padding: 16px 18px;
  overflow-x: auto;
}
.css-code-block code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #e0d7c6;
  white-space: pre;
}

/* ============ Info ============ */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
}
.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 26px 0 10px;
  color: var(--text);
}
.info p {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 10px;
}
.info code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent-2);
}

/* ============ Footer ============ */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1714;
  color: #e0d7c6;
  padding: 10px 22px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 999;
}
.toast.show { opacity: 1; }

@media (max-width: 480px) {
  .swatches-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
  .swatch-color { height: 70px; }
  .color-input-group { flex-direction: column; align-items: stretch; }
  .color-picker { width: 100%; height: 44px; }
  .harmony-chip { padding: 7px 13px; font-size: 12px; }
  .image-upload-zone { padding: 24px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }
