@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

#fontflip-app {
	--ff-paper: #F7F6F1;
	--ff-paper-raised: #FFFFFF;
	--ff-ink: #14140F;
	--ff-muted: #86847A;
	--ff-hairline: #E4E2D8;
	--ff-accent: #3F3FF3;
	--ff-accent-ink: #FFFFFF;
	--ff-pro: #B8860B;
	--ff-radius: 14px;

	all: initial;
	display: block;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
	color: var(--ff-ink);
	background: var(--ff-paper);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;

	/* Width/margins are set precisely by JS (setupFullBleed) to span the
	   viewport regardless of the theme container. This is just the safe
	   pre-JS default. */
	width: 100%;
	overflow-x: hidden;
}
#fontflip-app *, #fontflip-app *::before, #fontflip-app *::after { box-sizing: border-box; }

/* -------------------------------------------------- Hero --------- */
.ff-hero {
	max-width: 1720px;
	margin: 0 auto;
	padding: 44px clamp(24px, 3.5vw, 72px) 28px;
	border-bottom: 1px solid var(--ff-hairline);
}
.ff-hero-top {
	display: flex; align-items: baseline; justify-content: space-between;
	gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.ff-eyebrow {
	font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 500;
	letter-spacing: 0.14em; color: var(--ff-accent);
}
.ff-hero-meta {
	font-family: 'Space Grotesk', sans-serif; font-weight: 700;
	font-size: clamp(20px, 2.4vw, 30px); color: var(--ff-ink);
}
.ff-tabs { display: inline-flex; gap: 4px; background: var(--ff-hairline); padding: 4px; border-radius: 999px; }
.ff-tab {
	all: unset; cursor: pointer; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
	padding: 8px 16px; border-radius: 999px; color: var(--ff-muted);
	transition: background .15s ease, color .15s ease;
}
.ff-tab.is-active { background: var(--ff-ink); color: var(--ff-paper); }

/* -------------------------------------------------- Studio grid -- */
.ff-studio {
	display: grid;
	/* Compose : Preview.  Preview is wider because it holds the canvas plus
	   all the effect/export controls. Flip to `1.4fr minmax(0,1fr)` to make
	   Compose the wider pane instead. */
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
	gap: 0;
	width: 100%;
	max-width: 1720px;
	margin: 0 auto;
	align-items: stretch;
}
.ff-pane {
	padding: 36px clamp(24px, 3.5vw, 72px) 64px;
	min-width: 0;
}
.ff-pane-input { border-right: 1px solid var(--ff-hairline); }
.ff-pane-head {
	display: flex; align-items: center; justify-content: space-between;
	gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.ff-pane-title {
	font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 15px;
	letter-spacing: 0.02em; margin: 0; text-transform: uppercase; color: var(--ff-ink);
}

/* -------------------------------------------------- Input (unicode) */
.ff-input-wrap {
	background: var(--ff-paper-raised); border: 1px solid var(--ff-hairline);
	border-radius: var(--ff-radius); padding: 24px 24px 14px;
}
.ff-input {
	width: 100%; min-height: 300px; resize: vertical; border: none; outline: none;
	background: transparent; font-family: 'Space Grotesk', sans-serif;
	font-size: clamp(20px, 2.2vw, 28px); font-weight: 500; line-height: 1.35; color: var(--ff-ink);
}
.ff-input::placeholder { color: var(--ff-muted); }
.ff-input-foot {
	display: flex; justify-content: space-between; align-items: center;
	padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--ff-hairline);
}
.ff-count { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ff-muted); }
.ff-clear {
	all: unset; cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
	color: var(--ff-muted); padding: 6px 10px; border-radius: 999px;
}
.ff-clear:hover { color: var(--ff-ink); background: var(--ff-paper); }

/* -------------------------------------------------- Filters ------ */
.ff-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.ff-chip {
	all: unset; cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
	letter-spacing: 0.02em; padding: 7px 14px; border-radius: 999px;
	border: 1px solid var(--ff-hairline); color: var(--ff-muted);
	transition: border-color .15s ease, color .15s ease;
}
.ff-chip.is-active { border-color: var(--ff-accent); color: var(--ff-accent); }
.ff-chip:hover { color: var(--ff-ink); }

