:root{
  --bg: #f5f5f7;
  --card: rgba(255,255,255,0.7);
  --cardBorder: rgba(0,0,0,0.08);
  --text: #1d1d1f;
  --muted: rgba(29,29,31,0.68);
  --shadow: 0 20px 40px rgba(0,0,0,0.08);
  --radius: 18px;
  --focus: rgba(10,132,255,0.28);
}

*{ box-sizing: border-box; }

html{
  min-height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 20% 0%, rgba(10,132,255,0.18), transparent 65%),
    radial-gradient(900px 500px at 80% 0%, rgba(175,82,222,0.16), transparent 65%),
    radial-gradient(900px 600px at 50% 100%, rgba(52,199,89,0.10), transparent 65%),
    linear-gradient(to bottom, rgba(10,132,255,0.05), var(--bg) 45%, var(--bg) 55%, rgba(52,199,89,0.05));
  background-repeat: no-repeat;
}

body{
  min-height: 100%;
  margin:0;
  background: transparent;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app{
  width: min(860px, calc(100% - 48px));
  margin: 48px auto 24px;
}

.header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1{
  margin: 0 0 8px 0;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.header p{
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.swatchWrap{
  flex: 0 0 auto;
  padding: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--cardBorder);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.swatch{
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

.card{
  position: relative;
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  min-width: 0;
}

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}
.rowTop{ margin-bottom: 14px; }

.label{
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

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

.picker{
  width: 54px;
  height: 32px;
  padding: 0 2px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 2px;
  background: rgba(255,255,255,0.8);
}
.picker:focus{ outline: none; box-shadow: 0 0 0 4px var(--focus); }

.button{
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.85);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.button:hover{ background: rgba(255,255,255,0.95); }
.button:active{ transform: translateY(0.5px); }
.button:focus{ outline: none; box-shadow: 0 0 0 4px var(--focus); }

.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}

.saveBar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  margin-top: 16px;
  margin-bottom: 12px;
}
.saveMeta{
  color: rgba(29,29,31,0.55);
  font-size: 12px;
}

.lowerGrid{
  display:flex;
  gap: 14px;
  align-items:stretch;
}

.panel{
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.65);
  padding: 14px;
  flex: 1 1 0;
}
.panelTitle{
  font-size: 13px;
  color: rgba(29,29,31,0.62);
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}
.tableWrap{
  overflow:auto;
  max-height: 240px;
}
.savedTable{
  width: 100%;
  border-collapse: collapse;
}
.savedTable th{
  text-align:left;
  font-size: 12px;
  color: rgba(29,29,31,0.52);
  padding: 0 8px 8px 8px;
  font-weight: 600;
}
.savedTable td{
  padding: 8px;
  font-size: 13px;
}
.savedTr{
  cursor: pointer;
  border-radius: 12px;
}
.savedTr:hover td{
  background: rgba(255,255,255,0.55);
}
.savedSwatch{
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}
.savedTr.selected td{
  background: rgba(10,132,255,0.10);
}

.compareRow{
  display:flex;
  gap: 12px;
  justify-content:space-between;
}
.compareItem{
  flex: 1 1 0;
  min-width: 0;
}
.compareLabel{
  font-size: 12px;
  color: rgba(29,29,31,0.55);
  margin-bottom: 8px;
}
.compareSwatch{
  width: 100%;
  height: 64px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}
.compareHex{
  margin-top: 8px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: rgba(29,29,31,0.70);
}
.compareDiff{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(0,0,0,0.15);
  color: rgba(29,29,31,0.60);
  font-size: 13px;
}

.compareActions{
  margin-top: 12px;
  display:flex;
  justify-content:flex-end;
}

.dangerButton{
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,59,48,0.40);
  background: rgba(255,255,255,0.75);
  color: rgba(255,59,48,0.92);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.dangerButton:hover{
  background: rgba(255,255,255,0.95);
}
.dangerButton:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(255,59,48,0.18);
}
@media (max-width: 720px){
  .header{ align-items:stretch; }
  .swatchWrap{ align-self:flex-start; }
  .grid{ grid-template-columns: 1fr; }
  .lowerGrid{ flex-direction: column; }
  h1{ font-size: 24px; }
  .header p{ font-size: 12px; }

  /* Triplet: two channels per row, third below */
  .triplet{
    flex-wrap: wrap;
    gap: 5px;
  }
  .tripletItem{
    flex: 1 1 calc(50% - 2.5px);
  }
  .channelLabel{
    font-size: 10px;
  }
  .numInput{
    height: 32px;
    font-size: 12px;
  }
  .stepBtn{
    height: 15px;
    width: 16px;
  }
  .inputRow{
    flex-wrap: nowrap;
  }
  .inputRow .iconButton{
    align-self: stretch;
  }
}

.field{
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.65);
  min-width: 0;
}

.inputRow{
  display:flex;
  gap: 10px;
  align-items:center;
  margin-top: 8px;
  min-width: 0;
}
.inputRow .triplet{
  flex: 1 1 auto;
  min-width: 0;
}
.inputRow .iconButton{
  flex: 0 0 auto;
}

.text{
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.9);
  font-size: 14px;
  color: var(--text);
}
.text:focus{
  outline: none;
  border-color: rgba(10,132,255,0.55);
  box-shadow: 0 0 0 3px var(--focus);
}
.text.invalid{
  border-color: rgba(255,59,48,0.65);
  box-shadow: 0 0 0 3px rgba(255,59,48,0.18);
}

