

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

:root {
  --c1: #E91E63; /* Vibrant Pink */
  --r1: #FF9800; /* Bright Orange */
  --a: #FFC107; /* Amber Yellow */
  --f: #8BC34A; /* Light Green */
  --c2: #03A9F4; /* Light Blue */
  --o1: #673AB7; /* Deep Purple */
  --l: #00ACC1; /* Cyan/Teal */
  --o2: #F06292; /* Lighter Pink/Rose */
  --r2: #4DB6AC; /* Tealish Green */
}

/* Base and Global Styles */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Sans", "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", "メイリオ", Meiryo, "MS PGothic", "ＭＳ Ｐゴシック", sans-serif;
  overscroll-behavior-y: none;
  min-height: 100vh;
  background-color: #e2e8f0; /* bg-slate-200 */
  color: #1e293b; /* text-slate-800 */
  padding: clamp(1rem,4vh,2rem) clamp(0.5rem,2vw,1rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 300ms ease-in-out;
}

::selection {
  background-color: #bae6fd; /* selection:bg-sky-200 */
  color: #0c4a6e; /* selection:text-sky-900 */
}

.hidden {
  display: none !important;
}

/* App Layout */
.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.app-header {
  margin-bottom: clamp(1.5rem,5vh,3rem);
  width: 100%;
  max-width: 64rem; /* max-w-4xl */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header-content {
  text-align: center;
  width: 100%;
}

.title {
  font-weight: 900;
  margin-top: clamp(0.75rem,3vw,1.5rem);
  margin-bottom: clamp(0.5rem,2vw,1rem);
  font-size: clamp(1.6rem, 8vw, 3rem);
}

.tracking-wide {
  letter-spacing: 0.1em;
}

.font-crafcolor-c1 { color: var(--c1); }
.font-crafcolor-r1 { color: var(--r1); }
.font-crafcolor-a { color: var(--a); }
.font-crafcolor-f { color: var(--f); }
.font-crafcolor-c2 { color: var(--c2); }
.font-crafcolor-o1 { color: var(--o1); }
.font-crafcolor-l { color: var(--l); }
.font-crafcolor-o2 { color: var(--o2); }
.font-crafcolor-r2 { color: var(--r2); }

.subtitle {
  color: #ffffff; /* text-white */
  letter-spacing: 0.05em;
  font-size: clamp(0.75rem,2.3vw,1.1rem);
  white-space: pre-line;
}

/* Main Content Area */
.main-content-wrapper {
  width: 100%;
  max-width: 42rem; /* max-w-2xl */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.decorative-bar {
  background-color: black;
  border-top-left-radius: clamp(1rem,3vw,1.8rem);
  border-top-right-radius: clamp(1rem,3vw,1.8rem);
  height: clamp(3rem, 15vw, 9rem);
  width: 100%;
  position: relative;
  overflow: hidden;
  z-index: 10;
}

.decorative-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.1) 8px,
    transparent 8px,
    transparent 40px
  );
}

.white-divider {
  background-color: white;
  width: 85%;
  height: clamp(0.8rem,1.5vw,1.2rem);
}

.main-card {
  background-color: white;
  padding: clamp(1rem,5vw,2.5rem);
  border-radius: clamp(1rem,3vw,1.8rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Image Uploader */
.image-uploader-container {
  margin: clamp(0.75rem,3vw,1rem) 0;
}

#upload-button {
  padding: clamp(0.6rem, 2.5vw, 0.875rem) clamp(1.5rem, 5vw, 2.5rem);
  background-color: #2563eb;
  color: white;
  font-weight: 700;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  transition: all 150ms ease-in-out;
  font-size: clamp(0.875rem,2.5vw,1.125rem);
  border: none;
  cursor: pointer;
}
#upload-button:hover {
  background-color: #1d4ed8;
}
#upload-button:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4);
}

/* Canvas / Drop Zone */
.canvas-wrapper {
  width: 100%;
  margin-top: clamp(1rem,4vw,1.5rem);
  margin-bottom: clamp(1rem,4vw,1.5rem);
}
#drop-zone {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  transition: all 150ms ease-in-out;
  border-radius: 0.5rem;
  border: 2px dashed #94a3b8; /* border-slate-400 */
  padding: clamp(0.75rem,3vw,1rem);
  min-height: clamp(150px,30vh,250px);
}
#drop-zone.dragging-over {
  border-color: #0ea5e9; /* border-sky-500 */
  background-color: #f0f9ff; /* bg-sky-50 */
}
#drop-zone.has-image {
  border: none;
  padding: 0;
  min-height: auto;
}

.placeholder-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b; /* text-slate-500 */
  pointer-events: none;
  padding: 1rem;
  text-align: center;
}
.placeholder-icon {
  color: #94a3b8; /* text-slate-400 */
  margin-bottom: clamp(0.5rem,2vw,0.75rem);
  height: clamp(2rem,5vw,3rem);
  width: clamp(2rem,5vw,3rem);
}
.placeholder-text {
  font-size: clamp(0.75rem,2.5vw,1rem);
  white-space: pre-line;
}
#color-picker-canvas {
  display: block;
  border-radius: 0.5rem;
  width: 100%;
  height: auto;
  cursor: crosshair;
  border: 1px solid #cbd5e1; /* border-slate-300 */
  background-color: transparent;
  touch-action: none;
}

