/* Color picker styles */
:root {
  --bg: #f3f4f6;
  --panel-bg: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --accent: #3b82f6;
  --accent-soft: #dbeafe;
  --danger: #ef4444;
  --radius: 12px;
  --shadow-soft: 0 4px 12px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.app {
  max-width: 1100px;
  margin: 8px auto;
  padding: 8px;
}

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

.title-block h1 {
  margin: 0;
  font-size: 1.2rem;
}

.title-block p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.badge {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--muted);
}

/* Layout */

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 8px;
}

@media (max-width: 800px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 10px;
  min-height: 0;
}

/* Tabs */

.tabs {
  display: flex;
  border-radius: 999px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}

.tab-button {
  flex: 1;
  border: none;
  background: #f9fafb;
  padding: 6px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.tab-button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Layout helpers */

.row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.row.between {
  justify-content: space-between;
  align-items: center;
}

.row.align-center {
  align-items: center;
}

.row.right {
  justify-content: flex-end;
}

.help-text {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Buttons */

.btn-primary,
.btn-secondary {
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 0.8rem;
  padding: 5px 10px;
  cursor: pointer;
  background: #fff;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary:hover {
  background: #f3f4f6;
}

/* Palettes */

.preset-palettes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.palette-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
}

.palette-gradient {
  width: 100%;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}

.palette-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.palette-swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.palette-swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
}

.custom-picker {
  margin-top: 8px;
}

.palette-text {
  width: 110px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.palette-select-row {
  margin-bottom: 4px;
}

.palette-select {
  min-width: 200px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font-size: 0.9rem;
}

/* File input */

.file-input {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  padding: 5px 10px;
  font-size: 0.8rem;
  background: #fff;
  cursor: pointer;
}

.file-input input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Canvas */

.canvas-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #f9fafb;
  padding: 6px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#imageCanvas {
  max-width: 100%;
  height: auto;
  display: none;
}

.canvas-empty {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* Current color */

.current-color {
  margin-top: 8px;
}

.current-color h2 {
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.current-color-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

@media (max-width: 480px) {
  .current-color-row {
    grid-template-columns: 1fr;
  }
}

.swatch {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #f97316;
}

.color-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.color-label {
  color: var(--muted);
}

.color-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.btn-copy {
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  cursor: pointer;
}

.btn-copy:hover {
  background: #f3f4f6;
}

/* History */

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.9rem;
}

.history-list {
  margin-top: 6px;
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-empty {
  font-size: 0.8rem;
  color: var(--muted);
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f9fafb;
}

.history-swatch {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}

.history-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
}

.history-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.chip {
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.72rem;
}

.chip-label {
  color: var(--muted);
  margin-right: 4px;
}

.history-memo {
  width: 100%;
  min-height: 36px;
  resize: vertical;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.76rem;
  padding: 4px 6px;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.7rem;
}

/* Scrollbar */
.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-track {
  background: #e5e7eb;
}
.history-list::-webkit-scrollbar-thumb {
  background: #cbd5f5;
}

/* Ads */
.ad-panel {
  margin-top: 10px;
  text-align: center;
}

.ad-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.ad-slot {
  display: flex;
  justify-content: center;
  width: 100%;
}

.adsbygoogle {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
  margin: 0 auto;
}