/* -------------------------------------------------- Cards grid --- */
.ff-grid {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.ff-card {
	position: relative; background: var(--ff-paper-raised); border: 1px solid var(--ff-hairline);
	border-radius: var(--ff-radius); padding: 18px 18px 14px; display: flex; flex-direction: column;
	min-height: 150px; transition: border-color .15s ease;
}
.ff-card:hover { border-color: #cfccbd; }
.ff-card-tag { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ff-card-index { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ff-muted); }
.ff-card-label {
	font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500;
	letter-spacing: 0.06em; text-transform: uppercase; color: var(--ff-ink);
}
.ff-badge {
	margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 500;
	letter-spacing: 0.06em; color: var(--ff-pro); border: 1px solid var(--ff-pro);
	border-radius: 999px; padding: 2px 8px;
}
.ff-card-output {
	flex: 1; margin: 0 0 14px; font-size: 18px; line-height: 1.4; word-break: break-word; white-space: pre-wrap;
}
.ff-card-foot {
	display: flex; align-items: center; justify-content: flex-end; gap: 10px;
	border-top: 1px solid var(--ff-hairline); padding-top: 12px;
}
.ff-card.is-locked .ff-card-output { filter: blur(3px); user-select: none; }

/* -------------------------------------------------- Buttons ------ */
.ff-btn {
	all: unset; cursor: pointer; font-family: 'Inter', sans-serif; font-weight: 600; font-size: 12px;
	padding: 9px 16px; border-radius: 999px; text-align: center; transition: opacity .15s ease, background .15s ease;
}
.ff-btn-primary { background: var(--ff-ink); color: var(--ff-paper); }
.ff-btn-primary:hover { opacity: 0.85; }
.ff-btn-pro { background: var(--ff-pro); color: #fff; }
.ff-btn-pro:hover { opacity: 0.85; }
.ff-btn-ghost {
	background: var(--ff-paper-raised); color: var(--ff-ink); border: 1px solid var(--ff-hairline);
	font-family: 'IBM Plex Mono', monospace; padding: 8px 12px;
}
.ff-btn-ghost:hover { border-color: var(--ff-ink); }
.ff-btn-sm { font-size: 11px; }
.ff-btn-block { display: block; width: 100%; padding: 14px 16px; font-size: 14px; }

/* -------------------------------------------------- Real-font editor */
.ff-font-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ff-field-label {
	font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ff-muted);
	text-transform: uppercase; letter-spacing: 0.06em;
}
.ff-select {
	flex: 1; font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
	padding: 10px 12px; border-radius: 10px; border: 1px solid var(--ff-hairline);
	background: var(--ff-paper-raised); color: var(--ff-ink); cursor: pointer;
}
.ff-tip { margin-bottom: 12px; }

.ff-format-toolbar {
	display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px;
}
.ff-swatch-label {
	display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
	font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ff-ink);
	border: 1px solid var(--ff-hairline); border-radius: 999px; padding: 6px 12px; background: var(--ff-paper-raised);
}
.ff-swatch-label:hover { border-color: var(--ff-ink); }
.ff-swatch-dot {
	width: 14px; height: 14px; border-radius: 50%;
	background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); border: 1px solid rgba(0,0,0,.15);
}
.ff-color-swatch { width: 0; height: 0; opacity: 0; position: absolute; pointer-events: none; }

.ff-editor-wrap {
	background: var(--ff-paper-raised); border: 1px solid var(--ff-hairline);
	border-radius: var(--ff-radius); padding: 20px 22px;
}
.ff-editor {
	min-height: 320px; outline: none; font-family: 'Space Grotesk', sans-serif;
	font-size: clamp(22px, 1.9vw, 30px); font-weight: 500; line-height: 1.45; color: var(--ff-ink);
	word-break: break-word;
}
.ff-editor:empty::before { content: attr(data-placeholder); color: var(--ff-muted); }
.ff-run { border-radius: 3px; }

/* -------------------------------------------------- Preview ------ */
.ff-preview {
	border: 1px solid var(--ff-hairline); border-radius: var(--ff-radius);
	overflow: auto; margin-bottom: 22px; background: var(--ff-paper-raised);
	min-height: 380px; max-height: 620px; display: flex; align-items: center; justify-content: center;
	padding: 8px;
}
.ff-preview.is-fit { overflow: hidden; }
.ff-preview.is-transparent {
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #e9e7dd 25%, transparent 25%),
		linear-gradient(-45deg, #e9e7dd 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #e9e7dd 75%),
		linear-gradient(-45deg, transparent 75%, #e9e7dd 75%);
	background-size: 22px 22px;
	background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}
.ff-preview-canvas { display: block; width: 100%; height: auto; }
.ff-preview-canvas.is-fit { width: auto; max-width: 100%; max-height: 600px; height: auto; }

.ff-preview-actions { display: inline-flex; gap: 8px; }
.ff-preview-toggle {
	all: unset; cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
	padding: 7px 14px; border-radius: 999px; border: 1px solid var(--ff-hairline); color: var(--ff-muted);
}
.ff-preview-toggle.is-active { border-color: var(--ff-accent); color: var(--ff-accent); background: rgba(63,63,243,0.06); }
.ff-preview-toggle:hover { color: var(--ff-ink); }

/* -------------------------------------------------- Options ------ */
.ff-options {
	display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px 22px; margin-bottom: 22px;
}
.ff-opt { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ff-opt-wide { grid-column: 1 / -1; }
.ff-opt > label {
	font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ff-muted);
	text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: center; gap: 8px;
}
.ff-opt input[type="color"] {
	-webkit-appearance: none; appearance: none; width: 100%; height: 40px;
	border: 1px solid var(--ff-hairline); border-radius: 10px; padding: 3px; background: var(--ff-paper-raised); cursor: pointer;
}
.ff-opt input[type="color"]:disabled { opacity: .4; cursor: not-allowed; }
.ff-opt input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ff-opt input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.ff-opt input[type="range"] { width: 100%; accent-color: var(--ff-accent); }
.ff-range-val { font-family: 'IBM Plex Mono', monospace; color: var(--ff-ink); }

/* paired colour + number (outline / shadow) */
.ff-opt-pair { display: flex; align-items: center; gap: 8px; }
.ff-opt-pair input[type="color"] { width: 44px; flex: 0 0 44px; height: 40px; }
.ff-num {
	width: 100%; min-width: 0; height: 40px; border: 1px solid var(--ff-hairline); border-radius: 10px;
	padding: 0 10px; font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--ff-ink);
	background: var(--ff-paper-raised);
}
.ff-unit { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ff-muted); }