/* Loupe */
#loupe-container {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  border: 2px solid white;
  background-color: white;
  width: 124px;
  height: 124px;
  transform: translate(-50%, -50%);
}
#loupe-canvas {
  border: 1px solid #9ca3af; /* border-gray-400 */
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  border-radius: 50%;
}

/* History & PDF */
#history-pdf-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: clamp(0.75rem,3vw,1rem);
}
#saved-colors-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.saved-color-swatch {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    border: 2px solid #94a3b8; /* border-slate-400 */
    transition: all 150ms ease-in-out;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    cursor: pointer;
}
.saved-color-swatch:hover {
    border-color: #475569; /* hover:border-slate-600 */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.saved-color-swatch.active {
    border-color: #0ea5e9; /* border-sky-500 */
    box-shadow: 0 0 0 2px white, 0 0 0 4px #0ea5e9; /* ring-2 ring-sky-500 ring-offset-2 ring-offset-white */
}
.saved-color-swatch:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #0ea5e9;
}
#pdf-download-button {
  margin-top: clamp(1rem,3vw,1.5rem);
  padding: clamp(0.6rem, 2.5vw, 0.875rem) clamp(1.5rem, 5vw, 2.5rem);
  background-color: #2563eb;
  color: white;
  font-weight: 700;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  transition: all 150ms ease-in-out;
  font-size: clamp(0.875rem,2.5vw,1.125rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}
#pdf-download-button:hover {
  background-color: #1d4ed8;
}
#pdf-download-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#pdf-download-button .pdf-button-icon {
  height: 1.25rem;
  width: 1.25rem;
  margin-right: 0.375rem;
  display: inline-block;
  vertical-align: text-bottom;
}


/* Color Display */
#color-display-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: clamp(1rem,4vw,1.5rem);
}
.color-display {
  margin-top: clamp(0.75rem,3vw,1rem);
  padding: clamp(1rem,4vw,1.5rem);
  background-color: #f8fafc; /* bg-slate-50 */
  border-radius: 0.75rem; /* rounded-xl */
  width: 100%;
}
.color-display.placeholder {
  padding: clamp(1rem,4vw,1.5rem) 0;
  text-align: center;
  color: #64748b; /* text-slate-500 */
  width: 100%;
  max-width: 20rem; /* max-w-xs */
}
.color-display-title {
  font-weight: 600;
  color: #1e293b; /* text-slate-800 */
  margin-bottom: clamp(1rem,3vw,1.5rem);
  text-align: center;
  font-size: clamp(1.125rem,3.5vw,1.5rem);
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.5rem,1.5vw,0.75rem);
  margin-bottom: clamp(1.5rem,4vw,2rem);
}
.color-grid-item {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(0.25rem,1vw,0.5rem);
  border-radius: 0.5rem;
  text-align: center;
}
.color-grid-item .label {
  display: block;
  font-size: clamp(0.75rem,2vw,0.875rem);
  font-weight: 500;
}
.color-grid-item .value-container {
  display: flex;
  align-items: baseline;
  margin-top: 0.125rem;
}
.color-grid-item .value {
  display: block;
  font-weight: 700;
  font-size: clamp(1.4rem,4.2vw,1.75rem);
}
.color-grid-item .percent {
  display: block;
  font-size: clamp(0.75rem,2vw,0.875rem);
  font-weight: 400;
  margin-left: 0.125rem;
}
.color-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.color-preview-label {
  font-weight: 500;
  color: #475569; /* text-slate-600 */
  margin-bottom: 0.5rem;
  text-align: center;
  font-size: clamp(0.75rem,2.2vw,1rem);
}
.color-preview-swatch {
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1; /* border-slate-300 */
  width: 100%;
  height: clamp(2.5rem,10vw,3.75rem);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Notes */
#notes-container {
  color: #64748b; /* text-slate-500 */
  margin-top: clamp(0.75rem,3vw,1rem);
  font-size: clamp(0.6rem,1.8vw,0.875rem);
  width: 100%;
  max-width: 24rem; /* max-w-sm */
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
#notes-container p {
  line-height: 1.625;
  margin-bottom: 0.25rem;
  padding-left: 1em;
  text-indent: -1em;
}
#notes-container p:last-child {
  margin-bottom: 0;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding-top: clamp(0.5rem,2vh,1rem);
  text-align: center;
  font-size: clamp(0.75rem,2vw,0.875rem);
  width: 100%;
  max-width: 42rem; /* max-w-2xl */
}
.footer-links {
  margin-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 0.5rem;
  color: #ffffff; /* text-white */
}
.footer-links a {
  color: #ffffff; /* text-white */
  transition: color 150ms ease-in-out;
}
.footer-links a:hover {
  text-decoration: underline;
  color: #d1d5db; /* gray-300 */
}
.footer-links a:focus {
  outline: none;
  text-decoration: underline;
}
.creater-info {
  /* white-space: nowrap; was causing overflow */
}
.copyright {
  color: #ffffff; /* text-white */
}

/* Responsive Styles */
@media (min-width: 640px) { /* sm: */
  .color-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  #notes-container {
    max-width: 28rem; /* sm:max-w-md */
  }
}
@media (min-width: 768px) { /* md: */
  #notes-container {
    max-width: 32rem; /* md:max-w-lg */
  }
}