.textWithPrefix{
  flex: 1 1 0;
  min-width: 0;
  display:flex;
  align-items:center;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.9);
  gap: 4px;
}
.textWithPrefix:focus-within{
  border-color: rgba(10,132,255,0.55);
  box-shadow: 0 0 0 3px var(--focus);
}
.textPrefix{
  flex: 0 0 auto;
  font-size: 14px;
  color: rgba(29,29,31,0.45);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 500;
  line-height: 1;
}
.hexInput{
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.hexInput:focus{
  outline: none;
  box-shadow: none;
  border-color: transparent;
}
.hexInput.invalid{
  border-color: transparent;
  box-shadow: none;
}
.textWithPrefix.invalid{
  border-color: rgba(255,59,48,0.65);
  box-shadow: 0 0 0 3px rgba(255,59,48,0.18);
}

.iconButton{
  flex: 0 0 auto;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.85);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.iconButton:hover{ background: rgba(255,255,255,0.95); }
.iconButton:focus{ outline: none; box-shadow: 0 0 0 4px var(--focus); }

.inputRow .triplet{
  flex: 1 1 auto;
  min-width: 0;
}
.inputRow .iconButton{
  flex: 0 0 auto;
}

.triplet{
  display:flex;
  gap: 5px;
  align-items:center;
}
.tripletItem{
  flex: 1 1 0;
  display:flex;
  align-items:center;
  gap: 3px;
  min-width: 0;
}
.channelLabel{
  flex: 0 0 auto;
  font-size: 10px;
  color: rgba(29,29,31,0.55);
  font-weight: 600;
  min-width: 10px;
  text-align: center;
}
.numInput{
  flex: 1 1 0;
  min-width: 0;
  width: 0;
  height: 32px;
  padding: 0 2px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.9);
  font-size: 12px;
  text-align: center;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.numInput:focus{
  outline: none;
  border-color: rgba(10,132,255,0.55);
  box-shadow: 0 0 0 3px var(--focus);
}
.numInput.invalid{
  border-color: rgba(255,59,48,0.65);
  box-shadow: 0 0 0 3px rgba(255,59,48,0.18);
}

.stepper{
  flex: 0 0 auto;
  display:flex;
  flex-direction:column;
  gap: 1px;
}
.stepBtn{
  height: 15px;
  width: 16px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.85);
  color: var(--text);
  font-size: 7px;
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height: 1;
}
.stepBtn:hover{ background: rgba(255,255,255,0.95); }
.stepBtn:focus{ outline: none; box-shadow: 0 0 0 3px var(--focus); }
.stepBtn:active{ transform: translateY(0.5px); }

.hint{
  margin-top: 8px;
  font-size: 12px;
  color: rgba(29,29,31,0.56);
}
.hint code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
}

.footer{
  margin-top: 14px;
  color: rgba(29,29,31,0.50);
  font-size: 12px;
  padding: 0 2px;
}

.toast{
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(28,28,30,0.90);
  color: rgba(255,255,255,0.92);
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 5;
}
.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* Tabs */
.tabs{
  display:flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--cardBorder);
}
.tab{
  flex: 1 1 0;
  height: 34px;
  border: none;
  background: transparent;
  color: rgba(29,29,31,0.62);
  font-size: 13px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.tab:hover{ color: var(--text); }
.tab.active{
  background: rgba(255,255,255,0.95);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}
.tab:focus{ outline: none; box-shadow: 0 0 0 3px var(--focus); }

.tabPanel{ display: none; }
.tabPanel.active{ display: block; }

/* Upload area */
.uploadArea{
  border: 2px dashed rgba(0,0,0,0.18);
  border-radius: 16px;
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(255,255,255,0.45);
  transition: background 140ms ease, border-color 140ms ease;
}
.uploadArea:hover,
.uploadArea.dragover{
  background: rgba(10,132,255,0.08);
  border-color: rgba(10,132,255,0.55);
}
.uploadArea:focus-within{
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
  border-color: rgba(10,132,255,0.55);
}
.uploadIcon{
  font-size: 28px;
  color: rgba(29,29,31,0.55);
  line-height: 1;
  margin-bottom: 8px;
}
.uploadTitle{
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}
.uploadHint{
  font-size: 12px;
  color: rgba(29,29,31,0.55);
}

.imagePreviewWrap{
  margin-top: 14px;
  display:flex;
  align-items:center;
  gap: 12px;
}
.imagePreview{
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--cardBorder);
  background: rgba(255,255,255,0.6);
  flex: 0 0 auto;
}

/* Gradient result */
.gradientResult{
  margin-top: 16px;
}
.gradientStrip{
  width: 100%;
  height: 84px;
  border-radius: 16px;
  border: 1px solid var(--cardBorder);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}
.colorChips{
  margin-top: 14px;
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.colorChip{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 6px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-align: center;
}
.colorChipSwatch{
  width: 100%;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--cardBorder);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
  transition: transform 120ms ease;
}
.colorChip:hover .colorChipSwatch{
  transform: translateY(-1px);
}
.colorChip:focus{ outline: none; }
.colorChip:focus .colorChipSwatch{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35), 0 0 0 3px var(--focus);
}
.colorChipHex{
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: rgba(29,29,31,0.75);
}

.gradientActions{
  margin-top: 16px;
  display:flex;
  gap: 8px;
  justify-content:flex-end;
}

@media (max-width: 720px){
  .colorChips{ grid-template-columns: repeat(3, 1fr); }
  .imagePreviewWrap{ flex-direction: column; align-items: stretch; }
  .imagePreview{ width: 100%; height: 160px; }
}
