/* ========================================
   Color Palette Studio
   シンプルな SaaS ツール風スタイル
   ======================================== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --text-muted: #52606d;
  --border: #d9e2ec;
  --primary: #243b53;
  --primary-hover: #102a43;
  --danger: #9b1c1c;
  --danger-bg: #fce8e8;
  --focus: #2680c2;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 1000;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.container {
  width: min(960px, calc(100% - 32px));
  margin-inline: auto;
}

/* ---- Header / Footer ---- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  min-height: 64px;
}

.brand {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.site-footer {
  margin-top: 48px;
  padding: 28px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---- Hero ---- */

.hero {
  padding: 40px 0 8px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.25;
}

.lead {
  margin: 0;
  color: var(--text-muted);
  max-width: 42em;
}

/* ---- Panels ---- */

.panel {
  margin-top: 28px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.panel-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---- Actions ---- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #f0f4f8;
}

.btn-ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  min-width: 44px;
  padding: 8px 12px;
}

.btn-ghost:hover:not(:disabled) {
  background: #f0f4f8;
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #f5c1c1;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn:focus-visible,
.color-input:focus-visible,
.hex-input:focus-visible,
.share-input:focus-visible,
.code-block:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---- Palette ---- */

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.color-card {
  flex: 1 1 160px;
  max-width: 220px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.color-swatch {
  height: 120px;
  border-bottom: 1px solid var(--border);
}

.color-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.hex-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hex-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.hex-input.is-invalid {
  border-color: var(--danger);
  background: #fff5f5;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.8rem;
  min-height: 1.2em;
}

.color-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-input {
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}

.color-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.color-actions .btn {
  min-height: 40px;
  font-size: 0.85rem;
  padding: 8px 10px;
}

.inline-message {
  margin: 16px 0 0;
  min-height: 1.4em;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.inline-message.is-error {
  color: var(--danger);
}

/* ---- Site preview ---- */

.site-preview {
  --p1: #2f4f4f;
  --p2: #2c3e50;
  --p3: #ffd400;
  --p4: #ffffe5;
  --p5: #ecf0f1;
  --p6: #ecf0f1;
  --p7: #2c3e50;
  --p8: #ffd400;
  --p9: #ffffe5;
  --p10: #2f4f4f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--p4);
}

.preview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--p1);
  color: #fff;
}

.preview-logo {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.preview-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.preview-nav-link {
  color: #fff;
  text-decoration: none;
  opacity: 0.9;
  font-size: 0.95rem;
  cursor: default;
}

.preview-nav-link:hover {
  opacity: 1;
  text-decoration: underline;
  text-decoration-color: var(--p3);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.preview-hero {
  padding: 36px 24px 28px;
  background: var(--p4);
  color: var(--p2);
}

.preview-title {
  margin: 0 0 10px;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  color: var(--p2);
}

.preview-text {
  margin: 0 0 18px;
  max-width: 36em;
  color: var(--p2);
  opacity: 0.9;
}

.preview-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border: none;
  border-radius: 999px;
  background: var(--p3);
  color: var(--p2);
  font-weight: 700;
  cursor: default;
}

.preview-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 0 20px 28px;
  background: var(--p4);
}

.preview-card {
  padding: 18px;
  background: var(--p5);
  border: 2px solid var(--p5);
  border-radius: var(--radius-sm);
  color: var(--p2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.preview-card[data-card="1"] {
  border-color: var(--p6);
}

.preview-card[data-card="2"] {
  border-top: 4px solid var(--p7);
}

.preview-card[data-card="3"] {
  box-shadow: inset 0 0 0 2px var(--p8);
}

.preview-card h4 {
  margin: 0 0 8px;
}

.preview-card p {
  margin: 0;
  font-size: 0.92rem;
}

.preview-footer {
  padding: 16px 20px;
  background: var(--p2);
  color: #fff;
  text-align: center;
  font-size: 0.9rem;
}

.preview-footer p {
  margin: 0;
}

/* ---- CSS output / Share ---- */

.code-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.code-block {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: #102a43;
  color: #f0f4f8;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.share-input {
  flex: 1 1 240px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

/* ---- Howto ---- */

.howto-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.howto-list li + li {
  margin-top: 8px;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1100;
  transform: translateX(-50%);
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: #102a43;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 600;
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

/* ---- Responsive ---- */

@media (max-width: 720px) {
  .panel {
    padding: 18px;
  }

  .color-card {
    max-width: none;
    flex-basis: calc(50% - 8px);
  }

  .preview-cards {
    grid-template-columns: 1fr;
  }

  .share-row .btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .color-card {
    flex-basis: 100%;
  }

  .actions .btn {
    width: 100%;
  }
}