/* toggle switch */
.ff-switch { position: relative; display: inline-flex; align-items: center; width: 46px; height: 26px; }
.ff-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.ff-switch-track {
	position: absolute; inset: 0; background: var(--ff-hairline); border-radius: 999px; transition: background .15s ease;
}
.ff-switch-track::after {
	content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
	background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.ff-switch input:checked ~ .ff-switch-track { background: var(--ff-accent); }
.ff-switch input:checked ~ .ff-switch-track::after { transform: translateX(20px); }

/* segmented control */
.ff-segments { display: inline-flex; border: 1px solid var(--ff-hairline); border-radius: 10px; overflow: hidden; }
.ff-seg {
	all: unset; cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
	padding: 9px 16px; color: var(--ff-muted); border-right: 1px solid var(--ff-hairline);
}
.ff-seg:last-child { border-right: none; }
.ff-seg.is-active { background: var(--ff-ink); color: var(--ff-paper); }

.ff-export-row { margin-top: 4px; }
.ff-hint { font-size: 11px; color: var(--ff-muted); }

/* dual download buttons */
.ff-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.ff-dl {
	all: unset; cursor: pointer; box-sizing: border-box; display: flex; flex-direction: column; gap: 2px;
	padding: 14px 18px; border-radius: 14px; text-align: center; align-items: center;
	transition: opacity .15s ease, background .15s ease, border-color .15s ease;
}
.ff-dl-title { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 14px; }
.ff-dl-sub { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 11px; opacity: 0.75; }
.ff-dl-primary { background: var(--ff-accent); color: var(--ff-accent-ink); }
.ff-dl-primary:hover { opacity: 0.9; }
.ff-dl-secondary { background: var(--ff-paper-raised); color: var(--ff-ink); border: 1px solid var(--ff-hairline); }
.ff-dl-secondary:hover { border-color: var(--ff-ink); }
.ff-format-note {
	text-align: center; margin-top: 10px; font-family: 'IBM Plex Mono', monospace;
	font-size: 11px; color: var(--ff-muted); letter-spacing: 0.04em;
}

/* -------------------------------------------------- Empty -------- */
.ff-empty {
	grid-column: 1 / -1; text-align: center; color: var(--ff-muted);
	padding: 60px 20px; font-family: 'Space Grotesk', sans-serif;
}

/* -------------------------------------------------- Toast / modal */
.ff-toast {
	position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
	background: var(--ff-ink); color: var(--ff-paper); font-family: 'Inter', sans-serif;
	font-size: 13px; font-weight: 500; padding: 12px 20px; border-radius: 999px;
	opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 50;
}
.ff-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.ff-modal {
	position: fixed; inset: 0; background: rgba(20, 20, 15, 0.45);
	display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.ff-modal-card {
	background: var(--ff-paper-raised); border-radius: var(--ff-radius); padding: 28px; max-width: 360px; text-align: center;
}
.ff-modal-card h3 { font-family: 'Space Grotesk', sans-serif; font-size: 20px; margin: 0 0 10px; }
.ff-modal-card p { color: var(--ff-muted); font-size: 14px; margin: 0 0 18px; }

.ff-loading { padding: 60px; text-align: center; color: var(--ff-muted); font-family: 'Space Grotesk', sans-serif; }

/* -------------------------------------------------- Responsive --- */
@media (max-width: 1100px) {
	.ff-options { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
	.ff-studio { grid-template-columns: 1fr; }
	.ff-pane-input { border-right: none; border-bottom: 1px solid var(--ff-hairline); }
	.ff-pane { padding-bottom: 36px; }
}
@media (max-width: 560px) {
	.ff-grid { grid-template-columns: 1fr; }
	.ff-options { grid-template-columns: 1fr; }
	.ff-export-grid { grid-template-columns: 1fr; }
}
