:root {
  --bg: #ffffff;
  --text: #555;
  --text-dim: #999;
  --text-bright: #111;
  --line: #e5e5e5;
  --tap-min: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-weight: 400;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(28px + var(--safe-top)) 20px 16px;
  background: var(--bg);
}

.app-title {
  margin: 0 0 22px;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text-bright);
}
.app-title .logo-accent {
  font-weight: 800;
}

.search-wrap input {
  width: 100%;
  height: var(--tap-min);
  padding: 0 2px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text-bright);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  border-radius: 0;
}
.search-wrap input::placeholder { color: var(--text-dim); }
.search-wrap input:focus {
  outline: none;
  border-bottom-color: var(--text);
}

/* ---------- Main / view ---------- */
.view {
  flex: 1;
  padding: 4px 20px calc(90px + var(--safe-bottom));
  overflow-x: hidden;
}

/* ---------- Home: sección Destacadas + carrusel de todas ---------- */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 24px 0 12px;
}
.section-title:first-child { margin-top: 8px; }

.app-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.app-icon-grid.search-results {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
}

.app-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-carousel::-webkit-scrollbar { display: none; }
.app-carousel .app-icon-btn { flex: 0 0 auto; scroll-snap-align: start; }

.app-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.app-carousel .app-icon-btn { width: 76px; }

.app-icon-box {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #f5f5f5;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  transition: transform 0.1s ease, background 0.15s ease;
}
.app-icon-btn:active .app-icon-box { transform: scale(0.92); background: #ececec; }

.app-icon-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.25;
  max-width: 80px;
}

.app-icon-btn.is-pending { cursor: default; }
.app-icon-btn.is-pending .app-icon-box { opacity: 0.45; }
.app-icon-btn.is-pending .app-icon-label { color: var(--text-dim); }
.app-icon-badge {
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

@media (max-width: 360px) {
  .app-icon-grid { gap: 8px; }
  .app-icon-box { width: 50px; height: 50px; font-size: 1.4rem; }
}

/* ---------- Vista de herramienta individual ---------- */
.tool-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tool-view-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
}

.back-btn {
  width: var(--tap-min);
  height: var(--tap-min);
  margin-left: -12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-view-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field label {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-dim);
}
.field input[type="text"],
.field input[type="number"],
.field input[type="range"],
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text-bright);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
}
.field input[type="range"] { accent-color: var(--text-bright); }
.field input[type="file"] {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.field input[type="file"]::file-selector-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-bright);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 14px;
  margin-right: 12px;
  cursor: pointer;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-bottom-color: var(--text-bright);
}

.output-box {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  font-family: ui-monospace, monospace;
  font-weight: 400;
  color: var(--text-bright);
  word-break: break-all;
  min-height: 56px;
  display: flex;
  align-items: center;
}

.actions-row {
  display: flex;
  gap: 24px;
}

.btn {
  flex: 1;
  min-height: var(--tap-min);
  min-width: 100px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
}
.btn-primary {
  font-weight: 700;
  color: var(--text-bright);
}
.btn-secondary {
  font-weight: 400;
  color: var(--text-dim);
}
.btn:active { opacity: 0.6; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  padding: 14px 0 calc(14px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.nav-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 400;
}
.nav-btn.active {
  color: var(--text-bright);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-weight: 300;
  margin-top: 60px;
  font-size: 0.9rem;
}
